summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/completion.zsh15
-rw-r--r--lib/directories.zsh4
-rw-r--r--lib/functions.zsh4
-rw-r--r--lib/git.zsh33
-rw-r--r--lib/history.zsh13
-rw-r--r--lib/key-bindings.zsh6
-rw-r--r--lib/misc.zsh2
-rw-r--r--lib/termsupport.zsh14
8 files changed, 70 insertions, 21 deletions
diff --git a/lib/completion.zsh b/lib/completion.zsh
index fdd0a8536..f31e101d5 100644
--- a/lib/completion.zsh
+++ b/lib/completion.zsh
@@ -32,19 +32,21 @@ zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-dir
cdpath=(.)
# use /etc/hosts and known_hosts for hostname completion
+[ -r /etc/ssh/ssh_known_hosts ] && _global_ssh_hosts=(${${${${(f)"$(</etc/ssh/ssh_known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
hosts=(
+ "$_global_ssh_hosts[@]"
"$_ssh_hosts[@]"
"$_etc_hosts[@]"
- `hostname`
+ "$HOST"
localhost
)
zstyle ':completion:*:hosts' hosts $hosts
# Use caching so that commands like apt and dpkg complete are useable
zstyle ':completion::complete:*' use-cache 1
-zstyle ':completion::complete:*' cache-path ~/.oh-my-zsh/cache/
+zstyle ':completion::complete:*' cache-path $ZSH/cache/
# Don't complete uninteresting users
zstyle ':completion:*:*:*:users' ignored-patterns \
@@ -59,3 +61,12 @@ zstyle ':completion:*:*:*:users' ignored-patterns \
# ... unless we really want to.
zstyle '*' single-ignored show
+if [ "x$COMPLETION_WAITING_DOTS" = "xtrue" ]; then
+ expand-or-complete-with-dots() {
+ echo -n "\e[31m......\e[0m"
+ zle expand-or-complete
+ zle redisplay
+ }
+ zle -N expand-or-complete-with-dots
+ bindkey "^I" expand-or-complete-with-dots
+fi
diff --git a/lib/directories.zsh b/lib/directories.zsh
index bb114f615..a787db9eb 100644
--- a/lib/directories.zsh
+++ b/lib/directories.zsh
@@ -36,9 +36,9 @@ cd () {
alias md='mkdir -p'
alias rd=rmdir
-alias d='dirs -v'
+alias d='dirs -v | head -10'
# mkdir & cd to it
function mcd() {
mkdir -p "$1" && cd "$1";
-} \ No newline at end of file
+}
diff --git a/lib/functions.zsh b/lib/functions.zsh
index ef7cc6383..d2dcadd0c 100644
--- a/lib/functions.zsh
+++ b/lib/functions.zsh
@@ -3,11 +3,11 @@ function zsh_stats() {
}
function uninstall_oh_my_zsh() {
- /bin/sh $ZSH/tools/uninstall.sh
+ /usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/uninstall.sh
}
function upgrade_oh_my_zsh() {
- /bin/sh $ZSH/tools/upgrade.sh
+ /usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh
}
function take() {
diff --git a/lib/git.zsh b/lib/git.zsh
index 010cb2a1c..258b1df8f 100644
--- a/lib/git.zsh
+++ b/lib/git.zsh
@@ -4,9 +4,14 @@ function git_prompt_info() {
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
}
+
# Checks if working tree is dirty
parse_git_dirty() {
- if [[ -n $(git status -s 2> /dev/null) ]]; then
+ local SUBMODULE_SYNTAX=''
+ if [[ $POST_1_7_2_GIT -gt 0 ]]; then
+ SUBMODULE_SYNTAX="--ignore-submodules=dirty"
+ fi
+ if [[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
else
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
@@ -82,3 +87,29 @@ git_prompt_status() {
fi
echo $STATUS
}
+
+#compare the provided version of git to the version installed and on path
+#prints 1 if input version <= installed version
+#prints -1 otherwise
+function git_compare_version() {
+ local INPUT_GIT_VERSION=$1;
+ local INSTALLED_GIT_VERSION
+ INPUT_GIT_VERSION=(${(s/./)INPUT_GIT_VERSION});
+ INSTALLED_GIT_VERSION=($(git --version));
+ INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]});
+
+ for i in {1..3}; do
+ if [[ $INSTALLED_GIT_VERSION[$i] -lt $INPUT_GIT_VERSION[$i] ]]; then
+ echo -1
+ return 0
+ fi
+ done
+ echo 1
+}
+
+#this is unlikely to change so make it all statically assigned
+POST_1_7_2_GIT=$(git_compare_version "1.7.2")
+#clean up the namespace slightly by removing the checker function
+unset -f git_compare_version
+
+
diff --git a/lib/history.zsh b/lib/history.zsh
index ca6f57079..876936b87 100644
--- a/lib/history.zsh
+++ b/lib/history.zsh
@@ -3,14 +3,11 @@ HISTFILE=$HOME/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
-setopt hist_ignore_dups # ignore duplication command history list
-setopt share_history # share command history data
-
-setopt hist_verify
-setopt inc_append_history
+setopt append_history
setopt extended_history
setopt hist_expire_dups_first
+setopt hist_ignore_dups # ignore duplication command history list
setopt hist_ignore_space
-
-setopt SHARE_HISTORY
-setopt APPEND_HISTORY
+setopt hist_verify
+setopt inc_append_history
+setopt share_history # share command history data
diff --git a/lib/key-bindings.zsh b/lib/key-bindings.zsh
index 9c2dda35a..5f499f3e8 100644
--- a/lib/key-bindings.zsh
+++ b/lib/key-bindings.zsh
@@ -3,7 +3,6 @@
bindkey -e
bindkey '\ew' kill-region
bindkey -s '\el' "ls\n"
-bindkey -s '\e.' "..\n"
bindkey '^r' history-incremental-search-backward
bindkey "^[[5~" up-line-or-history
bindkey "^[[6~" down-line-or-history
@@ -14,10 +13,15 @@ bindkey '^[[B' down-line-or-search
bindkey "^[[H" beginning-of-line
bindkey "^[[1~" beginning-of-line
+bindkey "^[OH" beginning-of-line
bindkey "^[[F" end-of-line
bindkey "^[[4~" end-of-line
+bindkey "^[OF" end-of-line
bindkey ' ' magic-space # also do history expansion on space
+bindkey "^[[1;5C" forward-word
+bindkey "^[[1;5D" backward-word
+
bindkey '^[[Z' reverse-menu-complete
# Make the delete key (or Fn + Delete on the Mac) work instead of outputting a ~
diff --git a/lib/misc.zsh b/lib/misc.zsh
index 88732e664..0f7e7e925 100644
--- a/lib/misc.zsh
+++ b/lib/misc.zsh
@@ -9,5 +9,5 @@ bindkey "^[m" copy-prev-shell-word
setopt long_list_jobs
## pager
-export PAGER=less
+export PAGER="less -R"
export LC_CTYPE=$LANG
diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
index 22e7f372f..e26fef6d3 100644
--- a/lib/termsupport.zsh
+++ b/lib/termsupport.zsh
@@ -3,8 +3,10 @@
#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 {
- [ "$DISABLE_AUTO_TITLE" != "true" ] || return
- if [[ "$TERM" == screen* ]]; then
+ if [[ "$DISABLE_AUTO_TITLE" == "true" ]] || [[ "$EMACS" == *term* ]]; then
+ return
+ fi
+ 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
@@ -16,14 +18,18 @@ ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
#Appears when you have the prompt
-function precmd {
+function omz_termsupport_precmd {
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
}
#Appears at the beginning of (and during) of command execution
-function preexec {
+function omz_termsupport_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%<<"
}
+
+autoload -U add-zsh-hook
+add-zsh-hook precmd omz_termsupport_precmd
+add-zsh-hook preexec omz_termsupport_preexec