Move nethack function to its own script
This commit is contained in:
		
							parent
							
								
									b9c42cdd6f
								
							
						
					
					
						commit
						ff92c78b40
					
				
					 2 changed files with 33 additions and 10 deletions
				
			
		
							
								
								
									
										10
									
								
								rc
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								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
 | 
					# NetHack options
 | 
				
			||||||
# use color in the terminal
 | 
					# use color in the terminal
 | 
				
			||||||
binary_exists nethack && export NETHACKOPTIONS="color"
 | 
					binary_exists nethack && export NETHACKOPTIONS="color"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										33
									
								
								zsh/func/nethack
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								zsh/func/nethack
									
										
									
									
									
										Normal 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 "$@"
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue