From b0957e50eb4c52a0865c9ba859dac40b8ba52e65 Mon Sep 17 00:00:00 2001 From: William Ting Date: Tue, 31 Dec 2013 09:48:42 -0600 Subject: [PATCH] Add paths in background, sync comments between shell wrappers Closes #230. --- bin/autojump.bash | 21 ++++++++++++++------- bin/autojump.fish | 39 +++++++++++++++++++++------------------ bin/autojump.zsh | 15 ++++++++++++--- 3 files changed, 47 insertions(+), 28 deletions(-) diff --git a/bin/autojump.bash b/bin/autojump.bash index 0aa5b4f..3451f49 100644 --- a/bin/autojump.bash +++ b/bin/autojump.bash @@ -1,9 +1,15 @@ +# set user installation paths +if [ -d ~/.autojump/ ]; then + export PATH=~/.autojump/bin:"${PATH}" +fi + + +# enable tab completion _autojump() { local cur cur=${COMP_WORDS[*]:1} comps=$(autojump --complete $cur) - while read i - do + while read i; do COMPREPLY=("${COMPREPLY[@]}" "${i}") done </dev/null + (autojump -a "$(pwd)" &) &>/dev/null } case $PROMPT_COMMAND in @@ -28,6 +31,7 @@ case $PROMPT_COMMAND in ;; esac + # default autojump command j() { if [[ ${@} =~ ^-{1,2}.* ]]; then @@ -46,6 +50,7 @@ j() { fi } + # jump to child directory (subdirectory of current path) jc() { if [[ ${@} == -* ]]; then @@ -55,6 +60,7 @@ jc() { fi } + # open autojump results in file browser jo() { if [[ ${@} == -* ]]; then @@ -85,6 +91,7 @@ jo() { fi } + # open autojump results (child directory) in file browser jco() { if [[ ${@} == -* ]]; then diff --git a/bin/autojump.fish b/bin/autojump.fish index b1297d0..da3b18d 100644 --- a/bin/autojump.fish +++ b/bin/autojump.fish @@ -1,23 +1,23 @@ -complete -x -c j -a '(autojump --bash --complete (commandline -t))' - -switch "$XDG_DATA_HOME" - case "*$USER*" - set -x AUTOJUMP_DATA_DIR "$XDG_DATA_HOME/autojump" - case '*' - set -x AUTOJUMP_DATA_DIR ~/.local/share/autojump -end - -if not test -d $AUTOJUMP_DATA_DIR - mkdir $AUTOJUMP_DATA_DIR -end - -# local installation +# set user installation path if test -d ~/.autojump set -x PATH ~/.autojump/bin $PATH end set -x AUTOJUMP_HOME $HOME + +# enable tab completion +complete -x -c j -a '(autojump --bash --complete (commandline -t))' + + +# change pwd hook +function __aj_add --on-variable PWD + status --is-command-substitution; and return + autojump -a (pwd) &>/dev/null & +end + + +# misc helper functions function __aj_err echo $argv 1>&2; false end @@ -27,11 +27,8 @@ function __aj_not_found __aj_err "Try `autojump --help` for more information." end -function __aj_add --on-variable PWD - status --is-command-substitution; and return - autojump -a (pwd) >/dev/null ^$AUTOJUMP_DATA_DIR/autojump_errors -end +# default autojump command function j switch "$argv" case '-*' '--*' @@ -49,6 +46,8 @@ function j end end + +# jump to child directory (subdirectory of current path) function jc switch "$argv" case '-*' @@ -58,6 +57,8 @@ function jc end end + +# open autojump results in file browser function jo if test -z (autojump $argv) __aj_not_found $argv @@ -76,6 +77,8 @@ function jo end end + +# open autojump results (child directory) in file browser function jco switch "$argv" case '-*' diff --git a/bin/autojump.zsh b/bin/autojump.zsh index c12b24e..51a03a4 100644 --- a/bin/autojump.zsh +++ b/bin/autojump.zsh @@ -1,15 +1,20 @@ -# set paths for user installations +# set user installation paths if [[ -d ${HOME}/.autojump ]]; then path=(${HOME}/.autojump/bin ${path}) fpath=(${HOME}/.autojump/functions/ ${fpath}) fi -# set fpath if necessary for homebrew installation + +# set homebrew installation paths command -v brew &>/dev/null \ && [[ -d "`brew --prefix`/share/zsh/site-functions" ]] \ && fpath=(`brew --prefix`/share/zsh/site-functions ${fpath}) -# add change pwd hook + +# tab completion handled by _j file + + +# change pwd hook autojump_chpwd() { (autojump -a "$(pwd)" &) &>/dev/null } @@ -17,6 +22,7 @@ autojump_chpwd() { typeset -gaU chpwd_functions chpwd_functions+=autojump_chpwd + # default autojump command j() { if [[ ${@} == -* ]]; then @@ -35,6 +41,7 @@ j() { fi } + # jump to child directory (subdirectory of current path) jc() { if [[ ${@} == -* ]]; then @@ -44,6 +51,7 @@ jc() { fi } + # open autojump results in file browser jo() { if [[ ${@} == -* ]]; then @@ -74,6 +82,7 @@ jo() { fi } + # open autojump results (child directory) in file browser jco() { if [[ ${@} == -* ]]; then