Live data from Hacker News

Zsh Tricks to Blow Your Mind

twilio.com

131–140 of 218 posts

Re: Zsh Tricks to Blow Your Mind

#132
I always liked tcsh for how they did for loops. It's taken me 20 years of bash and I still always get the syntax wrong the first time. I need to figure out how to alias it.

I like the ^R trick. In bash I usually just !(whatever the string is) which only matches the last one or the more infamous !?(whatever the file/obj you were applying the command to)?

Re: Zsh Tricks to Blow Your Mind

#134
post #98
post #78

Earlier quoted context omitted.

I'd also dare to bet the author's favourite pizza is Hawaiian/pineapple

Salty/sweet contrast is the core of Hawaiian pizza appeal, and flavour/texture contrasts are the foundation of some of the most interesting foods, for instance salted caramel, pork and apples, etc.

Pineapple, banana pepper, and jalapeño may be my favorite pizza.

Re: Zsh Tricks to Blow Your Mind

#135
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  groff  groups

Re: Zsh Tricks to Blow Your Mind

#136

Earlier quoted context omitted.

the kerning in the screenshots is "hilarious"

looks like a version of Comic Sans, possibly http://www.comicneue.com/ or as recently discussed Comic Mono: https://news.ycombinator.com/item?id=25520510 https://dtinth.github.io/comic-mono-font/

Those would be better kerned. This is probably using the default Comic Sans forced to fixed width. Which is predictably bad.

Re: Zsh Tricks to Blow Your Mind

#138
Knew most of those, not much interested in "shell plugins".

One thing that many people miss are parameter expansions. Those are in Posix, so pretty much any bare shell should be able to use that, too. So dash/bash/zsh/ksh…

    echo Hello ${PLANET:-World} 
to have a default if you're not sure a variable is set. Replace "-" with "=" to actually set it, not just use it for this statement.

Or removing suffixes:

    filename=/tmp/foobar.tar.gz
    echo ${filename%.*} # -> /tmp/foobar.tar
    echo ${filename%%.*} # -> /tmp/foobar
Saves you some useless sed/awk.

I still wish the Linux shells (bash/zsh) would start to finally get some more features from friggin' ksh93.

Re: Zsh Tricks to Blow Your Mind

#139
A lot of the tips from TFA can be done in BASH as well and I'm sure the following of my own zsh tips also have a bash equivelant, but I'd like to share anyway:

Pure theme - My absolute favorite shell theme. Has almost all the bells and whistles of the powerlevel9k shown in the article, but looks, much cleaner and less in-your-face.

After downloading the theme, I've added this to my `.zshrc` file:

    # PURE theme - see https://github.com/sindresorhus/pure
    fpath+=$HOME/.zsh/pure
    
    autoload -U promptinit; promptinit
    prompt pure
Fuzzy find makes searching history much more powerful than what is listed in the article. I only use it together with ctr-r, but you can set it up for even more goodness.

    # Fuzzy find - see https://github.com/junegunn/fzf
    [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
Lastly I've added a syntax highlighter, which is really neat.

      # ZSH Syntax Highlighter - see https://github.com/zsh-users/zsh-syntax-highlighting
      source $HOME/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
I don't use oh-my-zsh, but I think my terminal is as fully fledged as even the best oh-my-zsh can offer.

Re: Zsh Tricks to Blow Your Mind

#140
post #98
post #78

Earlier quoted context omitted.

I'd also dare to bet the author's favourite pizza is Hawaiian/pineapple

Salty/sweet contrast is the core of Hawaiian pizza appeal, and flavour/texture contrasts are the foundation of some of the most interesting foods, for instance salted caramel, pork and apples, etc.

That makes a lot of sense. Admittedly the only Hawaiian pizza I've ever had came from the freezer.

Whenever the local Italian restaurant opens back up I'll go and try a properly made Hawaiian pizza :)

Post reply on HN