-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzhelp.zsh
More file actions
executable file
·40 lines (38 loc) · 787 Bytes
/
zhelp.zsh
File metadata and controls
executable file
·40 lines (38 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#
#Look up weather there is an alias for the argument given.
#
# Author:
# Lorenzo Bercelli <https://github.com/bercio>
#
local usage flag lookup
usage="$(
cat <<EOF
usage: $0 [-option ...] [--] command
options:
-e find only the alias that matches exactly the command given
EOF
)"
while getopts ':e' opt; do
case "$opt" in
(e) flag="true";;
([?])
print "$0: unknown option: $OPTARG" &&
print "$usage" &&
return 1
;;
esac
done
shift $(( $OPTIND - 1 ))
print $@
if (( $# < 2 )); then
print "$usage" &&
return 1
fi
if [[ -n $flag ]]; then
lookup=$(alias | grep -E "^.+='?$@'?$");
else
lookup=$(alias | grep -E "^.+='?$@.*'?$");
fi
[[ -n $lookup ]]&&
print "There are some aliases: $lookup"
&& return 0