2013-12-31 15:48:42 +00:00
|
|
|
# set user installation path
|
2013-05-18 11:58:41 +00:00
|
|
|
if test -d ~/.autojump
|
2013-05-25 12:28:06 +00:00
|
|
|
set -x PATH ~/.autojump/bin $PATH
|
2013-05-18 11:58:41 +00:00
|
|
|
end
|
|
|
|
|
2013-12-31 15:48:42 +00:00
|
|
|
|
|
|
|
# enable tab completion
|
2013-12-31 16:59:01 +00:00
|
|
|
complete -x -c j -a '(autojump --complete (commandline -t))'
|
2013-12-31 15:48:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
# change pwd hook
|
|
|
|
function __aj_add --on-variable PWD
|
|
|
|
status --is-command-substitution; and return
|
2013-12-31 16:59:01 +00:00
|
|
|
autojump -a (pwd) >/dev/null &
|
2013-12-31 15:48:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# misc helper functions
|
2013-05-18 11:58:41 +00:00
|
|
|
function __aj_err
|
|
|
|
echo $argv 1>&2; false
|
|
|
|
end
|
|
|
|
|
|
|
|
function __aj_not_found
|
|
|
|
__aj_err "autojump: directory '"$argv"' not found"
|
|
|
|
__aj_err "Try `autojump --help` for more information."
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-12-31 15:48:42 +00:00
|
|
|
# default autojump command
|
2013-05-18 11:58:41 +00:00
|
|
|
function j
|
|
|
|
switch "$argv"
|
|
|
|
case '-*' '--*'
|
|
|
|
autojump $argv
|
|
|
|
case '*'
|
|
|
|
set -l new_path (autojump $argv)
|
|
|
|
if test -d "$new_path"
|
|
|
|
set_color red
|
|
|
|
echo $new_path
|
|
|
|
set_color normal
|
|
|
|
cd $new_path
|
|
|
|
else
|
|
|
|
__aj_not_found $argv
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-12-31 15:48:42 +00:00
|
|
|
|
|
|
|
# jump to child directory (subdirectory of current path)
|
2013-05-18 11:58:41 +00:00
|
|
|
function jc
|
|
|
|
switch "$argv"
|
|
|
|
case '-*'
|
|
|
|
j $argv
|
|
|
|
case '*'
|
|
|
|
j (pwd) $argv
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-12-31 15:48:42 +00:00
|
|
|
|
|
|
|
# open autojump results in file browser
|
2013-05-18 11:58:41 +00:00
|
|
|
function jo
|
|
|
|
if test -z (autojump $argv)
|
|
|
|
__aj_not_found $argv
|
|
|
|
else
|
|
|
|
switch (sh -c 'echo ${OSTYPE}')
|
|
|
|
case linux-gnu
|
|
|
|
xdg-open (autojump $argv)
|
|
|
|
case 'darwin*'
|
|
|
|
open (autojump $argv)
|
|
|
|
case cygwin
|
|
|
|
cygstart "" (cygpath -w -a (pwd))
|
|
|
|
case '*'
|
|
|
|
__aj_error "Unknown operating system."
|
|
|
|
end
|
|
|
|
echo end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-12-31 15:48:42 +00:00
|
|
|
|
|
|
|
# open autojump results (child directory) in file browser
|
2013-05-18 11:58:41 +00:00
|
|
|
function jco
|
|
|
|
switch "$argv"
|
|
|
|
case '-*'
|
|
|
|
j $argv
|
|
|
|
case '*'
|
|
|
|
jo (pwd) $argv
|
|
|
|
end
|
|
|
|
end
|