From 814157761eb407cdab9714fdf9c1f1588901df06 Mon Sep 17 00:00:00 2001 From: James Cox Date: Tue, 22 Sep 2009 16:39:53 +0100 Subject: [PATCH 01/11] some helpers to make directory traversal go easier.... --- aliases.zsh | 6 +++++- directories.zsh | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 directories.zsh diff --git a/aliases.zsh b/aliases.zsh index 253c2ac..cd17781 100644 --- a/aliases.zsh +++ b/aliases.zsh @@ -10,6 +10,7 @@ alias .='pwd' alias ...='cd ../..' alias _='sudo' +alias ss='sudo su -' #alias g='grep -in' @@ -26,7 +27,10 @@ alias gba='git branch -a' alias history='fc -l 1' alias ls='ls -F' -alias ll='ls -al' +alias ll='ls -alr' +alias l='ls' +alias ll='ls -l' +alias sl=ls # often screw this up alias sgem='sudo gem' diff --git a/directories.zsh b/directories.zsh new file mode 100644 index 0000000..32b8014 --- /dev/null +++ b/directories.zsh @@ -0,0 +1,38 @@ +# Changing/making/removing directory + + +alias ..='cd ..' +alias cd..='cd ..' +alias cd...='cd ../..' +alias cd....='cd ../../..' +alias cd.....='cd ../../../..' +alias cd/='cd /' + +alias 1='cd -' +alias 2='cd +2' +alias 3='cd +3' +alias 4='cd +4' +alias 5='cd +5' +alias 6='cd +6' +alias 7='cd +7' +alias 8='cd +8' +alias 9='cd +9' + +cd () { + if [[ "x$*" == "x..." ]]; then + cd ../.. + elif [[ "x$*" == "x...." ]]; then + cd ../../.. + elif [[ "x$*" == "x....." ]]; then + cd ../../.. + elif [[ "x$*" == "x......" ]]; then + cd ../../../.. + else + builtin cd "$@" + fi +} + +alias md='mkdir -p' +alias rd=rmdir + +alias d='dirs -v' \ No newline at end of file From 039e17d84175b091137bfaff59ccfaa67a2300d6 Mon Sep 17 00:00:00 2001 From: James Cox Date: Tue, 22 Sep 2009 16:41:22 +0100 Subject: [PATCH 02/11] make correction work; this is a nicer way of handling typos in commands --- correction.zsh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 correction.zsh diff --git a/correction.zsh b/correction.zsh new file mode 100644 index 0000000..c9fecb0 --- /dev/null +++ b/correction.zsh @@ -0,0 +1,6 @@ +setopt correct_all + +alias man='nocorrect man' +alias mv='nocorrect mv' +alias mysql='nocorrect mysql' +alias mv='nocorrect mv' From 404fee6cb1982cebaa0d9ff925127820c642fc82 Mon Sep 17 00:00:00 2001 From: James Cox Date: Tue, 22 Sep 2009 23:01:55 +0100 Subject: [PATCH 03/11] add in xterms / title hacks --- xterms.zsh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 xterms.zsh diff --git a/xterms.zsh b/xterms.zsh new file mode 100644 index 0000000..17c6a10 --- /dev/null +++ b/xterms.zsh @@ -0,0 +1,16 @@ +# Specific to xterms, such as OS X terminal + +if [[ "${TERM}" == xterm* ]]; then + unset TMOUT + + precmd () { + print -Pn "\033]0;%n@%m %~\007" + #print -Pn "\033]0;%n@%m%# %~ %l %w :: %T\a" ## or use this + } + + preexec () { + print -Pn "\033]0;%n@%m <$1> %~\007" + #print -Pn "\033]0;%n@%m%# <$1> %~ %l %w :: %T\a" ## or use this + } + +fi \ No newline at end of file From 65bbe3fa6a066314e181e58cb3be7169771840d2 Mon Sep 17 00:00:00 2001 From: James Cox Date: Tue, 22 Sep 2009 23:02:18 +0100 Subject: [PATCH 04/11] minimalist --- themes/imajes.zsh-theme | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 themes/imajes.zsh-theme diff --git a/themes/imajes.zsh-theme b/themes/imajes.zsh-theme new file mode 100644 index 0000000..88c35b6 --- /dev/null +++ b/themes/imajes.zsh-theme @@ -0,0 +1,5 @@ +# Found on the ZshWiki +# http://zshwiki.org/home/config/prompt +# + +PROMPT="%{$fg[red]%}%%%{$reset_color%} " \ No newline at end of file From 82e2883a4138bc08912442da198d4e1c162d384f Mon Sep 17 00:00:00 2001 From: James Cox Date: Tue, 22 Sep 2009 23:27:28 +0100 Subject: [PATCH 05/11] some todo notes, take @chris2's titlebar improvements and poke at completions --- README.textile | 4 ++++ completion.zsh | 11 +++++++---- key-bindings.zsh | 22 +++++++++++++++++++++- xterms.zsh | 37 +++++++++++++++++++++---------------- 4 files changed, 53 insertions(+), 21 deletions(-) diff --git a/README.textile b/README.textile index bf40869..851a5ab 100644 --- a/README.textile +++ b/README.textile @@ -59,3 +59,7 @@ h3. Send us your theme! I'm hoping to collect a bunch of themes for our command prompts. You can see existing ones in the @themes/@ directory. +h3. Todo from imajes: + +* need to make the title bar support git folder +* \ No newline at end of file diff --git a/completion.zsh b/completion.zsh index dff71cf..c993620 100644 --- a/completion.zsh +++ b/completion.zsh @@ -1,6 +1,8 @@ +## fixme - the load process here seems a bit bizarre + setopt noautomenu -setopt COMPLETE_IN_WORD -setopt ALWAYS_TO_END +setopt complete_in_word +setopt always_to_end unsetopt flowcontrol @@ -17,9 +19,10 @@ zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l: zstyle ':completion:*' list-colors '' zstyle ':completion:*' hosts $( sed 's/[, ].*$//' $HOME/.ssh/known_hosts ) -unsetopt MENU_COMPLETE -setopt AUTO_MENU +#unsetopt MENU_COMPLETE +#setopt AUTO_MENU +# should this be in keybindings? bindkey -M menuselect '^o' accept-and-infer-next-history zstyle ':completion:*:*:*:*:*' menu yes select diff --git a/key-bindings.zsh b/key-bindings.zsh index 20caad1..43082ae 100644 --- a/key-bindings.zsh +++ b/key-bindings.zsh @@ -11,4 +11,24 @@ bindkey "^[[H" beginning-of-line bindkey "^[[1~" beginning-of-line bindkey "^[[F" end-of-line bindkey "^[[4~" end-of-line -bindkey ' ' magic-space # also do history expansion on space \ No newline at end of file +bindkey ' ' magic-space # also do history expansion on space + + +# consider emacs keybindings: + +#bindkey -e ## emacs key bindings +# +#bindkey '^[[A' up-line-or-search +#bindkey '^[[B' down-line-or-search +#bindkey '^[^[[C' emacs-forward-word +#bindkey '^[^[[D' emacs-backward-word +# +#bindkey -s '^X^Z' '%-^M' +#bindkey '^[e' expand-cmd-path +#bindkey '^[^I' reverse-menu-complete +#bindkey '^X^N' accept-and-infer-next-history +#bindkey '^W' kill-region +#bindkey '^I' complete-word +## Fix weird sequence that rxvt produces +#bindkey -s '^[[Z' '\t' +# \ No newline at end of file diff --git a/xterms.zsh b/xterms.zsh index 17c6a10..fef9787 100644 --- a/xterms.zsh +++ b/xterms.zsh @@ -1,16 +1,21 @@ -# Specific to xterms, such as OS X terminal - -if [[ "${TERM}" == xterm* ]]; then - unset TMOUT - - precmd () { - print -Pn "\033]0;%n@%m %~\007" - #print -Pn "\033]0;%n@%m%# %~ %l %w :: %T\a" ## or use this - } - - preexec () { - print -Pn "\033]0;%n@%m <$1> %~\007" - #print -Pn "\033]0;%n@%m%# <$1> %~ %l %w :: %T\a" ## or use this - } - -fi \ No newline at end of file +case "$TERM" in + xterm*|rxvt*) + preexec () { + print -Pn "\e]0;%n@%m: $1\a" # xterm + } + precmd () { + print -Pn "\e]0;%n@%m: %~\a" # xterm + } + ;; + screen*) + preexec () { + local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} + echo -ne "\ek$CMD\e\\" + print -Pn "\e]0;%n@%m: $1\a" # xterm + } + precmd () { + echo -ne "\ekzsh\e\\" + print -Pn "\e]0;%n@%m: %~\a" # xterm + } + ;; +esac \ No newline at end of file From 2b8d218167297ea50ca2e0a9a6fda307b6f3da6a Mon Sep 17 00:00:00 2001 From: James Cox Date: Tue, 22 Sep 2009 23:36:25 +0100 Subject: [PATCH 06/11] would rather store history in $HOME and double size --- history.zsh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/history.zsh b/history.zsh index a093aa2..b2c8c03 100644 --- a/history.zsh +++ b/history.zsh @@ -7,9 +7,8 @@ setopt HIST_IGNORE_DUPS ## Command history configuration # -HISTFILE=$ZSH/log/.zsh_history -HISTSIZE=2500 -SAVEHIST=2500 +HISTFILE=$HOME/.zsh_history +HISTSIZE=5000 +SAVEHIST=5000 setopt hist_ignore_dups # ignore duplication command history list setopt share_history # share command history data - From ee31f463f2a9d9a9f75baca0e18aad88a54da9ec Mon Sep 17 00:00:00 2001 From: James Cox Date: Wed, 23 Sep 2009 00:44:57 +0100 Subject: [PATCH 07/11] tidy up history --- history.zsh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/history.zsh b/history.zsh index b2c8c03..356b649 100644 --- a/history.zsh +++ b/history.zsh @@ -1,10 +1,3 @@ -# History stuff. -setopt HIST_VERIFY -setopt INC_APPEND_HISTORY -setopt SHARE_HISTORY -setopt EXTENDED_HISTORY -setopt HIST_IGNORE_DUPS - ## Command history configuration # HISTFILE=$HOME/.zsh_history @@ -12,3 +5,8 @@ HISTSIZE=5000 SAVEHIST=5000 setopt hist_ignore_dups # ignore duplication command history list setopt share_history # share command history data + +setopt hist_verify +setopt inc_append_history +setopt extended_history +setopt hist_expire_dups_first From ed3b5693db45c2404ed53d799ef3d63bf08eb921 Mon Sep 17 00:00:00 2001 From: James Cox Date: Wed, 23 Sep 2009 00:45:15 +0100 Subject: [PATCH 08/11] misc useful --- misc.zsh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 misc.zsh diff --git a/misc.zsh b/misc.zsh new file mode 100644 index 0000000..c368cff --- /dev/null +++ b/misc.zsh @@ -0,0 +1,6 @@ +## smart urls +autoload -U url-quote-magic +zle -N self-insert url-quote-magic + +## file rename magick +bindkey "^[m" copy-prev-shell-word \ No newline at end of file From c5d82052842d2312f55e809b6eb3e1e5122c1742 Mon Sep 17 00:00:00 2001 From: James Cox Date: Wed, 23 Sep 2009 00:49:00 +0100 Subject: [PATCH 09/11] further refactorings --- .gitignore | 2 +- completion.zsh | 9 ++++++++- directories.zsh | 2 +- key-bindings.zsh | 2 ++ prompt.zsh | 17 +++++------------ 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 56d0a21..e807409 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ +locals.zsh log/.zsh_history - projects.zsh diff --git a/completion.zsh b/completion.zsh index c993620..795903d 100644 --- a/completion.zsh +++ b/completion.zsh @@ -19,7 +19,7 @@ zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l: zstyle ':completion:*' list-colors '' zstyle ':completion:*' hosts $( sed 's/[, ].*$//' $HOME/.ssh/known_hosts ) -#unsetopt MENU_COMPLETE +unsetopt MENU_COMPLETE #setopt AUTO_MENU # should this be in keybindings? @@ -31,3 +31,10 @@ zstyle ':completion:*:*:*:*:*' menu yes select zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w" zstyle ':completion:*:*:(ssh|scp):*:*' hosts `sed 's/^\([^ ,]*\).*$/\1/' ~/.ssh/known_hosts` + + +#complete on history +# zstyle ':completion:*:history-words' stop yes +# zstyle ':completion:*:history-words' remove-all-dups yes +# zstyle ':completion:*:history-words' list false +# zstyle ':completion:*:history-words' menu yes \ No newline at end of file diff --git a/directories.zsh b/directories.zsh index 32b8014..31d5336 100644 --- a/directories.zsh +++ b/directories.zsh @@ -1,5 +1,5 @@ # Changing/making/removing directory - +setopt auto_name_dirs alias ..='cd ..' alias cd..='cd ..' diff --git a/key-bindings.zsh b/key-bindings.zsh index 43082ae..2fae6d0 100644 --- a/key-bindings.zsh +++ b/key-bindings.zsh @@ -1,6 +1,8 @@ # TODO: Explain what some of this does.. autoload -U compinit compinit + +bindkey -e bindkey '\ew' kill-region bindkey -s '\el' "ls\n" bindkey -s '\e.' "..\n" diff --git a/prompt.zsh b/prompt.zsh index 31c33fe..3968968 100644 --- a/prompt.zsh +++ b/prompt.zsh @@ -1,19 +1,12 @@ export PAGER=less export LC_CTYPE=en_US.UTF-8 -bindkey -e +# speed stuff. -# Directory stuff. -setopt AUTO_NAME_DIRS - -# Speed stuff. - -#setopt NO_BEEP -setopt AUTO_CD -setopt MULTIOS -setopt CDABLEVARS - -bindkey -e +#setopt no_beep +setopt auto_cd +setopt multios +setopt cdablevarS if [[ x$WINDOW != x ]] then From 1f7d917ca40ca61bf437f2b0d1e1515873e3f6f4 Mon Sep 17 00:00:00 2001 From: James Cox Date: Wed, 23 Sep 2009 01:18:15 +0100 Subject: [PATCH 10/11] more fixes, more or less have this as i want --- directories.zsh | 2 ++ functions.zsh | 1 + key-bindings.zsh | 5 +++++ misc.zsh | 5 ++++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/directories.zsh b/directories.zsh index 31d5336..56d7a23 100644 --- a/directories.zsh +++ b/directories.zsh @@ -1,5 +1,7 @@ # Changing/making/removing directory setopt auto_name_dirs +setopt auto_pushd +setopt pushd_ignore_dups alias ..='cd ..' alias cd..='cd ..' diff --git a/functions.zsh b/functions.zsh index e3891f6..2fb096d 100644 --- a/functions.zsh +++ b/functions.zsh @@ -1,3 +1,4 @@ +## fixme, i duplicated this in xterms - oops function title { if [[ $TERM == "screen" ]]; then # Use these two for GNU Screen: diff --git a/key-bindings.zsh b/key-bindings.zsh index 2fae6d0..87e47ba 100644 --- a/key-bindings.zsh +++ b/key-bindings.zsh @@ -9,6 +9,11 @@ bindkey -s '\e.' "..\n" bindkey '^r' history-incremental-search-backward bindkey "^[[5~" up-line-or-history bindkey "^[[6~" down-line-or-history + +# make search up and down work, so partially type and hit up/down to find relevant stuff +bindkey '^[[A' up-line-or-search +bindkey '^[[B' down-line-or-search + bindkey "^[[H" beginning-of-line bindkey "^[[1~" beginning-of-line bindkey "^[[F" end-of-line diff --git a/misc.zsh b/misc.zsh index c368cff..fab4be9 100644 --- a/misc.zsh +++ b/misc.zsh @@ -3,4 +3,7 @@ autoload -U url-quote-magic zle -N self-insert url-quote-magic ## file rename magick -bindkey "^[m" copy-prev-shell-word \ No newline at end of file +bindkey "^[m" copy-prev-shell-word + +## jobs +setopt long_list_jobs \ No newline at end of file From fc796262ab43e1e16ca10cf614f66dcd1ec97cbb Mon Sep 17 00:00:00 2001 From: James Cox Date: Wed, 23 Sep 2009 01:20:08 +0100 Subject: [PATCH 11/11] add in refcard note --- README.textile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.textile b/README.textile index 851a5ab..1735e15 100644 --- a/README.textile +++ b/README.textile @@ -42,6 +42,9 @@ TODO: Update this.. ** Take a look at the "current themes":http://wiki.github.com/robbyrussell/oh-my-zsh/themes that come bundled with Oh My Zsh. * much much more.. +h2. Useful +the "refcard":http://www.bash2zsh.com/zsh_refcard/refcard.pdf is pretty tasty for tips. + h3. Uninstalling If you want to uninstall it, just run @uninstall_oh_my_zsh@ from the command line and it'll remove itself and revert you to bash (or your previous zsh config).