diff options
Diffstat (limited to 'Functions')
-rw-r--r-- | Functions/Chpwd/zsh_directory_name_cdr | 5 | ||||
-rw-r--r-- | Functions/Misc/zed | 41 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 17 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_svn | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_tla | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/VCS_INFO_bydir_detect | 15 | ||||
-rw-r--r-- | Functions/VCS_Info/VCS_INFO_realpath | 7 | ||||
-rw-r--r-- | Functions/VCS_Info/vcs_info | 1 |
10 files changed, 55 insertions, 39 deletions
diff --git a/Functions/Chpwd/zsh_directory_name_cdr b/Functions/Chpwd/zsh_directory_name_cdr index c9be7db0c..cb72e4600 100644 --- a/Functions/Chpwd/zsh_directory_name_cdr +++ b/Functions/Chpwd/zsh_directory_name_cdr @@ -1,14 +1,13 @@ if [[ $1 = n ]]; then if [[ $2 = <-> ]]; then # Recent directory - typeset -ga reply autoload -Uz cdr cdr -r if [[ -n ${reply[$2]} ]]; then - reply=(${reply[$2]}) + typeset -ga reply=(${reply[$2]}) return 0 else - reply=() + typeset -ga reply=() return 1 fi fi diff --git a/Functions/Misc/zed b/Functions/Misc/zed index f571daf5e..9eb4b2d93 100644 --- a/Functions/Misc/zed +++ b/Functions/Misc/zed @@ -3,7 +3,7 @@ # # No other shell could do this. # Edit small files with the command line editor. -# Use ^X^W to save, ^C to abort. +# Use ^X^W to save (or ZZ in vicmd mode), ^C to abort. # Option -f: edit shell functions. (Also if called as fned.) setopt localoptions noksharrays @@ -60,6 +60,11 @@ __zed_pg_down() done } +if ! zle -la __zed_pg_up __zed_pg_down; then + zle -N __zed_pg_up + zle -N __zed_pg_down +fi + if (( bind )) || ! bindkey -M zed >&/dev/null; then # Make the zed keymap a copy of the current main. bindkey -N zed main @@ -67,6 +72,12 @@ if (( bind )) || ! bindkey -M zed >&/dev/null; then # zed we may want to set this temporally. bindkey -A main zed-normal-keymap + # Define a widget to use at startup, undo shouldn't clear initial buffer + __zed_init() { + UNDO_LIMIT_NO=$UNDO_CHANGE_NO + } + zle -N __zed_init + # Assign some default keys. # Depending on your stty's, you may be able to use ^J as accept-line, else: @@ -75,10 +86,16 @@ if (( bind )) || ! bindkey -M zed >&/dev/null; then bindkey -M zed '^x^w' accept-line bindkey -M zed '^M' self-insert-unmeta - zle -N __zed_pg_up - zle -N __zed_pg_down - [[ ${+terminfo} = 1 && -n "$terminfo[kpp]" ]] && bindkey -M zed "$terminfo[kpp]" __zed_pg_up - [[ ${+terminfo} = 1 && -n "$terminfo[knp]" ]] && bindkey -M zed "$terminfo[knp]" __zed_pg_down + [[ ${+terminfo} = 1 ]] && { + [[ -n "$terminfo[kpp]" ]] && bindkey -M zed "$terminfo[kpp]" __zed_pg_up + [[ -n "$terminfo[knp]" ]] && bindkey -M zed "$terminfo[knp]" __zed_pg_down + [[ -n "$terminfo[khome]" ]] && bindkey -M zed "$terminfo[khome]" beginning-of-line + [[ -n "$terminfo[kend]" ]] && bindkey -M zed "$terminfo[kend]" end-of-line + + # Fallback to well known code as terminfo might be wrong (often) sometimes + bindkey -M zed "^[[H" beginning-of-line + bindkey -M zed "^[[F" end-of-line + } # Make zed-set-file-name available. # Assume it's in fpath; there's no error at this point if it isn't @@ -89,6 +106,16 @@ if (( bind )) || ! bindkey -M zed-vicmd >&/dev/null; then bindkey -N zed-vicmd vicmd bindkey -M zed-vicmd "ZZ" accept-line + [[ ${+terminfo} = 1 ]] && { + [[ -n "$terminfo[kpp]" ]] && bindkey -M zed-vicmd "$terminfo[kpp]" __zed_pg_up + [[ -n "$terminfo[knp]" ]] && bindkey -M zed-vicmd "$terminfo[knp]" __zed_pg_down + [[ -n "$terminfo[khome]" ]] && bindkey -M zed-vicmd "$terminfo[khome]" vi-beginning-of-line + [[ -n "$terminfo[kend]" ]] && bindkey -M zed-vicmd "$terminfo[kend]" vi-end-of-line + + # Fallback to well known code as terminfo might be wrong (often) sometimes + bindkey -M zed-vicmd "^[[H" vi-beginning-of-line + bindkey -M zed-vicmd "^[[F" vi-end-of-line + } fi (( bind )) && return 0 @@ -105,11 +132,11 @@ if ((fun)) then var="${(q-)1} () { }" fi - vared -M zed -m zed-vicmd var && eval function "$var" + vared -M zed -m zed-vicmd -i __zed_init var && eval function "$var" else zed_file_name=$1 [[ -f $1 ]] && var="$(<$1)" - while vared -M zed -m zed-vicmd var + while vared -M zed -m zed-vicmd -i __zed_init var do { print -r -- "$var" >| $zed_file_name diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr index e8c8e81de..705db65a7 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr @@ -81,7 +81,7 @@ else bzrbase=${bzr_info[branch_root]} ;; esac - bzrbase="$(VCS_INFO_realpath ${bzrbase})" + bzrbase=${bzrbase:P} if [ -n "${bzr_info[checkout_of_branch]}" ] && \ zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "use-server" diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs index ed738b98f..e9d172052 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs @@ -9,7 +9,7 @@ cvsbase="." while [[ -d "${cvsbase}/../CVS" ]]; do cvsbase="${cvsbase}/.." done -cvsbase="$(VCS_INFO_realpath ${cvsbase})" +cvsbase=${cvsbase:P} cvsbranch=$(< ./CVS/Repository) rrn=${cvsbase:t} cvsbranch=${cvsbranch##${rrn}/} diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index f3dd95dcb..c3e62db3a 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -104,16 +104,15 @@ VCS_INFO_git_getbranch () { elif [[ -d "${gitdir}/.dotest-merge" ]] ; then gitbranch="$(< ${gitdir}/.dotest-merge/head-name)" + elif gitbranch="$(${(z)gitsymref} 2> /dev/null)" ; then + elif gitbranch="refs/tags/$(${vcs_comm[cmd]} describe --all --exact-match HEAD 2>/dev/null)" ; then + elif gitbranch="$(${vcs_comm[cmd]} describe --contains HEAD 2>/dev/null)" ; then + ## Commented out because we don't know of a case in which 'describe --contains' fails and 'name-rev --tags' succeeds. + #elif gitbranch="$(${vcs_comm[cmd]} name-rev --name-only --no-undefined --tags HEAD 2>/dev/null)" ; then + elif gitbranch="$(${vcs_comm[cmd]} name-rev --name-only --no-undefined --always HEAD 2>/dev/null)" ; then + elif gitbranch="${${"$(< $gitdir/HEAD)"}[1,7]}..." ; then else - gitbranch="$(${(z)gitsymref} 2> /dev/null)" - - if [[ $? -ne 0 ]] ; then - gitbranch="refs/tags/$(${vcs_comm[cmd]} describe --all --exact-match HEAD 2>/dev/null)" - - if [[ $? -ne 0 ]] ; then - gitbranch="${${"$(< $gitdir/HEAD)"}[1,7]}..." - fi - fi + # Can't happen fi return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn index e1334f661..a773a727d 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn @@ -46,7 +46,7 @@ else done fi -svnbase="$(VCS_INFO_realpath ${svnbase})" +svnbase=${svnbase:P} rrn=${svnbase:t} zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svnbranch || svnbranch="%b:%r" diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla b/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla index f015e0cce..4e9cee8b9 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla @@ -5,7 +5,7 @@ setopt localoptions extendedglob NO_shwordsplit local tlabase tlabranch -tlabase="$(VCS_INFO_realpath ${vcs_comm[basedir]})" +tlabase=${vcs_comm[basedir]:P} rrn=${tlabase:t} # tree-id gives us something like 'foo@example.com/demo--1.0--patch-4', so: tlabranch=${${"$( ${vcs_comm[cmd]} tree-id )"}/*\//} diff --git a/Functions/VCS_Info/VCS_INFO_bydir_detect b/Functions/VCS_Info/VCS_INFO_bydir_detect index 70b0fb6fa..b20c05c9c 100644 --- a/Functions/VCS_Info/VCS_INFO_bydir_detect +++ b/Functions/VCS_Info/VCS_INFO_bydir_detect @@ -4,11 +4,11 @@ setopt localoptions NO_shwordsplit local dirname=$1 -local basedir="." realbasedir file +local basedir="." file -realbasedir="$(VCS_INFO_realpath ${basedir})" -while [[ ${realbasedir} != '/' ]]; do - [[ -r ${realbasedir} ]] || return 1 +basedir=${basedir:P} +while [[ ${basedir} != '/' ]]; do + [[ -r ${basedir} ]] || return 1 if [[ -n ${vcs_comm[detect_need_file]} ]] ; then [[ -d ${basedir}/${dirname} ]] && { for file in ${(s: :)${vcs_comm[detect_need_file]}}; do @@ -19,10 +19,9 @@ while [[ ${realbasedir} != '/' ]]; do [[ -d ${basedir}/${dirname} ]] && break fi - basedir=${basedir}/.. - realbasedir="$(VCS_INFO_realpath ${basedir})" + basedir=${basedir:h} done -[[ ${realbasedir} == "/" ]] && return 1 -vcs_comm[basedir]=${realbasedir} +[[ ${basedir} == "/" ]] && return 1 +vcs_comm[basedir]=${basedir} return 0 diff --git a/Functions/VCS_Info/VCS_INFO_realpath b/Functions/VCS_Info/VCS_INFO_realpath deleted file mode 100644 index ce4a69402..000000000 --- a/Functions/VCS_Info/VCS_INFO_realpath +++ /dev/null @@ -1,7 +0,0 @@ -## vim:ft=zsh -## Written by Frank Terbeck <ft@bewatermyfriend.org> -## Distributed under the same BSD-ish license as zsh itself. - -setopt localoptions NO_shwordsplit chaselinks -# -q to avoid chpwd() invocations -( builtin cd -q $1 2>/dev/null && pwd; ) diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info index 4e9ac6c6a..d67ae6bf5 100644 --- a/Functions/VCS_Info/vcs_info +++ b/Functions/VCS_Info/vcs_info @@ -26,7 +26,6 @@ static_functions=( VCS_INFO_nvcsformats VCS_INFO_patch2subject VCS_INFO_quilt - VCS_INFO_realpath VCS_INFO_reposub VCS_INFO_set |