Przeglądaj źródła

use more portable form of defining bash / zsh functions

pull/252/head
William Ting 10 lat temu
rodzic
commit
bec6314eab
2 zmienionych plików z 11 dodań i 13 usunięć
  1. +6
    -8
      bin/autojump.bash
  2. +5
    -5
      bin/autojump.zsh

+ 6
- 8
bin/autojump.bash Wyświetl plik

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

+ 5
- 5
bin/autojump.zsh Wyświetl plik

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

Ładowanie…
Anuluj
Zapisz