Hacker News new | past | comments | ask | show | jobs | submit login

Good selection of tips, like Normille I didn't know $! even though I have read Bash's man page through more than once.

Note that many of these are not just for Bash. pushd/popd is near universal among shells and CDPATH is standard among SYSV shells.

The idea of a shortcut for cd .. and its repetitions is good, but I'd prefer alias p='cd ..', pp='cd ../..' and so on, since I balk at the idea of having to distinguish, e.g., ..... and ...., but I find pppp and ppp are easier to discriminate by eyeball.

The shells I use most often are bash and the Emacs eshell, and over the years I appreciate eshell more and more. It has a few footguns, but the availability of the various selection-narrowing libraries, dired and tramp are huge pluses. zsh can pretty much do anything bash can do and more, and it's default on Macos and Arch Linux.




I'm an old-timer so was introduced to Unix before bash was ubiquitous. Actually it was csh/tcsh which later introduced me to "interactive" command history/editing. With interactive command history/editing, the old tricks to avoid excessive typing became less essential.

But I still use some of the old techniques as they continue to save time/typing - particular "$!". And even though I've reduced my reliance on aliases, I'm so used to jumping between directories that "pd" (pushd) and "nd" (pushd +1) are some of the few I continue to find myself installing.

The other shell techniques (strictly speaking editing features) that I was surprised to find are generally less used these days are the shortcuts like CTRL-w to delete the word to the left of the cursor or CTRL-a, CTRL-e to navigate to the start and end of the current line.


Many of these Emacs/readline shortcuts work in 99% of Mac apps too, which is nice.

https://jblevins.org/log/kbd


> I'm an old-timer so was introduced to Unix before bash was ubiquitous.

Me too, my first contact with UNIX was with SunOS 4 in 1988, which had csh as its default shell. I don't think I switched to bash until I started administering a Linux box in 1999, although I did script in POSIX shells before then. Before I had a system I was in control of, my attitude to bash was that it was unportable, because of the major differences between its v1 and v2 syntax.


Is there a way to tell CTRL-w to break words at / as well as space? I often use it to remove a parameter from a command I've copy-pasted or got from the history, but for the cd use case it removes too much.

Edit: ESC followed by backspace seems to work.


Alt-Backspace


If I were to alias cd ../../ et al I'd probably go for .. 2.. 3.. 4.. or something




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: