Live data from Hacker News

How to navigate directories faster with Bash (2015)

mhoffman.github.io

1–10 of 179 posts

Re: How to navigate directories faster with Bash (2015)

#2
I upvoted for this alone:

  Another neat short hand is !$ which is an alias for the last argument of the previous command. This can be handy if one creates a new directory and wants to change into it without typing the the directory again. So commands would be

  mkdir -p make/new/directory
  cd !$
You've no idea how many years I've been thinking "This is Linux fer gawd's sake. Surely there must be some easy way to make a new directory and 'cd' to it in a single command!" But was never able to find or guess the right incantation.

Re: How to navigate directories faster with Bash (2015)

#4
post #2

I upvoted for this alone: Another neat short hand is !$ which is an alias for the last argument of the previous command. This can be handy if one creates a new directory and wants to change into it without typing the the directory again. So commands would be mkdir -p make/new/directory cd !$ You've no idea how many years I've been thinking "This is Linux fer gawd's sake. Surely there must be some easy way to make a n…

I hava a mkcd alias to create a directory and changing into it.

Re: How to navigate directories faster with Bash (2015)

#6
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.

Re: How to navigate directories faster with Bash (2015)

#7
post #2

I upvoted for this alone: Another neat short hand is !$ which is an alias for the last argument of the previous command. This can be handy if one creates a new directory and wants to change into it without typing the the directory again. So commands would be mkdir -p make/new/directory cd !$ You've no idea how many years I've been thinking "This is Linux fer gawd's sake. Surely there must be some easy way to make a n…

Typing Esc then . does the trick too.

Re: How to navigate directories faster with Bash (2015)

#8
post #7
post #2

I upvoted for this alone: Another neat short hand is !$ which is an alias for the last argument of the previous command. This can be handy if one creates a new directory and wants to change into it without typing the the directory again. So commands would be mkdir -p make/new/directory cd !$ You've no idea how many years I've been thinking "This is Linux fer gawd's sake. Surely there must be some easy way to make a n…

Typing Esc then . does the trick too.

what, what?

Re: How to navigate directories faster with Bash (2015)

#9
post #2

I upvoted for this alone: Another neat short hand is !$ which is an alias for the last argument of the previous command. This can be handy if one creates a new directory and wants to change into it without typing the the directory again. So commands would be mkdir -p make/new/directory cd !$ You've no idea how many years I've been thinking "This is Linux fer gawd's sake. Surely there must be some easy way to make a n…

This is nifty: https://github.com/wting/autojump

Re: How to navigate directories faster with Bash (2015)

#10
post #6

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,…

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