Add paths in background, sync comments between shell wrappers

Closes #230.
pull/252/head
William Ting 11 years ago
parent 3709536698
commit b0957e50eb

@ -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 <<EOF
$comps
@ -11,13 +17,10 @@ EOF
}
complete -F _autojump j
# set paths if necessary for local installations
if [ -d ~/.autojump/ ]; then
export PATH=~/.autojump/bin:"${PATH}"
fi
# change pwd hook
autojump_add_to_database() {
autojump -a "$(pwd)" &>/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

@ -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 '-*'

@ -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

Loading…
Cancel
Save