These were suggested by sorin-ionescu in pull request #343.
Paul Gideon Dann authored on 19/09/2011 at 11:40:29... | ... |
@@ -1,15 +1,18 @@ |
1 | 1 |
function wake() { |
2 |
- local config_file=~/.wakeonlan/$1 |
|
3 |
- if [[ ! -f $config_file ]]; then |
|
2 |
+ local config_file="$HOME/.wakeonlan/$1" |
|
3 |
+ if [[ ! -f "$config_file" ]]; then |
|
4 | 4 |
echo "ERROR: There is no configuration file at \"$config_file\"." |
5 |
- return |
|
5 |
+ return 1 |
|
6 | 6 |
fi |
7 | 7 |
|
8 |
- which wakeonlan > /dev/null |
|
9 |
- if [[ ! $? == 0 ]]; then |
|
8 |
+ if (( ! $+commands[wakeonlan] )); then |
|
10 | 9 |
echo "ERROR: Can't find \"wakeonlan\". Are you sure it's installed?" |
11 |
- return |
|
10 |
+ return 1 |
|
12 | 11 |
fi |
13 | 12 |
|
14 | 13 |
wakeonlan -f $config_file |
15 | 14 |
} |
15 |
+ |
|
16 |
+if (( $+functions[compdef] )); then |
|
17 |
+ compdef "_arguments '1:device to wake:_files -W '\''$HOME/.wakeonlan'\'''" wake |
|
18 |
+fi |