mirror of
https://github.com/jimeh/tmuxifier.git
synced 2026-02-19 01:46:40 +00:00
Add support for command aliases
* `session` and `window` commands are now know as `load-session` and `load-window` respectively, with aliases for their former names. * Add short aliases for various commands. * `help` and `completions` commands have been expanded with support for aliases. * `help` command has been expanded upon with brief docs for a few more commands.
This commit is contained in:
@@ -2,14 +2,27 @@
|
||||
set -e
|
||||
[ -n "$TMUXIFIER_DEBUG" ] && set -x
|
||||
|
||||
has-completions() {
|
||||
grep -i "^# provide tmuxifier completions" "$1" >/dev/null
|
||||
}
|
||||
|
||||
command="$1"
|
||||
if [ -z "$command" ]; then
|
||||
echo "Usage: tmuxifier completions COMMAND [arg1 arg2...]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
command_path="$(command -v "tmuxifier-$command")"
|
||||
if grep -i "^# provide tmuxifier completions" "$command_path" >/dev/null; then
|
||||
command_path="$(command -v "tmuxifier-$command" || true)"
|
||||
|
||||
# Attempt to resolve aliases
|
||||
if [ -z "$command_path" ]; then
|
||||
resolved="$(tmuxifier-alias "$command")"
|
||||
if [ ! -z "$resolved" ]; then
|
||||
command_path="$(command -v "tmuxifier-$resolved" || true)"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z "$command_path" ] && has-completions "$command_path"; then
|
||||
shift
|
||||
exec "$command_path" --complete "$@"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user