Live data from Hacker News

Zsh Tricks to Blow Your Mind

twilio.com

161–170 of 218 posts

Re: Zsh Tricks to Blow Your Mind

#161
post #51

I've been using Fish instead and it's much much simpler than configuring ZSH to my liking. It's already good out of the box, without having to carry around any kind of configuration. The only stuff I usually do is to setup `powerline-go` as prompt, and voilà, that's pretty much it.

The main drawback for fish is that is not compatible with bash scripting. If you need help with something specific, you can throw out almost all help available online.

Switched to fish for daily use a year ago and have only had to fallback to bash maybe 3-4 times for a gnarly command invocation that was bash only.

Re: Zsh Tricks to Blow Your Mind

#162

I've been using Fish instead and it's much much simpler than configuring ZSH to my liking. It's already good out of the box, without having to carry around any kind of configuration. The only stuff I usually do is to setup `powerline-go` as prompt, and voilà, that's pretty much it.

I rather liked Fish's zero config approach but I found their handling of the PATH very hard to work with day to day. Perhaps it was just my familiarity with having a bunch of statements to alter the PATH in a config file but it felt very opaque, I always had to look up how to add stuff to the PATH and I had great trouble trying to remove stuff from the PATH.

That is a valid issue. Should be remedied in an upcoming release.

Re: Zsh Tricks to Blow Your Mind

#163

Apple has kind of herded me into zsh for work in the terminal. So far it has been pleasant, with interesting plugins, but it's periodic updates are a little annoying. Despite remaining in zsh while in a terminal, I still find myself writing only bash scripts when a script it needed.

>Despite remaining in zsh while in a terminal, I still find myself writing only bash scripts when a script it needed.

I do this too. I think it's good practice; zsh is amazing as an interactive shell, but bash is everywhere.

Re: Zsh Tricks to Blow Your Mind

#164

Earlier quoted context omitted.

I rather liked Fish's zero config approach but I found their handling of the PATH very hard to work with day to day. Perhaps it was just my familiarity with having a bunch of statements to alter the PATH in a config file but it felt very opaque, I always had to look up how to add stuff to the PATH and I had great trouble trying to remove stuff from the PATH.

That is a valid issue. Should be remedied in an upcoming release.

Oh wow that's great to hear. Do you have any resources I could reference? A Github issue discussing the intended solution or something?

Re: Zsh Tricks to Blow Your Mind

#165
post #153

My favourite feature of zsh (it might be oh-my-zsh), is the tab expansion of unambiguous abbreviated paths. Say if you do: $ cd /u/b/l That will expand into /usr/bin/local. If there are ambiguities at any point, it will expand as much as it can and let you fix it at the point where a decision needs to be made (pressing tab again will show you the options, like Bash et al). For example: $ /u/b/gr $ /usr/bin/gr grep gr…

As far as I know, that's not oh-my-zsh, since I can do that and I don't have omz installed.

You're right, all it requires is a call to compinit from base zsh: `autoload -Uz compinit; compinit` And compinstall can be used to configure things like the case-sensitivity or amount of ambiguity accepted in matches using a nice menu system.

Re: Zsh Tricks to Blow Your Mind

#167

Earlier quoted context omitted.

Solid selection. I'd also add nnn as the fastest tool to navigate directories I've ever seen.

Have you been able to get it to cd on quit? it's the only thing I can't seem to get. It's amazing though.

Pressing `!` in the target directory will open a new terminal session within nnn, with that path as working dir. When you `exit` you'll land in nnn again.

It's not exactly the same but close enough for me.

Re: Zsh Tricks to Blow Your Mind

#168
post #151

Earlier quoted context omitted.

It's a feature of the zsh line editor called "push-line". http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html

Thanks very much! Adding: bindkey '^q' push-line works perfectly. Day improved!

You can also operate on the stack of pending commands programatically using the read and print builtins along with the common to both -z option. It can be a really nice way to build up or edit complex commands/variables in combination with expansion flags and such. 'print -z goodbye; print -z hello' for the five second example of what happens.

Re: Zsh Tricks to Blow Your Mind

#169
post #151

Earlier quoted context omitted.

Yes please -- this sounds great, I used to use `ctrl-u` then `ctrl-y` with bash, and that doesn't work with zsh, alas. I tried searching for `zsh "park" command` and got nothing useful.

It's a feature of the zsh line editor called "push-line". http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html

Thank you, I love it. This is so great for a quick ls or cd in between.

Turns out it wasn't the terminal that was eating my Ctrl-q, but the key wasn't bound in my zsh.

The page you linked says push-line (^Q ESC-Q ESC-q) (unbound)(unbound)

Does that mean that in a standard config push-line is bound to Ctrl-q?

Re: Zsh Tricks to Blow Your Mind

#170

Earlier quoted context omitted.

That is a valid issue. Should be remedied in an upcoming release.

Oh wow that's great to hear. Do you have any resources I could reference? A Github issue discussing the intended solution or something?

https://github.com/fish-shell/fish-shell/pull/7028
Post reply on HN