5 ms·
I think the move of Kali Linux from bash to zsh is sane. I sometimes have to use the default shell of Linux distribution, especially on servers, and my main pai
by idoubtit 6y ago
I think the move of Kali Linux from bash to zsh is sane. I sometimes have to use the default shell of Linux distribution, especially on servers, and my main pain points with bash are:
- The history is editable by default. If I move to a previous history line and change it, the old line disappears. Hitting Ctrl-c will remove it from the history.
- If I use simultaneous shells (screen, tmux, or several ssh connections), the history saved will be the one of the last shell to quit. The bash config `histappend` should be the default, IMO.
- Most of the time, I search the history by the beginning of the command I just typed, which zsh maps to alt-p and which bash does not map by default. I rarely use the ctrl-r search.
- No way to pause a command and view the man. With zsh, `git clone<alt-h>` will display `man git-clone`, then return to the incomplete command line.
- No way to set a command aside. E.g. if I realise while typing that I'm not in the right directory, `git clone<alt-q>cd src<return>`.
- Neil44 6y agoPause command - I usually hit home, insert a # then enter then man then get the command back and continue. Or tmux it. Didn't realise zsh had that shortcut.
- saagarjha 6y ago> No way to pause a command and view the man. ^A, ^K, m, a, n, space, ^Y, enter. Upon exit, ^Y. > No way to set a command aside. ^A, ^K. Grab it again with ^Y. (Yes, these are all readline shortcuts. If you think they’re a bit long, bind them to something shorter in your inputrc.)
- dima55 6y agoDo you actually use zsh? C-o and M-q and M-a and M-h and all the others are really nice, and as far as I know bash has nothing similar (correct me if I'm wrong). You don't NEED any of these niceties but they're very nice.
- codetrotter 6y ago> E.g. if I realise while typing that I'm not in the right directory, `git clone<alt-q>cd src<return>`. With bash I’d just Ctrl+a and type “cd src ;” and then press ctrl+e and continue typing what I was typing. I got so used to doing it that way, that even after switching to zsh I still do it this way. The disadvantage of my way of doing it is if you typo the path. But I tab complete pretty much always, so in practice I don’t have the problem of typoing directory names without noticing. I probably should learn those zsh ways of doing things. Will try to remember to do it the zsh way next time I need to do something like the things you mentioned.
- mkl 6y agoIf you use && instead of ; then you won't have the typo problem.
- codetrotter 6y agoTrue, but that means typing another character and I am lazy :p
- mkl 6y ago> - The history is editable by default. If I move to a previous history line and change it, the old line disappears. Press M-r to revert back to the original command. > - No way to set a command aside. E.g. if I realise while typing that I'm not in the right directory, `git clone<alt-q>cd src<return>`. Press M-# to comment out the current command and go to a new prompt, then up to get the commented command back, and M-3 M-# to uncomment it and run it (any number works, but 3 is the same key as #).
- inetknght 6y agoOh look! Magic! I think if bash had some interactive help with this magic when it appears then it would be a lot more helpful and a lot less magical.
- zests 6y agoI don't think bash really fits the type of program to have interactive tutorials. If you are serious about your command-line-fu its worth giving the manual a good read. bind -P | grep '\\e' https://www.gnu.org/software/bash/manual/ https://www.gnu.org/software/bash/manual/ My favorite by far is '\e.' or 'M-.' which inserts the last arg from your previous command. Discovering this led me down the bash rabbit-hole of finding new commands, creating my own and really enjoying the bash shell. Did you know you can execute arbitrary code as one of these commands? I had one that ran 'docker ps' so I could list my containers in the middle of typing a command.
- mapolone 6y agoNot to mention: - Oh-my-zsh has a lot of plugins for auto-completion - FZF (fuzzy finder), for command history is a big hit (supports bash too)
- ti_ranger 6y ago> - Oh-my-zsh has a lot of plugins for auto-completion As does bash-completion, which is available in many (but not all :-/) Linux distros and via Homebrew on MacOS and [pre-dates](https://github.com/scop/bash-completion/tree/09b07d57a7031d904223b31c3a240adab0533546 https://github.com/scop/bash-completion/tree/09b07d57a7031d9...) [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh/tree/5da20b9dddb1f7a9110675ded5df59c4c3ed1b83 https://github.com/ohmyzsh/ohmyzsh/tree/5da20b9dddb1f7a91106...) by about 6 years. But, zsh users and oh-my-zsh fan-boys seem to be entirely ignorant of bash-completion.
- sbarre 6y agoI never understand comments like these. Why do you have to twist this to be about "ignorant fan boys"? Not enough drama in the world already?
- ti_ranger 6y agoSorry, but I've read too many posts that say "bash sucks, it doesn't do <thing that bash has done for years before zsh did it> like zsh does".
- rootbear 6y agoThis may be an old fashioned way to do it, but I set aside a command by using ^A (or Home) and the entering : and space: $ : Command that has an error I can then cd to the right directory, or fix whatever other problem I had, then use up-arrow to get back to the command, remove the : and space and run it. The : (no op) command is fairly obscure and some of the other suggestions here are probably better.
- barbs 6y agoI do the same but with a # to comment it out
- tug0fwar 6y agoAt the end of the day, whatever shell best suits you basically boils down to usage, habits and how much willing you are to tweak it.