Skip to main content

What are the advantages and disadvantages of using zsh instead of bash (or other shells)?

Everything you know from bash still applies, but zsh does a bunch of other useful things. I know that I use only a small subset of them, but these are especially useful for me:

  • Extended globbing: For example, 
    *(.)
     matches only regular files, not directories, whereas 
    a*z(/)
     matches directories whose names start with 
    a
     and end with 
    z
    . There are a bunch of other things, such as 
    **
     as described by Ole Tange.
  • Inline glob expansion: For example, type 
    rm *.pdf
     and then hit tab. The glob 
    *.pdf
     will expand inline into the list of .pdf files, which means you can change the result of the expansion, perhaps by removing from the command the name of one particular file you don’t want to 
    rm
    .
  • Interactive path expansion: Type 
    cd /u/l/b
     and hit tab. If there is only one existing path each of whose components starts with the specified letters (that is, if only one path matches 
    /u*/l*/b*
    ), then it expands in place. If there are two, say 
    /usr/local/bin
     and 
    /usr/libexec/bootlog.d
    , then it expands to 
    /usr/l/b
    and places the cursor after the 
    l
    . Type 
    o
    , hit tab again, and you get 
    /usr/local/bin
    .
  • Nice prompt configuration options: For example, my prompt is currently displayed as 
    tov@zyzzx:/..cts/research/alms/talk
    . I prefer to see a suffix of my current working directory rather than have a really long prompt, so I have zsh abbreviate that portion of my prompt at a maximum length.

The ones not already listed here are :
  • Auto-correct on known commands

  • Auto-complete : This is different from the default bash autocomplete
    e.g
    You type 

    kill
    and press <tab>. Instead of a list of files in current directory, you'll see all your processes with their pids.


  • Remote auto-completion :
    So I can view remote file listings :


    Now if I press <tab>, I can view the remote directory listing on the remote server
  • Expand variables

    ~/    $PATH <tab>
    you get =>
    ~/    /usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/mridul/.rvm/bin
  • Use Alt-/ (forward slash) to move through argument history
  • Shared command history between all running shells.
    This is something some people appreciate and some others wouldn't like. But I find it useful for myself.

Advantages that I appreciate:
  1. Much easier prompt definitions. Particularly dynamic/multine prompts.
  2. Right Prompt? Yes, thank you!
  3. Awesome set (more comprehensive than BASH) of Auto Completions are much faster and smarter (e.g. case insensitive completion, smart defaults)
  4. Path Expansion is pure win. (cd /v/w [tab] == cd /var/www)
  5. Path Replacement is pretty cool also.
  6. Spelling Correction (setopt correct) is mighty awesome for me.
  7. oh-my-zsh - Large, community driven framework for all sorts of bells and whistles.
  8. The Zsh Line Editor... just google it
  9. Key Bindings? Yes, thank you!
  10. Globbing

Comments

Popular posts from this blog

Magento-Concept

1) Mcrypt : This is an interface to the mcrypt library, which supports a wide variety of block algorithms such as DES, TripleDES, Blowfish (default), 3-WAY, SAFER-SK64, SAFER-SK128, TWOFISH, TEA, RC2 and GOST in CBC, OFB, CFB and ECB cipher modes. Additionally, it supports RC6 and IDEA which are considered "non-free". CFB/OFB are 8bit by default. 2) Mhash : These functions are intended to work with » mhash. Mhash can be used to create checksums, message digests, message authentication codes, and more. This is an interface to the mhash library. Mhash supports a wide variety of hash algorithms such as MD5, SHA1, GOST, and many others. 3) Simplexml : The SimpleXML extension provides a very simple and easily usable toolset to convert XML to an object that can be processed with normal property selectors and array iterators. 4) DOM : The DOM extension allows you to op  erate on XML documents through the DOM API with PHP 5. 5) InnoDB storage engine : InnoDB is ...