Move nethack function to its own script

This commit is contained in:
Eryn Wells 2014-02-10 10:17:39 -07:00
parent b9c42cdd6f
commit ff92c78b40
2 changed files with 33 additions and 10 deletions

10
rc
View file

@ -73,16 +73,6 @@ function configure_ls
}
function nethack
{
if binary_exists nethack; then
command nethack
else
telnet nethack.alt.org
fi
}
# NetHack options
# use color in the terminal
binary_exists nethack && export NETHACKOPTIONS="color"

33
zsh/func/nethack Normal file
View file

@ -0,0 +1,33 @@
#!/usr/bin/env zsh
# vim: set ft=zsh:
# Eryn Wells <eryn@erynwells.me>
function nethack
{
local remote
while getopts 'lr' opt; do
case $opt in
l) remote=0;;
r) remote=1;;
*)
echo "Invalid argument: $OPTARG" 1>&2
return -1
;;
esac
done
if (( $remote )) && binary_exists nethack; then
telnet nethack.alt.org
return $?
else
if binary_exists nethack; then
command nethack
return $?
else
telnet nethack.alt.org
return $?
fi
fi
}
nethack "$@"