Live data from Hacker News

How to navigate directories faster with Bash (2015)

mhoffman.github.io

21–30 of 179 posts

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

#21
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…

In zsh, you use -> % take which makes the dir and cd's into it.

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

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

How does that work?

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

#25
post #15
post #5

I use `z` as a less manual way to search common directories instead of changing $CDPATH. It's based on 'frecency'. https://github.com/rupa/z

I use `autojump` (aliased as `j`), which sounds quite similar as it also records your most frequently visited directories. It's as simple as entering `j down` to enter /some/path/to/MyDownloadFolder. For exploring massive file trees, a terminal file manager that allows you to preview the contents of subdirectories without entering them is huge time saver. I use `lf`. https://github.com/wting/autojump https://github.c…

Autojump is great. Another similar one with less functionality but a stripped down script is "bashmarks":

https://github.com/huyng/bashmarks

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

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

Alt + . does the same thing as well, with the added advantage that you can keep pressing alt and then hit . several times to go through all the "last arguments" in your history one by one.

Further, holding Alt followed by numeric argument followed by dot, gives you an argument at a specific position. For example, Alt + 1, Alt + . copies the first argument.

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

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

You just blew my mind.

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

#29
For me once I moved to zsh and added `oh my zsh` it really became so much easier.

I like the autocomplete, the fact that when cd-ing a known path you can just type the first leter of each directory with slashes, showing the git branch in working dir.

Its the little things.

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

#30
post #5

I use `z` as a less manual way to search common directories instead of changing $CDPATH. It's based on 'frecency'. https://github.com/rupa/z

I use (and develop) `goat`. It's like a shortcut manager for aliases for directories you go to often. And a way to make "cd ...." work for any number of dots.

https://github.com/0mp/goat

Post reply on HN