cd ‘/dev/sda1’
or
cd “C:/”
https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html#index-cd
TIL about $CDPATH may have to populate that!
Wait until we tell them about autojump
cd .
More like cd… dir cd… dir cd…
deleted by creator
cd .. pwd
and then rinse and repeat for every level because you just don’t trust that mischievous cd
cd /some/thing/i/remember
alias ..='cd ..' #: up one directory alias ...='cd ../..' #: up two directories
The first two options (
autocd
andcdspell
) have been a lifesaver in fixing my frustrations with the defaultbash
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
I alias
..
tocd ..
Works for me 🤷🏻
I do that too!
I also aliasto
cd ../..
. 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…
I use a lot
cd -
(go to previous) or justcd
to go home.Nah, I always
cd
to full path, that way I can easily use my history to move back therecd…
Honestly I haven’t tried this on Linux yet, but didn’t Windows implement this somewhere along the way?..
cd ....
I believe,
zsh
supports 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
zsh
for scripts either.
I mean, I believe, it’s generally compatible withbash
, but just throwing a shebang likeor
into the first line of the script will make it execute with
sh
orbash
, even when you run it fromzsh
.
Windows be like
cd …
ls
grumble grumble
dir
Wanna fix that real quick?
echo @dir %1 %2 %3 %4>%SystemRoot%\System32\ls.bat
I aliased
cd
to 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 … ls cd … ls cd … ls cd … ls