Support autocomplete for goto aliases

* refs #53
This commit is contained in:
iridakos
2019-05-30 17:35:50 +03:00
parent b31295da8b
commit 0d076f234a
3 changed files with 26 additions and 15 deletions
+5
View File
@@ -5,6 +5,11 @@ All notable changes to `goto` will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [1.2.4] - 2019-05-30
### Added
- support bash completion for aliases of `goto`
## [1.2.3] - 2018-03-14
### Added
+1 -1
View File
@@ -2,7 +2,7 @@
A shell utility allowing users to navigate to aliased directories supporting auto-completion :feet:
![Generic badge](https://img.shields.io/badge/version-1.2.3-green.svg)
![Generic badge](https://img.shields.io/badge/version-1.2.4-green.svg)
## How does it work?
+20 -14
View File
@@ -111,7 +111,7 @@ USAGE
# Displays version
_goto_version()
{
echo "goto version 1.2.3.1"
echo "goto version 1.2.4"
}
# Expands directory.
@@ -438,16 +438,22 @@ _complete_goto_zsh()
return $ret
}
# Register the goto completions.
if [ -n "${BASH_VERSION}" ]; then
if ! [[ $(uname -s) =~ Darwin* ]]; then
complete -o filenames -F _complete_goto_bash goto
else
complete -F _complete_goto_bash goto
fi
elif [ -n "${ZSH_VERSION}" ]; then
compdef _complete_goto_zsh goto
else
echo "Unsupported shell."
exit 1
fi
aliases=($(alias | sed -n "s/.*\s\(.*\)='goto'/\1/p"))
aliases+=('goto')
for i in "${aliases[@]}"
do
# Register the goto completions.
if [ -n "${BASH_VERSION}" ]; then
if ! [[ $(uname -s) =~ Darwin* ]]; then
complete -o filenames -F _complete_goto_bash $i
else
complete -F _complete_goto_bash $i
fi
elif [ -n "${ZSH_VERSION}" ]; then
compdef _complete_goto_zsh $i
else
echo "Unsupported shell."
exit 1
fi
done