Did that years ago, just called it cds. I also have an "up" command which is an alias to "cds ..". Oh, and I have a "setup server_name" they copy all my aliases to a server and create an alias that allow me to "ssh -A server_name" using only server_name.
Alternatively, you could use a TUI file manager. Once you get the navigation down you can manage things pretty quickly. Especially with ones that have options for dual directory layouts, like Midnight Commander or vifm.
Try Dolphin. Press F4 to open the terminal view. It stays in dync with the gui so if you use cd in the terminal, the contents of the new folder will be shown.
that, or you have to make ABSOLUTELY SURE that you haven't accidentally pressed a button on your keyboard that has inevitably resulted in the total destruction of the directory contents
Doesn't let you rifle through things approvingly as you go. "Yes this is the correct directory because it has the three files I was looking at earlier--
You know what let's do a ls -al just to be super sure it's the right modification
Sometimes I throw off the linux admin reading my log by throwing in a pwd before going to the next one. Know it's not gonna be in that directory you know?
Installing zoxide led me to installing fzf, which has improved my terminal experience by about 35%, I already installed it in all the machines I'm managing
Check out Atuin. Its another must have for me. When you push up arrow, it shows your command history in a very pleasing list. You can even generate account keys to migrate your history between PCs, but I've never bothered with it. You can also search past commands on the history menu.
You don't need an account for it. That's only for the migration keys.
I can recommend featureful terminal emulator Kitty. I'd been using tmux and screen for over a decade, but now just get that functionality baked into the terminal. The only time I use tmux now is for remote sessions.
I was about to post something similar. With fish you can do your own functions, right? So, you can pass any dots as arguments to a function called cd, so, for every extra dot after .., you append a /.. at the end.
The first two options (autocd and cdspell) have been a lifesaver in fixing my frustrations with the default bash settings (and even lets me stick with bash, instead of feeling I should move to zsh or any other shell.
I can just type a foldername, tabcomplete it and press enter to go there. It's great.
# == shopts ==
# https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html
shopt -s autocd # cd into folder without cd, so 'dotfiles' will cd into the folder
shopt -s cdspell # attempt spelling correcting on folders
shopt -s direxpand # expand a partial dir name
shopt -s checkjobs # stop shell from exit when there's jobs running
shopt -s dirspell # attempt spelling correcting on folders
shopt -s expand_aliases # aliases are expanded
shopt -s histappend # append to the history file, don't overwrite it
shopt -s histreedit # lets your re-edit old executed command
shopt -s histverify # I'm confused.
shopt -s hostcomplete # performs completion when a word contains an '@'
shopt -s cmdhist # save multiple-line command in single history entry
shopt -u lithist # multi-lines are saved with embedded newlines rather than semicolons; explictly unset
shopt -s checkwinsize # update LINES and COLUMNS to fit output
Easiest solution, use fish instead of bash! Default fish keybindings will allow you to just type . . or name a directory similar to how you could do with Zoxide.
Point was: most of the time I see someone spending time counting the requisite number of ..s, all they really wanna do is “go back to where I was before”.
cd foo/bar/baz/qux and cd - is better than cd foo/bar/baz/qux and cd ../../../..
Biggest issue I have with custom macros is I’m logging into like 5 different machines a day. Don’t wanna keep copying over my custom bash files. Prefer built-in commands.
Oh yeah, I wouldn't use that for scripts. I wouldn't use zsh for scripts either.
I mean, I believe, it's generally compatible with bash, but just throwing a shebang like #!/bin/sh or #!/bin/bash into the first line of the script will make it execute with sh or bash, even when you run it from zsh.
The history of the CTO at a previous job was filled with dc and sl because he was a fucking moron. Yes I'm still bitter that he earned way more money than me who had to fix all his mess.
The good thing about Dolphin is you can have the real tree following your navigation. Want to go up a few levels, just click once, directly where you want to go next. None of this up, up, up nonsense. Great for snooping in many different folders in quick succession.
Mmmm i wouldn't type them in a sequence. Rather quickly ! and then enter.
But I realise, this only makes sense in an azerty layout, where exclamation mark is close to the enter key. It's then very fast to ! Enter and go back levels.
"hmm yes.. everything seems to be in order"
I need a shell/plugin/tool/whatever that always shows me the content of the current dir in a little popup or something.
Anything I do in the shell is like cd this, ls, cd there, ls *, I feel like a have the navigational awareness of a amnesiac goldfish
Put this in bashrc or whatever flavour of shells's bashrc you use:
I didnt remember the function sintax of bash so I just copied it from SO.
You (probably) only want to pass the first argument to
cd, this'll send the rest tols.Did that years ago, just called it cds. I also have an "up" command which is an alias to "cds ..". Oh, and I have a "setup server_name" they copy all my aliases to a server and create an alias that allow me to "ssh -A server_name" using only server_name.
Alternatively, you could use a TUI file manager. Once you get the navigation down you can manage things pretty quickly. Especially with ones that have options for dual directory layouts, like Midnight Commander or vifm.
It is called windows 2000 explorer and it's great for file operations :) In Linux i have yet to find a really good replacement ;(
Try Dolphin. Press F4 to open the terminal view. It stays in dync with the gui so if you use cd in the terminal, the contents of the new folder will be shown.
That sounds really cool but I spent so much time making things look pretty …
What's a GUI?
that, or you have to make ABSOLUTELY SURE that you haven't accidentally pressed a button on your keyboard that has inevitably resulted in the total destruction of the directory contents
A window, you say!?
You probably want rangerfm or vifm. They use miller columns for to show you your surrounding context.
pwdseems more appropriate thanlsDoesn't let you rifle through things approvingly as you go. "Yes this is the correct directory because it has the three files I was looking at earlier--
You know what let's do a ls -al just to be super sure it's the right modification
fair point
I ain't reading allat
Then you invite chaos to sit in your lap, friend
Sometimes I throw off the linux admin reading my log by throwing in a pwd before going to the next one. Know it's not gonna be in that directory you know?
cd ..⭡ ⏎⭡ ⏎⭡ ⏎Oh, shit.
square
That's pretty neat
This is the way.
Or just use zsh
Yeah, let's use whole different shell, because you can't add some few aliases to your
.bashrc.That's not why I use a whole different shell. It just happens to be a perk of the one I use.
.....for zsh usersExcuse me what? I've been multi cd'ing for years like a chump?
Exactly. The fucking what now?
Doesn't work on my machine... is it a setting that needs to be enabled or something?
Same. I LLMd it and said it needs aliasing so not sure what these users are saying now actually.
cd .. ls cd .. ls cd .. ls cd .. ls
Depending on where you are, maybe just "cd".
Smh when are you going to upgrade to dvd
Then forget all that and just use
cd ~orcd /No need for
~- justcdworks as well.I alias
..tocd ..Works for me 🤷🏻
I do that too!
I also alias
...tocd ../... I'll be honest, I often forget to do it, but in theory it can speed things up.I feel like thats eventually going to case problems when you run a script...
for i in { 1..4 }; do cd ..; done
Try zoxide
Installing zoxide led me to installing fzf, which has improved my terminal experience by about 35%, I already installed it in all the machines I'm managing
Got any more tools? :)
Check out Atuin. Its another must have for me. When you push up arrow, it shows your command history in a very pleasing list. You can even generate account keys to migrate your history between PCs, but I've never bothered with it. You can also search past commands on the history menu.
You don't need an account for it. That's only for the migration keys.
Yeah, these two are fucking awesome. I recently installed zoxide and OMG, i dont know how ive lived without it.
Other awesome tools: Eza - prettier ls Yazi - vim-like file manager
I don't think there's anything too unusual but here's my nix packages
I can recommend featureful terminal emulator Kitty. I'd been using tmux and screen for over a decade, but now just get that functionality baked into the terminal. The only time I use tmux now is for remote sessions.
I am tmuxed all the time, the idea of integrating it into the terminal is interesting. I'll need to think about it, thanks for the suggestion :)
eza is pretty cool, too. I replacement for ls which has built in tree view, dir size summary, and git status.
Are you sure it's not 33.3, repeating, of course? Just making sure.
zoxide, btop and lazygit are a must for me in any computer.
Yup. I usually have zoxide installed. It's grand.
I use a lot
cd -(go to previous) or justcdto go home.Or the alias I have set up
…..
I kept saying "cd up" in my mind so I just made an alias for
cdu, became a reflex within the next dayOnce you've typed .. you know if you type more dots it's to go up more dir, so you don't really need two dots for each additional dir.
Yeah so it was five dots for four directories up. I also have
… for 2
And
…. for 3
I don’t think I have one for 5. I’d have to look. I also use autojump and fzf which is very useful.
i use fish shell with https://github.com/nickeb96/puffer-fish
basically when i type
...it expands to../..and adds another/..for every additional dot i typeits similar to what the zsh users in the comment section are doing
I was about to post something similar. With fish you can do your own functions, right? So, you can pass any dots as arguments to a function called
cd, so, for every extra dot after.., you append a/..at the end.yeah, but its less visual
cd .....is harder to understand thancd ../../../..also the extension work with any commend, not just
cdcd ..
cd ..
history
!1
!1
!1
...
You forgot the pwd after each 'cd'.
ls*
Ls doesn't tell them where they are, just what files exist in their current location.
Yup,
But I want to know if the file I'm looking for is in this directory or I have to cd.. once more
That's when locate piped to grep is your best friend.
cd .....I use zsh btwWhaaaaaaaaaaaaaaat
don’t even need the cd since if it’s a dir, zsh automatically cd to that path ;)
just
…..works greatI didn't know that. Thanks!
Me doing it the worst way > opening up dolphin(file explorer) navigating to the folder then opening terminal there.
Doesnt dolphin has a terminal in built so you can watch files in gui and still use cli?
Yep you can toggle it with F4
Yes I use it sometime but then I close it and forget about it
I like ranger (https://github.com/ranger/ranger).
The first two options (
autocdandcdspell) have been a lifesaver in fixing my frustrations with the defaultbashsettings (and even lets me stick with bash, instead of feeling I should move to zsh or any other shell.I can just type a foldername, tabcomplete it and press enter to go there. It's great.
alias .4=cd ../../../..
alias -g .4="../../../.."
Tbf it is less key presses since you can generally just recall the last command.
What's so surprising?? What did you see in that dir??
Double-bang repeats the previous command. Great if you forget
sudo.Haha yeah I was just being silly
Easiest solution, use fish instead of bash! Default fish keybindings will allow you to just type . . or name a directory similar to how you could do with Zoxide.
Also, wait until you find about pushd and popd ;)
Really buried the lede there:
pushdandpopdare what I use instead ofcdmost times!cd -helps-returns you to the previous path rather than repeat the last cd right? so cd - would undo the cd ..Point was: most of the time I see someone spending time counting the requisite number of
..s, all they really wanna do is “go back to where I was before”.cd foo/bar/baz/quxandcd -is better thancd foo/bar/baz/quxandcd ../../../..I've used a script that made 'up 4' a thing. Forgot to migrate it though.
Biggest issue I have with custom macros is I’m logging into like 5 different machines a day. Don’t wanna keep copying over my custom bash files. Prefer built-in commands.
Yeah, I get that. But I'm traversing my machine a lot while developing, so I want that as hassle free as possible.
Me too. Would love a tool that allows me to have bells and whistles on my remote machines without having to install extra packages on them.
Had it in my .zshrc. I should look for it, it was helpful
Wait until we tell them about autojump
Honestly I haven't tried this on Linux yet, but didn't Windows implement this somewhere along the way?...
cd ....Windows be like
cd ..
ls
grumble grumble
dir
Wanna fix that real quick?
echo @dir %1 %2 %3 %4>%SystemRoot%\System32\ls.batI believe,
zshsupports that.Interesting, I might have to check that out someday.
Though when I write scripts, I'm not a fan of blind folder navigation like that, there's a good reason for the pushd and popd script commands.
Oh yeah, I wouldn't use that for scripts. I wouldn't use
zshfor scripts either.I mean, I believe, it's generally compatible with
bash, but just throwing a shebang like#!/bin/shor#!/bin/bashinto the first line of the script will make it execute withshorbash, even when you run it fromzsh.I aliased
cdto a custom funtion in my bashrc to do this at one point, butcd ../../../..is too engrained so I never rembered to use it.You will probably like zoxide (i am not sure about policy on links here, but here you go https://github.com/ajeetdsouza/zoxide)
Zoxide is nice, or use Yazi so you can actually see where you're going.
Yazi, Superfile, Midnight Commander (my favorite), or Ranger. I'm sure there's more, but those are the ones I know.
cd .../...
The
historyof the CTO at a previous job was filled withdcandslbecause he was a fucking moron. Yes I'm still bitter that he earned way more money than me who had to fix all his mess.You could have gifted him some silly fun with the
slpackage.I feel called out. Should definitely make an alias or two that auto CDs me the amount of times I need...
Why no cd /////// speceficterm if you know how deep it is
Those are supposed to be stars. I'm not fixing this on a phone
Childhood me with only MS-DOS machines is all feeling nostalgic.
td aliased to cd $(whatever the command is to get the git root directory)
cd /some/thing/i/remember
I guess if you enjoy being a virgin that much you can do it that way.
Well, mom said I could be anything when I grew up...
Nah, I always
cdto full path, that way I can easily use my history to move back therez myDirgit () { if [ "$1" = "cd" ] then shift cd "./$(command git rev-parse --show-cdup)$*" else command git "$@" fi }I created a script called GoUpALevel.
alias cdr='cd /'
Heh
and then rinse and repeat for every level because you just don’t trust that mischievous cd
More like cd… dir cd… dir cd…
The good thing about Dolphin is you can have the real tree following your navigation. Want to go up a few levels, just click once, directly where you want to go next. None of this up, up, up nonsense. Great for snooping in many different folders in quick succession.
bind '"^H":"cd ..^M"'Syntax get's twisted here. Second ^ is inserted automatically. As well as the One after the actual bash line.
What it does: Bind Ctrl+Backspace to
cd ...https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html#index-cd
TIL about $CDPATH may have to populate that!
cd ./..
cd ../._
Sometimes I have to swap between two routed for several things, so I create a quick in-memory alias like aa=$(pwd)
Then I can cd $aa
cd '/dev/sda1'
or
cd "C:/"
alias !="cd .."
Approximative syntax but you get the idea.
!!is the last command in my shell.Mmmm i wouldn't type them in a sequence. Rather quickly ! and then enter.
But I realise, this only makes sense in an azerty layout, where exclamation mark is close to the enter key. It's then very fast to ! Enter and go back levels.
I agree some solutions below are more elegant