[
  {
    "path": "README.md",
    "content": "Awesome ZSH\n===========\nThis document briefly covers ZSH shell and serves as a quick summary of its many features. It's not a full guide nor a detailed documentation. It's merely a scratchpad from my journey into ZSH. \n\n*Document assumes moderate knowledge of Bash shell.*\n\n## Enable ZSH\n\n\t$ chsh -s /bin/zsh         # setting zsh as default shell\n\t                           # or simply use oh-my-zsh installer\n\n## Completions\n\n\t% autoload -U compinit && compinit\n\t% cp -<TAB>\n\t% kill <TAB>\n\n## ZSH on steroids (oh-my-zsh installed)\n\n - Install oh-my-zsh from [github](https://github.com/robbyrussell/oh-my-zsh)\n - Update configuration to your needs in `~/.zshrc`\n - Put custom configuration in `~/.oh-my-zsh/custom`\n\n## Extended globing & qualifiers\n\n\t% echo *        # like in bash\n\t% echo **/*     # glob recursively\n\t% echo **/*(.)  # glob recursively (just files)\n\t$ echo **/*(/)  # glob recursively (just directories)\n\n## Redirects\n\n\t% echo Hello >a.txt >&1         # print Hello to both a.txt and stdout\n\t% echo Hello >a.txt >/dev/fd/0  # same\n\t$ echo hello | tee a.txt        # same thing in bash\n\t% echo Hello >a.txt >b.txt      # print Hello to both a.txt and b.txt\n\n## Auto change directories\n\n\t~% coding\n\tcoding% \n\n\t% unsetopt auto_cd      # to disable\n\n## Expand paths\n\n\t~% cd c/w/m/i<TAB>\n    ~% cd coding/work/mobile/ios\n\nbut if path is not unique:\n\n\t~% cd c/w<TAB>\n\t~% cd coding/w\n\twork  week  wrong\n\n## Path replacement\n\n\t~% cd /usr/local/bin\n\t/usr/local/bin% cd bin share\n\t/usr/local/share%\n\n## Expand variables\n\n\t~% echo %PATH<TAB>\n\t~% echo /opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin\n\n\t% vared PATH         # load PATH variable into line editor, ENTER to accept\n\n## Approximated completion\n\n    # ~/.oh-my-zsh/custom/completions.zsh\n    # Allow aproximation when completing\n    zstyle ':completion:::::' completer _complete _approximate\n    zstyle ':completion:*:approximate:*' max-errors 2\n\nthen try it out:\n\n\t~% cd codign/wo<TAB>\n    ~% cd coding/work/\n\n\t~% cp --reg<TAB>\n\t~% cp --recursively\n\n## SSH remote hosts\n\n\t~% ssh user@m<TAB>\n    ~% ssh user@myserver.com\n\n## Remote path completion\n\n\t~% git clone myserver.com:/home/user/<TAB>\n    ~% git clone myserver.com:/home/user\n    repo-a.git  repo-b.git  repo-c.git\n\n## Iterating over files\n\n\t$ for f in *.txt; do echo $f; done  # bash\n\t% for f (*.txt) { echo $f; }        # same thing in zsh\n\n## Renaming\n\n\t% autoload -U zmv                    # load zmv first\n\t% zmv '(*).txt' '$1.html'\n\t% zmv -n '(*).txt' '$1.html'\n\t% zmv -n '(**/)(*).txt' '$1/$2.html'\n\nMore examples at [zshwiki](http://zshwiki.org/home/builtin/functions/zmv).\n\n## History navigation\n\n\t% zmv <UP>      # it will only iterate over history elements starting with zmv\n\t\n## Better history navigation\nIf you have oh-my-zsh installed then enable ``history-substring-search`` plugin (``~/.zshrc``):\n\n    plugins=(history-substring-search ...)\t\n    \nYou'll get even better context history navigation (with colors).\n\n## Locating stuff\n\t\n\t% which echo ls sh\n\t% whence echo ls sh\n\t% echo =ls\t\n\n## Various Prompts\n\nModify `~/.zshrc` from:\n\n\tZSH_THEME=\"robbyrussell\"\n\nto\n\n\tZSH_THEME=\"random\"\n\nEach new zsh will get random theme. You can see them all at [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/themes).\n\n## Custom hooks\n\n    # ~/.oh-my-zsh/custom/utils.zsh\n    # directory change hook\n    #\n    function chpwd; {\n        if [[ \"$PWD\" == \"/etc\" ]]; then\n    \t    echo \"You have entered /etc, don't break anything!\"\n        fi\n    }\n\t\nThen try it out:\t\n\t\n\t~% cd /etc\n    You have entered /etc, don't break anything!\n    /etc%\t\n\n\n# Reference\n1. [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)\n2. [ZSH Tips by ZZapper](http://www.rayninfo.co.uk/tips/zshtips.html)\n3. [10 zsh tricks you may not know...](http://chneukirchen.org/blog/archive/2008/02/10-zsh-tricks-you-may-not-know.html)\n4. [ZSH documentation](http://zsh.sourceforge.net/Guide/zshguide.html)\n5. [Advanced Bash programming](http://www.tldp.org/LDP/abs/html/)\n6. [Shell programming with bash: by example, by counter-example](http://matt.might.net/articles/bash-by-example/)\n\n# License\n\nDocument released under [Attribution-NonCommercial-ShareAlike 4.0 International](http://creativecommons.org/licenses/by-nc-sa/4.0/deed.en_US). In other words: noncommercial, requires attribution and must be reproduced with a similar license.\n"
  }
]