Correctly resolve aliases in help command.

This resolves issue #1.
This commit is contained in:
2012-04-30 02:08:40 +01:00
parent 7d2c9aa49f
commit 3063c6f1f3
3 changed files with 27 additions and 9 deletions

View File

@@ -31,6 +31,5 @@ case "$1" in
echo "list-windows"
;;
* )
echo "unknown alias \"$1\""
exit 1
esac

View File

@@ -10,13 +10,11 @@ fi
command="$1"
# Lookup command, attempt to resolve as alias if fails
! command_path="$(command -v "tmuxifier-$command")"
if [ -z "$command_path" ]; then
resolved="$(tmuxifier-alias "$command")"
if [ ! -z "$resolved" ]; then
# Ensure we have the correct command name in case an alias was given.
if [ -n "$command" ]; then
! resolved="$(tmuxifier-alias "$command")"
if [ -n "$resolved" ]; then
command="$resolved"
! command_path="$(command -v "tmuxifier-$command")"
fi
fi
@@ -111,14 +109,16 @@ Aliases: list-win, lsw
List all window layouts."
;;
* )
if [ ! -z "$command_path" ]; then
! command_path="$(tmuxifier-resolve-command-path "$command")"
if [ -n "$command_path" ]; then
echo "Sorry, the '$command' command isn't documented yet."
echo
echo "You can view the command's source here:"
echo "$command_path"
echo
else
echo "tmuxifier: no such command '$command'"
echo "tmuxifier: no such command '$command'" >&2
exit 1
fi
;;
esac

View File

@@ -0,0 +1,19 @@
#! /usr/bin/env bash
set -e
[ -n "$TMUXIFIER_DEBUG" ] && set -x
if [ -n "$1" ]; then
! command_path="$(command -v "tmuxifier-$1")"
if [ -z "$command_path" ]; then
resolved="$(tmuxifier-alias "$1")"
if [ -n "$resolved" ]; then
! command_path="$(command -v "tmuxifier-$resolved")"
fi
fi
fi
if [ -n "$command_path" ]; then
echo "$command_path"
else
exit 1
fi