A Bash “edit-in-place” idiom


I use a shell script called `stream.sh` to launch my music player and open a given internet radio station. I use it like this to tune to a local AM station:


$ stream.sh 1370

I usually edit small scripts like that with `nano(1)`. Rather than type the entire path to the script when I need to edit it (`nano ~/prog/sh/stream.sh`) I just say `nano $(which stream.sh)` i.e. “edit whichever file is in the `$PATH` with that name”.

My shell (`zsh(1)`) performs tab-completion on the single argument to `which(1)` – here, “stream.sh”. So I’ve got “nano $(which stre_.s_)” where “_”s are tabs.

It’s actually a brain-saver with more verbose names, I promise `:]`.

Blogged to…

“Step by Step” by Chronos on di.fm‘s chillout station as recommended by DJ JMULV

See also

Information and Links


Other Posts

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Be the first to leave a comment!