▲ 70 ▼ Navigating around in your shell (blog.meain.io) submitted 2 years ago by learnbyexample@programming.dev to c/linux@lemmy.ml 21 comments fedilink hide all child comments
[–] executivechimp@discuss.tchncs.de 14 points 2 years ago (6 children) Good article. Rather than aliasing `cd ../.." etc. I've got this function in my setup: up () { local x='' for i in $(seq ${1:-1}) do x="$x../" done cd $x } This lets me do up 4 to go up 4 directories. permalink fedilink source hideshow 12 child comments replies: [–] olafurp@lemmy.world 9 points 2 years ago (1 child) You could also do a "up" for one up "upp" for 2 and "upppp" for 4 because of fun permalink fedilink source parent hideshow 2 child comments replies: [–] executivechimp@discuss.tchncs.de 4 points 2 years ago True. That is something that could be done. permalink fedilink source parent [–] ENipo@lemmy.world 4 points 2 years ago (2 children) Oh I really like this. I never had an alias for this since I need to do multiple backwards cds very rarely, but I might just copy this permalink fedilink source parent hideshow 4 child comments replies: [–] taladar@sh.itjust.works 3 points 2 years ago I have the zsh option autopushd set which calls pushd in interactive shells for every cd, that way 90% of the time when I want to go back up to another path I can just use popd permalink fedilink source parent [–] executivechimp@discuss.tchncs.de 1 point 2 years ago Go for it. I've been using it for years without a problem. permalink fedilink source parent [–] Astaroth@lemm.ee 2 points 2 years ago I use Fish and have keybinds for previous and next directory, 99% of the time when going up in a directory it's to (one of) the previous directory/ies I was in permalink fedilink source parent [–] Specialpatrol@feddit.uk 2 points 2 years ago Holy shit permalink fedilink source parent [–] beeng@discuss.tchncs.de 2 points 2 years ago (1 child) Look into zoxide. z direc Will take you to the most used directory starting with "direc" eg "/home/me/random/directory" permalink fedilink source parent hideshow 2 child comments replies: [–] executivechimp@discuss.tchncs.de 2 points 2 years ago (1 child) I've tried things like that before but never got on with them. I found when I had many projects with similar directory structures it was easy to end up in the wrong place and took more thought to get to the right place than just cding permalink fedilink source parent hideshow 2 child comments replies: [–] beeng@discuss.tchncs.de 1 point 2 years ago* The dir's are the same names or similar? A few extra key strokes to get the fullname should be easier than cd'ing back and forth. There's also z foo "space" "tab" as per docs to get interactive list for matches. But, just a suggestion! permalink fedilink source parent [–] PlexSheep@feddit.de 1 point 2 years ago What I use to automatically extend stuff like ls .... to ls ../../../.. function expand-dots() { local MATCH if [[ $LBUFFER =~ '(^| )\.\.\.+' ]]; then LBUFFER=$LBUFFER:fs%\.\.\.%../..% fi } function expand-dots-then-expand-or-complete() { zle expand-dots zle expand-or-complete } function expand-dots-then-accept-line() { zle expand-dots zle accept-line } zle -N expand-dots zle -N expand-dots-then-expand-or-complete zle -N expand-dots-then-accept-line bindkey '^I' expand-dots-then-expand-or-complete bindkey '^M' expand-dots-then-accept-line (for zsh) permalink fedilink source parent
[–] olafurp@lemmy.world 9 points 2 years ago (1 child) You could also do a "up" for one up "upp" for 2 and "upppp" for 4 because of fun permalink fedilink source parent hideshow 2 child comments replies: [–] executivechimp@discuss.tchncs.de 4 points 2 years ago True. That is something that could be done. permalink fedilink source parent
[–] executivechimp@discuss.tchncs.de 4 points 2 years ago True. That is something that could be done. permalink fedilink source parent
[–] ENipo@lemmy.world 4 points 2 years ago (2 children) Oh I really like this. I never had an alias for this since I need to do multiple backwards cds very rarely, but I might just copy this permalink fedilink source parent hideshow 4 child comments replies: [–] taladar@sh.itjust.works 3 points 2 years ago I have the zsh option autopushd set which calls pushd in interactive shells for every cd, that way 90% of the time when I want to go back up to another path I can just use popd permalink fedilink source parent [–] executivechimp@discuss.tchncs.de 1 point 2 years ago Go for it. I've been using it for years without a problem. permalink fedilink source parent
[–] taladar@sh.itjust.works 3 points 2 years ago I have the zsh option autopushd set which calls pushd in interactive shells for every cd, that way 90% of the time when I want to go back up to another path I can just use popd permalink fedilink source parent
[–] executivechimp@discuss.tchncs.de 1 point 2 years ago Go for it. I've been using it for years without a problem. permalink fedilink source parent
[–] Astaroth@lemm.ee 2 points 2 years ago I use Fish and have keybinds for previous and next directory, 99% of the time when going up in a directory it's to (one of) the previous directory/ies I was in permalink fedilink source parent
[–] beeng@discuss.tchncs.de 2 points 2 years ago (1 child) Look into zoxide. z direc Will take you to the most used directory starting with "direc" eg "/home/me/random/directory" permalink fedilink source parent hideshow 2 child comments replies: [–] executivechimp@discuss.tchncs.de 2 points 2 years ago (1 child) I've tried things like that before but never got on with them. I found when I had many projects with similar directory structures it was easy to end up in the wrong place and took more thought to get to the right place than just cding permalink fedilink source parent hideshow 2 child comments replies: [–] beeng@discuss.tchncs.de 1 point 2 years ago* The dir's are the same names or similar? A few extra key strokes to get the fullname should be easier than cd'ing back and forth. There's also z foo "space" "tab" as per docs to get interactive list for matches. But, just a suggestion! permalink fedilink source parent
[–] executivechimp@discuss.tchncs.de 2 points 2 years ago (1 child) I've tried things like that before but never got on with them. I found when I had many projects with similar directory structures it was easy to end up in the wrong place and took more thought to get to the right place than just cding permalink fedilink source parent hideshow 2 child comments replies: [–] beeng@discuss.tchncs.de 1 point 2 years ago* The dir's are the same names or similar? A few extra key strokes to get the fullname should be easier than cd'ing back and forth. There's also z foo "space" "tab" as per docs to get interactive list for matches. But, just a suggestion! permalink fedilink source parent
[–] beeng@discuss.tchncs.de 1 point 2 years ago* The dir's are the same names or similar? A few extra key strokes to get the fullname should be easier than cd'ing back and forth. There's also z foo "space" "tab" as per docs to get interactive list for matches. But, just a suggestion! permalink fedilink source parent
[–] PlexSheep@feddit.de 1 point 2 years ago What I use to automatically extend stuff like ls .... to ls ../../../.. function expand-dots() { local MATCH if [[ $LBUFFER =~ '(^| )\.\.\.+' ]]; then LBUFFER=$LBUFFER:fs%\.\.\.%../..% fi } function expand-dots-then-expand-or-complete() { zle expand-dots zle expand-or-complete } function expand-dots-then-accept-line() { zle expand-dots zle accept-line } zle -N expand-dots zle -N expand-dots-then-expand-or-complete zle -N expand-dots-then-accept-line bindkey '^I' expand-dots-then-expand-or-complete bindkey '^M' expand-dots-then-accept-line (for zsh) permalink fedilink source parent