News for hackers. Stuff that matters.
Re:Kali Linux 2020.3 by idoubtit on Monday August 24, 2020 @04:57AM (#24258708)
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>`.

Re:Kali Linux 2020.3 by mkl on Monday August 24, 2020 @06:09AM (#24259138)
> - 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 #).

Re:Kali Linux 2020.3 by inetknght on Monday August 24, 2020 @11:39AM (#24261678)
Oh 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.

Re:Kali Linux 2020.3 by zests on Monday August 24, 2020 @12:17PM (#24262112)
I 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/

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.

Re:Kali Linux 2020.3 by codetrotter on Monday August 24, 2020 @05:51AM (#24259034)
> 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.

Re:Kali Linux 2020.3 by mkl on Monday August 24, 2020 @06:11AM (#24259150)
If you use && instead of ; then you won't have the typo problem.
Re:Kali Linux 2020.3 by codetrotter on Monday August 24, 2020 @06:29PM (#24266272)
True, but that means typing another character and I am lazy :p
Re:Kali Linux 2020.3 by rootbear on Monday August 24, 2020 @10:51AM (#24261223)
This 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.

Re:Kali Linux 2020.3 by barbs on Monday August 24, 2020 @04:21PM (#24265075)
I do the same but with a # to comment it out
Re:Kali Linux 2020.3 by mapolone on Monday August 24, 2020 @06:10AM (#24259142)
Not 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)

Re:Kali Linux 2020.3 by zests on Monday August 24, 2020 @09:30AM (#24260435)
I tried using ZSH. My first experience was using a bunch of plugins like zsh spaceship and having the shell slow to a complete halt.

I then used "stock zsh" and running commands was fine except some autocompletes like git-autocomplete were terribly slow and, for example, did not support `git switch`. This broke my workflow and it was easier to just go back to bash than to figure out how zsh works. I found that autocomplete in zsh is a lot more opaque than in bash. I'm sure there are ways to fix it. My way was to switch to bash.

(Now I use magit so the need is lessened.)

Re:Kali Linux 2020.3 by ti_ranger on Monday August 24, 2020 @06:25AM (#24259225)
> - 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/09b07d57a7031d9...) [oh-my-zsh](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.

Re:Kali Linux 2020.3 by sbarre on Monday August 24, 2020 @07:00AM (#24259434)
I 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?

Re:Kali Linux 2020.3 by ti_ranger on Monday August 24, 2020 @08:19AM (#24259868)
Actually, maybe it's more the fact that at a prominent tech company: * zsh is the default shell on a large proportion of servers that have read-only /home, so you can't easily change to your preferred shell * a training guide that many new developers follows states incorrectly that:

> If you are using Bash and you have the option of using ZSH, you should switch to it. ZSH has additional auto-complete and history features that Bash doesn’t have (but don't worry - those features will not be relevant to this tutorial.)

oh-my-zsh seems to be recommended by a lot of developers in this company, even though: * the default mechanism to install is curl|sh (there is no Homebrew package) on developer machines which have privileged access to a lot of resources * installing it via its recommended installation procedure on dev machines would violate company policies, whereas installing bash-completion wouldn't

Re:Kali Linux 2020.3 by ti_ranger on Monday August 24, 2020 @07:42AM (#24259685)
Sorry, 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".
Re:Kali Linux 2020.3 by sbarre on Monday August 24, 2020 @08:11AM (#24259829)
And there's a constructive way to respond to those posts, if you must absolutely respond.

Yours ain't it.

Re:Kali Linux 2020.3 by dbtc on Monday August 24, 2020 @01:59PM (#24263395)
Ironic response.
Re:Kali Linux 2020.3 by sbarre on Monday August 24, 2020 @03:54PM (#24264768)
Fair point
Re:Kali Linux 2020.3 by Neil44 on Monday August 24, 2020 @05:06AM (#24258748)
Pause 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.
Re:Kali Linux 2020.3 by rytis on Monday August 24, 2020 @05:14AM (#24258795)
Instead of home+#+enter try alt-#
Re:Kali Linux 2020.3 by smichel17 on Monday August 24, 2020 @07:33AM (#24259638)
I usually append \, hit enter, then ctrl-c. Run the new command, then up arrow, backspace, enter. You can get closer to the zsh workflow with ctrl-z instead, but that doesn't work if the new command is cd.
Re:Kali Linux 2020.3 by saagarjha on Monday August 24, 2020 @05:11AM (#24258781)
> 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.)

Re:Kali Linux 2020.3 by dima55 on Monday August 24, 2020 @05:26AM (#24258865)
Do 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.
Re:Kali Linux 2020.3 by p4bl0 on Monday August 24, 2020 @07:45AM (#24259701)
The comment you are responding to talks about Bash.
Re:Kali Linux 2020.3 by dima55 on Monday August 24, 2020 @08:43PM (#24267109)
It talks about bash workarounds for zsh features.
Re:Kali Linux 2020.3 by tug0fwar on Monday August 24, 2020 @11:20AM (#24261501)
At 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.