Topic: @script
allow me to start you off with a little history.
i used to be (and still occasionally am) active online in a MOO (which, for the uninitiated, is an object oriented MUD, so in full an Multi User Dungeon Object Oriented - a MOO! - and for all good reasons it is also the sound a cow makes)
these things were originally intended to be for online multiplayer text-games or some shit, but in my case it was filled with my friends and future friends to be, and was essentially a big private chatroom, only with medieval aliases (it is called 'Medieval' and originally themed that way).
in this MOO-environment, you could script all your own stuff (if you had the perms and quota). so, i went wild with making scripts for every conceivable way i could hit, kick, bash, kill, impale or gruesomely mutilate someone (this was all in text, so it was more funny than offensive, and we were among friends)
in this MOO, scripts were called 'verbs', and you could make a new script with the command '@verb crunchbang'. followed by '@edit crunchbang', it would open up in an editor and you'd be making a verb that could be the command 'crunchbang rhowaldt', and the verb would output (for all users in the room to see) 'rhowaldt crunchbangs himself!'
doing a lot of editing, the process of building a verb then editing it became quite tedious: 2 commands for 1 thing!
so, someone made @@verb, which would do @verb followed by @edit.
with bash scripting, each time i make a new script i do
'touch script'
'chmod +x script'
'gedit script &'
so, i figured, let me build a Linux @@verb script, like i had it in the MOO! and so i did. here it is for y'all to see and marvel at and by all means use. i can imagine someone else finding this handy. it is called @script.
#!/bin/bash
# @script will perform a repetitive task for you.
# it will make a new script, make it executable for you,
# then open it in gedit.
LOCATION=`pwd`
PATH=""
TOUCH="/usr/bin/touch"
CHMOD="/bin/chmod"
EDITOR="/usr/bin/gedit"
if [ $# -lt 1 ]; then
echo "Use '@script <scriptname> [<location>]'."
exit
fi
if [ $2 ]; then
if [ ! -d "$2" ]; then
echo "Location does not exist."
exit
else
LOCATION="$2"
fi
fi
PATH="$LOCATION/$1"
$TOUCH $PATH
$CHMOD +x $PATH
$EDITOR $PATHfor old time's sake, i've also added these two to my .bashrc:
# from the MOO-days
alias @verb="@script"
alias @edit="gedit"by the way, if you are wondering why i put the full path to 'pwd', 'touch' and 'gedit' there, it is because for some reason i could not get it working just by name. if someone could help me out on that one, i'd be grateful.
Last edited by rhowaldt (2011-06-19 00:11:42)