zsh चीटशीट
5.9आपके terminal के लिए ज़रूरी zsh shortcuts, tricks, और keybindings
हिन्दी: 2026-03-29
zsh macOS पर default shell है और Linux पर भी तेज़ी से बढ़ रहा है, और अच्छे कारण से — यह bash जो कुछ भी करता है वह सब लेता है और smarter completion, बेहतर globbing, और एक plugin ecosystem जोड़ता है जो आपके terminal को genuinely enjoyable बना सकता है। अगर आप बिना जाने zsh इस्तेमाल कर रहे थे (macOS Catalina का शुक्रिया), तो आप sports car first gear में चला रहे थे।
zsh की असली power उसके line editor में है। वे Ctrl और Alt key combos random नहीं हैं — वे Emacs-style editing से आते हैं, जो default mode है। हर बार जब आप line की शुरुआत पर jump करने के लिए Ctrl-a hit करते हैं, आप वही binding इस्तेमाल कर रहे हैं जो Emacs users 1970s से कर रहे हैं। अगर चाहें तो vi mode पर भी switch कर सकते हैं, लेकिन defaults से शुरू करें। एक बार internalize हो जाएँ तो surprisingly अच्छे हैं।
यह cheatsheet उस पर focus करती है जो आपको तुरंत तेज़ बनाएगा: line navigation ताकि arrow keys के लिए हाथ न बढ़ाना पड़े, history tricks जो commands दोबारा type करने से बचाएँ, globbing patterns जो zsh को आपके लिए files ढूंढने दें, और इतना oh-my-zsh ज्ञान कि productive environment setup हो जाए बिना options में डूबे। 400-page manual skip करके रोज़ काम आने वाली चीज़ें रख रहे हैं।
Line Navigation
ये default Emacs mode में काम करते हैं (यही आप इस्तेमाल कर रहे हैं जब तक explicitly vi पर switch नहीं किया)। इन्हें muscle memory में जला दें और हाथ कभी home row नहीं छोड़ेंगे।
History
आपकी shell history एक खज़ाना है। zsh default रूप से हज़ारों commands रखता है, और ये shortcuts उन्हें efficiently mine करने में मदद करते हैं 47 बार up arrow press करने के बजाय।
Globbing
यहाँ zsh bash को पीछे छोड़ देता है। zsh की globbing इतनी powerful है कि ज़्यादातर रोज़मर्रा file searches के लिए find की जगह ले सकती है। कोई pipes नहीं, कोई subshells नहीं, बस patterns।
Aliases
Aliases से zsh आपका अपना feel करता है। ये जानने लायक patterns हैं — specific aliases आप पर हैं, लेकिन ये forms सबसे ज़्यादा productivity unlock करते हैं।
Key Bindings
zsh का line editor (zle) पूरी तरह customizable है। किसी भी key को किसी भी action से rebind कर सकते हैं, और सैकड़ों built-in widgets चुनने के लिए हैं।
Vi Mode
अगर आप vim/nvim user हैं, तो vi mode zsh को घर जैसा feel कराता है। Normal mode, insert mode, और ज़्यादातर motions जो आप पहले से जानते हैं मिलते हैं।
oh-my-zsh Essentials
oh-my-zsh सबसे popular zsh framework है, और यह इसके लायक है। लेकिन 300+ plugins के साथ, config bloat करना आसान है। ये plugins और patterns हैं जो वाकई load करने लायक हैं।
Tips
अपने ~/.zshrc में setopt AUTO_CD जोड़ें और बस path type करके directories navigate कर सकते हैं — cd ज़रूरी नहीं। ऊपर जाने के लिए .. type करें, home पर jump करने के लिए ~/projects। एक बार इसकी आदत हो जाए, cd type करना wasted keystrokes लगता है।
zsh-autosuggestions plugin arguably सबसे बड़ा productivity boost है जो आप जोड़ सकते हैं। Type करते समय history पर based ghost text predictions दिखाता है। पूरी suggestion accept करने के लिए right arrow key press करें, या सिर्फ अगला word accept करने के लिए Alt-f। Install करें और सोचें कि इसके बिना कैसे काम चलता था।
Current command line अपने $EDITOR में खोलने के लिए Ctrl-x Ctrl-e इस्तेमाल करें (bind करने के बाद: autoload -z edit-command-line && zle -N edit-command-line && bindkey '^X^E' edit-command-line)। Pipes और loops वाले लंबे commands nvim में compose करना single terminal line से कहीं आसान है।
History properly configure करें। ~/.zshrc में ये जोड़ें और कभी command नहीं खोएंगे:
HISTSIZE=50000, SAVEHIST=50000, setopt SHARE_HISTORY (sessions में sync), setopt HIST_IGNORE_DUPS (consecutive duplicates skip करें), setopt HIST_IGNORE_SPACE (space prefix करें history से बाहर रखने के लिए — secrets वाले commands के लिए handy)।
zsh की recursive globbing (**/*) इतनी powerful है कि basic find usage replace कर सकती है। सभी TypeScript files चाहिए? ls **/*.ts। सभी .DS_Store files delete करनी हैं? rm -f **/.DS_Store। find . -name "*.ts" से तेज़ type होता है और याद रखना आसान है।
अगर Alt key combos आपके terminal में काम नहीं करते (macOS पर common), तो terminal preferences में "Use Option as Meta key" enable करें। iTerm2 में यह Profiles > Keys में है। Terminal.app में Settings > Profiles > Keyboard में है। इसके बिना, Alt-f, Alt-b, और Alt-d dead on arrival हैं।
Suffix aliases zsh का underrated feature हैं। ~/.zshrc में alias -s py=python3 जोड़ें और Python script बस filename type करके चला सकते हैं: python3 script.py के बजाय script.py। किसी भी extension के लिए काम करता है — .json को jq . से map करें, .md को markdown viewer से, .log को less से।