1
0
mirror of https://github.com/wting/autojump synced 2024-10-27 20:34:07 +00:00

use more portable form of defining bash / zsh functions

This commit is contained in:
William Ting 2013-12-30 16:27:34 -06:00
parent 0caa91030f
commit bec6314eab
2 changed files with 11 additions and 13 deletions

View File

@ -1,5 +1,4 @@
_autojump() _autojump() {
{
local cur local cur
cur=${COMP_WORDS[*]:1} cur=${COMP_WORDS[*]:1}
comps=$(autojump --bash --complete $cur) comps=$(autojump --bash --complete $cur)
@ -12,8 +11,7 @@ EOF
} }
complete -F _autojump j complete -F _autojump j
_autojump_files() _autojump_files() {
{
if [[ ${COMP_WORDS[COMP_CWORD]} == *__* ]]; then if [[ ${COMP_WORDS[COMP_CWORD]} == *__* ]]; then
local cur local cur
#cur=${COMP_WORDS[*]:1} #cur=${COMP_WORDS[*]:1}
@ -69,7 +67,7 @@ case $PROMPT_COMMAND in
;; ;;
esac esac
function j { j() {
if [[ ${@} =~ ^-{1,2}.* ]]; then if [[ ${@} =~ ^-{1,2}.* ]]; then
autojump ${@} autojump ${@}
return return
@ -86,7 +84,7 @@ function j {
fi fi
} }
function jc { jc() {
if [[ ${@} == -* ]]; then if [[ ${@} == -* ]]; then
j ${@} j ${@}
else else
@ -94,7 +92,7 @@ function jc {
fi fi
} }
function jo { jo() {
if [ -z $(autojump $@) ]; then if [ -z $(autojump $@) ]; then
echo "autojump: directory '${@}' not found" echo "autojump: directory '${@}' not found"
echo "Try \`autojump --help\` for more information." echo "Try \`autojump --help\` for more information."
@ -117,7 +115,7 @@ function jo {
fi fi
} }
function jco { jco() {
if [[ ${@} == -* ]]; then if [[ ${@} == -* ]]; then
j ${@} j ${@}
else else

View File

@ -20,7 +20,7 @@ command -v brew &>/dev/null \
&& [[ -d "`brew --prefix`/share/zsh/site-functions" ]] \ && [[ -d "`brew --prefix`/share/zsh/site-functions" ]] \
&& fpath=(`brew --prefix`/share/zsh/site-functions ${fpath}) && fpath=(`brew --prefix`/share/zsh/site-functions ${fpath})
function autojump_chpwd() { autojump_chpwd() {
if [[ "${AUTOJUMP_KEEP_SYMLINKS}" == "1" ]]; then if [[ "${AUTOJUMP_KEEP_SYMLINKS}" == "1" ]]; then
_PWD_ARGS="" _PWD_ARGS=""
else else
@ -32,7 +32,7 @@ function autojump_chpwd() {
typeset -gaU chpwd_functions typeset -gaU chpwd_functions
chpwd_functions+=autojump_chpwd chpwd_functions+=autojump_chpwd
function j { j() {
# Cannot use =~ due to MacPorts zsh v4.2, see issue #125. # Cannot use =~ due to MacPorts zsh v4.2, see issue #125.
if [[ ${@} == -* ]]; then if [[ ${@} == -* ]]; then
autojump ${@} autojump ${@}
@ -50,7 +50,7 @@ function j {
fi fi
} }
function jc { jc() {
if [[ ${@} == -* ]]; then if [[ ${@} == -* ]]; then
j ${@} j ${@}
else else
@ -58,7 +58,7 @@ function jc {
fi fi
} }
function jo { jo() {
if [[ ${@} == -* ]]; then if [[ ${@} == -* ]]; then
j ${@} j ${@}
return return
@ -86,7 +86,7 @@ function jo {
fi fi
} }
function jco { jco() {
if [[ ${@} == -* ]]; then if [[ ${@} == -* ]]; then
j ${@} j ${@}
else else