mirror of
https://github.com/jimeh/tmuxifier.git
synced 2026-02-19 09:56:39 +00:00
35 lines
751 B
Bash
Executable File
35 lines
751 B
Bash
Executable File
#! /usr/bin/env bash
|
|
set -e
|
|
[ -n "$TMUXIFIER_DEBUG" ] && set -x
|
|
|
|
# Provide tmuxifier completions
|
|
if [ "$1" == "--complete" ]; then
|
|
tmuxifier-commands
|
|
exit
|
|
fi
|
|
|
|
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" || 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
|