mirror of
https://github.com/iridakos/goto.git
synced 2025-05-18 00:10:13 -07:00
parent
81d9fd79ae
commit
0ac31f2bf3
17
goto.bash
17
goto.bash
@ -138,7 +138,7 @@ function _goto_unregister_alias
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Delete entry from file.
|
# Delete entry from file.
|
||||||
echo "$(sed "/^\<$1\>/d" ~/.goto)" > ~/.goto
|
echo "$(sed "/^$1 /d" ~/.goto)" > ~/.goto
|
||||||
echo "Alias '$1' unregistered successfully."
|
echo "Alias '$1' unregistered successfully."
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ function _goto_unregister_alias
|
|||||||
function _goto_cleanup()
|
function _goto_cleanup()
|
||||||
{
|
{
|
||||||
while IFS='' read -r entry || [[ -n "$entry" ]]; do
|
while IFS='' read -r entry || [[ -n "$entry" ]]; do
|
||||||
al=$(echo $entry | sed 's/[\t ].*//')
|
al=$(echo $entry | sed 's/ .*//')
|
||||||
dir=$(echo $entry | sed 's/[^ ]* //')
|
dir=$(echo $entry | sed 's/[^ ]* //')
|
||||||
|
|
||||||
if [ -n "$al" ] && [ ! -d "$dir" ]; then
|
if [ -n "$al" ] && [ ! -d "$dir" ]; then
|
||||||
@ -210,19 +210,18 @@ function _complete_goto_aliases()
|
|||||||
compopt +o filenames 2>/dev/null
|
compopt +o filenames 2>/dev/null
|
||||||
|
|
||||||
# if you find only one alias don't append the directory
|
# if you find only one alias don't append the directory
|
||||||
COMPREPLY=$(printf ${matches[0]} | sed 's/[\t ].*//')
|
COMPREPLY=$(printf ${matches[0]} | sed 's/ .*//')
|
||||||
else
|
else
|
||||||
for i in "${!matches[@]}"; do
|
for i in "${!matches[@]}"; do
|
||||||
# remove the filenames attribute from the completion method
|
# remove the filenames attribute from the completion method
|
||||||
compopt +o filenames 2>/dev/null
|
compopt +o filenames 2>/dev/null
|
||||||
|
|
||||||
if ! [[ $(uname -s) =~ Darwin* ]]; then
|
if ! [[ $(uname -s) =~ Darwin* ]]; then
|
||||||
matches[$i]="$(echo ${matches[$i]} | sed 's/[\t]/ /g')"
|
matches[$i]=$(printf '%*s' "-$COLUMNS" "${matches[$i]}")
|
||||||
matches[$i]=$(printf '%*s' "-$COLUMNS" "${matches[$i]}")
|
|
||||||
|
|
||||||
COMPREPLY+=($(compgen -W "${matches[$i]}"))
|
COMPREPLY+=($(compgen -W "${matches[$i]}"))
|
||||||
else
|
else
|
||||||
al=$(echo ${matches[$i]} | sed 's/[\t ].*//')
|
al=$(echo ${matches[$i]} | sed 's/ .*//')
|
||||||
|
|
||||||
COMPREPLY+=($(compgen -W "$al"))
|
COMPREPLY+=($(compgen -W "$al"))
|
||||||
fi
|
fi
|
||||||
@ -264,4 +263,8 @@ function _complete_goto()
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Register the goto compspec
|
# Register the goto compspec
|
||||||
complete -o filenames -F _complete_goto goto
|
if ! [[ $(uname -s) =~ Darwin* ]]; then
|
||||||
|
complete -o filenames -F _complete_goto goto
|
||||||
|
else
|
||||||
|
complete -F _complete_goto goto
|
||||||
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user