Having used Linux for a while, it’s safe to say I’ve accumulated a bit of experience about the terminal, it is unavoidable since Linux desktop was different back then. Booting into live environment for testing Linux distribution wasn’t as straight forward as today, for me at least, doing a kernel parameter override for modesetting is a must. USB modems (which was common back then) is a pain to set up. Having X showing the natural screen resolution is a luxury to have in live environment. And once you think you’ve already installed Linux into your system, something broke, and you can’t log in or some kernel panic stuffs. You’re back in the live environment, setting up internet connection (archlinux bbs and Ubuntu forum is mandatory, even now I still prefer information from archlinux forum).

This will be a collection of all the small things that I think worth noting, or ones I should use more often, but perhaps not the obvious stuffs. Expect many updates on this post (when I’m feeling like it).

Directories

Create directory and quickly change to it

1
2
mkdir -pv test && cd $_
pwd

Parameter Expansion

This is perhaps a part of bash, though I’m sure it will work on zsh. This is from the bash manual page.

String expansion

${parameter:-word}

if parameter is unset or null, the expansion of word is subtituted.

1
2
3
4
5
6
a=1234
echo ${a:-345}
unset a
echo ${a:-345}
a=
echo ${a:-456}

${parameter:=word}

If parameter is unset or null, the expansion of word is assigned to parameter. The value of parameter is then substituted.

1
2
3
4
5
6
var=
: ${var:=DEFAULT}
echo $var
var=test
: ${var:=DEFAULT}
echo $var

Misc

brace expansion

Useful for generating sequences of numbers.

1
2
3
echo {0..10}
touch test-{0..9}.txt
ls *.txt