From ff92c78b402a9e61f83a60749d8d23b8ed7122ae Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Mon, 10 Feb 2014 10:17:39 -0700 Subject: [PATCH] Move nethack function to its own script --- rc | 10 ---------- zsh/func/nethack | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 zsh/func/nethack diff --git a/rc b/rc index ae74b7c..1fd058b 100644 --- a/rc +++ b/rc @@ -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" diff --git a/zsh/func/nethack b/zsh/func/nethack new file mode 100644 index 0000000..9d46f76 --- /dev/null +++ b/zsh/func/nethack @@ -0,0 +1,33 @@ +#!/usr/bin/env zsh +# vim: set ft=zsh: +# Eryn Wells + +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 "$@"