summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJames Smith <james@loopj.com>2011-08-01 00:44:51 -0700
committerJames Smith <james@loopj.com>2011-08-01 00:44:51 -0700
commit0ba398f9e1aaf05e72406d5c840f013eebb6b260 (patch)
tree66a866657780870fcfb338606ec92b29da82eb4c /lib
parenta15a8c4a98bc1aff024c3ef44dec48309ff4f90b (diff)
parenta738ca9b645c3cc53bdb01e8676202ceca449ccf (diff)
downloadzsh-0ba398f9e1aaf05e72406d5c840f013eebb6b260.tar.gz
zsh-0ba398f9e1aaf05e72406d5c840f013eebb6b260.tar.bz2
zsh-0ba398f9e1aaf05e72406d5c840f013eebb6b260.zip
Merge in recent stuff
Diffstat (limited to 'lib')
-rw-r--r--lib/aliases.zsh1
-rw-r--r--lib/completion.zsh4
-rw-r--r--lib/edit-command-line.zsh3
-rw-r--r--lib/functions.zsh35
-rw-r--r--lib/git.zsh25
-rw-r--r--lib/key-bindings.zsh8
-rw-r--r--lib/misc.zsh2
-rw-r--r--lib/spectrum.zsh8
-rw-r--r--lib/termsupport.zsh13
9 files changed, 48 insertions, 51 deletions
diff --git a/lib/aliases.zsh b/lib/aliases.zsh
index b47de5bde..0555be264 100644
--- a/lib/aliases.zsh
+++ b/lib/aliases.zsh
@@ -22,4 +22,3 @@ alias sl=ls # often screw this up
alias afind='ack-grep -il'
-alias x=extract
diff --git a/lib/completion.zsh b/lib/completion.zsh
index e8e9776a5..fdd0a8536 100644
--- a/lib/completion.zsh
+++ b/lib/completion.zsh
@@ -4,14 +4,10 @@ unsetopt menu_complete # do not autoselect the first completion entry
unsetopt flowcontrol
setopt auto_menu # show completion menu on succesive tab press
setopt complete_in_word
-setopt complete_aliases
setopt always_to_end
WORDCHARS=''
-autoload -U compinit
-compinit -i
-
zmodload -i zsh/complist
## case-insensitive (all),partial-word and then substring completion
diff --git a/lib/edit-command-line.zsh b/lib/edit-command-line.zsh
new file mode 100644
index 000000000..db2000325
--- /dev/null
+++ b/lib/edit-command-line.zsh
@@ -0,0 +1,3 @@
+autoload -U edit-command-line
+zle -N edit-command-line
+bindkey '\C-x\C-e' edit-command-line
diff --git a/lib/functions.zsh b/lib/functions.zsh
index 6f5d015f7..ef7cc6383 100644
--- a/lib/functions.zsh
+++ b/lib/functions.zsh
@@ -15,38 +15,3 @@ function take() {
cd $1
}
-function extract() {
- unset REMOVE_ARCHIVE
-
- if test "$1" = "-r"; then
- REMOVE=1
- shift
- fi
- if [[ -f $1 ]]; then
- case $1 in
- *.tar.bz2) tar xvjf $1;;
- *.tar.gz) tar xvzf $1;;
- *.tar.xz) tar xvJf $1;;
- *.tar.lzma) tar --lzma -xvf $1;;
- *.bz2) bunzip $1;;
- *.rar) unrar $1;;
- *.gz) gunzip $1;;
- *.tar) tar xvf $1;;
- *.tbz2) tar xvjf $1;;
- *.tgz) tar xvzf $1;;
- *.zip) unzip $1;;
- *.Z) uncompress $1;;
- *.7z) 7z x $1;;
- *) echo "'$1' cannot be extracted via >extract<";;
- esac
-
- if [[ $REMOVE_ARCHIVE -eq 1 ]]; then
- echo removing "$1";
- /bin/rm "$1";
- fi
-
- else
- echo "'$1' is not a valid file"
- fi
-}
-
diff --git a/lib/git.zsh b/lib/git.zsh
index 75367f877..010cb2a1c 100644
--- a/lib/git.zsh
+++ b/lib/git.zsh
@@ -4,8 +4,8 @@ function git_prompt_info() {
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
}
-# get dirty status of the current working tree
-parse_git_dirty () {
+# Checks if working tree is dirty
+parse_git_dirty() {
if [[ -n $(git status -s 2> /dev/null) ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
else
@@ -33,7 +33,24 @@ git_remote_status() {
fi
}
-# get the status of the working tree
+# Checks if there are commits ahead from remote
+function git_prompt_ahead() {
+ if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
+ echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
+ fi
+}
+
+# Formats prompt string for current git commit short SHA
+function git_prompt_short_sha() {
+ SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
+}
+
+# Formats prompt string for current git commit long SHA
+function git_prompt_long_sha() {
+ SHA=$(git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
+}
+
+# Get the status of the working tree
git_prompt_status() {
INDEX=$(git status --porcelain 2> /dev/null)
STATUS=""
@@ -57,6 +74,8 @@ git_prompt_status() {
fi
if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
+ elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then
+ STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
fi
if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
diff --git a/lib/key-bindings.zsh b/lib/key-bindings.zsh
index 7196a88ff..9c2dda35a 100644
--- a/lib/key-bindings.zsh
+++ b/lib/key-bindings.zsh
@@ -1,6 +1,4 @@
# TODO: Explain what some of this does..
-autoload -U compinit
-compinit -i
bindkey -e
bindkey '\ew' kill-region
@@ -22,6 +20,12 @@ bindkey ' ' magic-space # also do history expansion on space
bindkey '^[[Z' reverse-menu-complete
+# Make the delete key (or Fn + Delete on the Mac) work instead of outputting a ~
+bindkey '^?' backward-delete-char
+bindkey "^[[3~" delete-char
+bindkey "^[3;5~" delete-char
+bindkey "\e[3~" delete-char
+
# consider emacs keybindings:
#bindkey -e ## emacs key bindings
diff --git a/lib/misc.zsh b/lib/misc.zsh
index 4c1743657..88732e664 100644
--- a/lib/misc.zsh
+++ b/lib/misc.zsh
@@ -10,4 +10,4 @@ setopt long_list_jobs
## pager
export PAGER=less
-export LC_CTYPE=en_US.UTF-8
+export LC_CTYPE=$LANG
diff --git a/lib/spectrum.zsh b/lib/spectrum.zsh
index 4006a7fe1..2fdf537ef 100644
--- a/lib/spectrum.zsh
+++ b/lib/spectrum.zsh
@@ -18,3 +18,11 @@ for color in {000..255}; do
FG[$color]="%{[38;5;${color}m%}"
BG[$color]="%{[48;5;${color}m%}"
done
+
+# Show all 256 colors with color number
+function spectrum_ls() {
+ for code in {000..255}; do
+ print -P -- "$code: %F{$code}Test%f"
+ done
+}
+
diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
index e1e536690..22e7f372f 100644
--- a/lib/termsupport.zsh
+++ b/lib/termsupport.zsh
@@ -3,11 +3,12 @@
#Fully support screen, iterm, and probably most modern xterm and rxvt
#Limited support for Apple Terminal (Terminal can't set window or tab separately)
function title {
- if [[ "$TERM" == "screen" ]]; then
- print -Pn "\ek$1\e\\" #set screen hardstatus, usually truncated at 20 chars
- elif [[ ($TERM =~ "^xterm") ]] || [[ ($TERM == "rxvt") ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
- print -Pn "\e]2;$2\a" #set window name
- print -Pn "\e]1;$1\a" #set icon (=tab) name (will override window name on broken terminal)
+ [ "$DISABLE_AUTO_TITLE" != "true" ] || return
+ if [[ "$TERM" == screen* ]]; then
+ print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
+ elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
+ print -Pn "\e]2;$2:q\a" #set window name
+ print -Pn "\e]1;$1:q\a" #set icon (=tab) name (will override window name on broken terminal)
fi
}
@@ -21,6 +22,8 @@ function precmd {
#Appears at the beginning of (and during) of command execution
function preexec {
+ emulate -L zsh
+ setopt extended_glob
local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
title "$CMD" "%100>...>$2%<<"
}