A few scripts and aliases

I don’t use many aliases, although I know they are quite popular with some people. In general I have only two or three, which I use mostly because they’re coupled with some scripts that open or trigger a program in a particular way.

For example, I’m on an elinks kick these days. It’s fast, it’s fun and it works marvellously alongside screen and dvtm.

But I don’t like browsers that don’t clean up after themselves. I don’t like all-or-nothing cookie management, or goto lists or search histories. And so, for an alias, I use this:

alias elinks='$HOME/.scripts/elinks.sh'

That triggers an executable script in a hidden folder, and this it what’s in it:

#!/bin/bash
/usr/bin/elinks $1
rm $HOME/.elinks/gotohist $HOME/.elinks/searchhist 2>/dev/null
cp $HOME/.elinks/cookies.edit $HOME/.elinks/cookies

The first line tags it as a bash script. The next line triggers elinks and passes any address to it that I might have wanted as a start page.

When it’s done, the search history and the goto history are removed, with whatever feedback shuffled off to /dev/null (because those commands show an error message if the file doesn’t exist and can’t be deleted).

After that, a pristine cookie file is copied into place. The idea there is that there are some cookies that I care to keep — forum sign-ins or blog sign-ins — and those are in the cookies.edit file.

That way, when I’m done, the cookies I accrued through the course of my surfing are eradicated with a clean list, ready when I start elinks again. The only downside is that with two browsers open, if one of them exits, the cookies for both are reset. Just so you know. …

Here’s another example. I set the volume manually on my machine, usually at start time, with the amixer commands. But I have two aliases — usually called ‘volmute’ and ‘volreset’ — that trigger two more scripts. Here’s ‘mute.sh’.

#!/bin/bash
amixer sset PCM mute
amixer sset Master mute

And of course, ‘volumes.sh’.

#!/bin/bash
amixer sset PCM 50% unmute
amixer sset Master 90% unmute

With those two I can manage the general volume on moc or another audio source (like MPlayer) without hunting down the application in use. I type one word and the system falls mute (good for when the phone rings), and type another to reset it to a comfortable level.

I have a few others, but they’re not stellar, or they follow the examples of one I already explained, like a script that cleans up after emelfm2 and restores some settings. I’ll never be accused of being a master scripter, but little things like this are occasionally useful. :mrgreen:

About these ads

3 Responses to “A few scripts and aliases”


  1. 1 IceBrain 2009/03/21 at 10:29 PM

    I use a “mute” alias too, but it toggles the mute setting, so a second call restores the volume to the same level it was.

    I use a “mkcd” too, which calls mkdir $1 && cd $1, so I can make a directory and change to it directly.

    But my most elaborate alias (which is not exactly an alias, it’s a ZSH function) is “tube”, which runs a python script that searches for the given keywords in youtube and returns the video URL, which is then passed to mplayer running in a hidden screen session :P

  2. 2 Tom Adams 2009/03/22 at 6:11 AM

    I use mkdir/cd too. Very handy.

    I also have an alias to run an HTTP server which serves . as the document root.

    alias srv=”ruby -rwebrick -e ‘s=WEBrick::HTTPServer.new(:Port=>8080,\
    :DocumentRoot=>Dir::pwd);trap(\”INT\”){s.shutdown};s.start’”

    I’m very happy about WEBrick being included in Ruby. Means it works everywhere. Great for ad-hoc file sharing between machines and/or people on the same network (handy for streaming, letting housemates download files).

  3. 3 karthik 2009/03/22 at 4:10 PM

    I don’t know if you use elinks to open multiple URLs in tabs. (I do.) In any case, it’s a simple fix to generalize the elinks script a bit:

    #!/bin/bash
    /usr/bin/elinks $*


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Welcome!



Visit the Wiki!

Some recent desktops


May 6, 2011
Musca 0.9.24 on Crux Linux
150Mhz Pentium 96Mb 8Gb CF
 


May 14, 2011
IceWM 1.2.37 and Arch Linux
L2300 core duo 3Gb 320Gb

Some recent games


Apr. 21, 2011
Oolite on Xubuntu 11.04
L2300 core duo 3Gb 320Gb

Enter your email address to subscribe to this blog and receive notifications of new posts.

Join 405 other followers

License

This work is licensed under the GNU Free Documentation License. Please see the About page for details.

Blog Stats

  • 3,963,317 hits

Archives


Follow

Get every new post delivered to your Inbox.

Join 405 other followers

%d bloggers like this: