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 नहीं छोड़ेंगे।

Line Navigation
Ctrl-a
Line की शुरुआत पर jump करें
Ctrl-e
Line के अंत पर jump करें
Alt-f
एक word आगे जाएँ
Alt-b
एक word पीछे जाएँ
Ctrl-f
एक character आगे जाएँ
Ctrl-b
एक character पीछे जाएँ
Ctrl-w
Cursor से पहले word delete करें
Alt-d
Cursor के बाद word delete करें
Ctrl-k
Cursor से line के अंत तक kill (cut) करें
Ctrl-u
Cursor से line की शुरुआत तक kill (cut) करें
Ctrl-y
आखिरी killed text yank (paste) करें
Ctrl-t
Cursor से पहले दो characters swap करें
Ctrl-l
Screen clear करें (current line रहती है)
Ctrl-_
आखिरी edit undo करें

History

आपकी shell history एक खज़ाना है। zsh default रूप से हज़ारों commands रखता है, और ये shortcuts उन्हें efficiently mine करने में मदद करते हैं 47 बार up arrow press करने के बजाय।

History
Ctrl-r
History में reverse search करें (filter करने के लिए type करें)
Ctrl-s
History में forward search करें
Ctrl-p
पिछला command (Up arrow जैसा ही)
Ctrl-n
अगला command (Down arrow जैसा ही)
!!
पूरा आखिरी command repeat करें
sudo !!
आखिरी command sudo के साथ फिर चलाएँ (lifesaver)
!$
पिछले command का आखिरी argument insert करें
!^
पिछले command का पहला argument insert करें
!*
पिछले command के सभी arguments insert करें
!<string>
<string> से शुरू होने वाला सबसे recent command चलाएँ
!<n>
History से command number <n> चलाएँ
history
Recent command history दिखाएँ
history -10
आखिरी 10 commands दिखाएँ
fc
आखिरी command editing के लिए $EDITOR में खोलें

Globbing

यहाँ zsh bash को पीछे छोड़ देता है। zsh की globbing इतनी powerful है कि ज़्यादातर रोज़मर्रा file searches के लिए find की जगह ले सकती है। कोई pipes नहीं, कोई subshells नहीं, बस patterns।

Globbing
*
Current directory में कोई भी string match करें
**/*
सभी subdirectories में recursively files match करें
?
कोई भी single character match करें
[abc]
Listed characters में से कोई एक match करें
[a-z]
Range में कोई character match करें
[^abc]
List में नहीं होने वाला कोई character match करें
*.{js,ts}
.js या .ts से खत्म होने वाली files match करें (brace expansion)
**/*.py
Recursively सभी Python files ढूंढें
*(.)
सिर्फ regular files match करें (directories नहीं)
*(/)
सिर्फ directories match करें
*(@)
सिर्फ symlinks match करें
*(m-7)
पिछले 7 दिनों में modified files
*(Lk+100)
100 KB से बड़ी files
*(om[1,5])
5 सबसे हाल में modified files

Aliases

Aliases से zsh आपका अपना feel करता है। ये जानने लायक patterns हैं — specific aliases आप पर हैं, लेकिन ये forms सबसे ज़्यादा productivity unlock करते हैं।

Aliases
alias ll="ls -lah"
Simple command alias
alias -g G="| grep"
Global alias — command में कहीं भी काम करता है (ls G foo)
alias -g L="| less"
Less में pipe करने के लिए global alias
alias -g NE="2>/dev/null"
Errors suppress करने के लिए global alias
alias -s py=nvim
Suffix alias — file.py type करने से nvim में खुलती है
alias -s json=jq .
Suffix alias — data.json type करने से pretty-print होता है
alias -s md=glow
Suffix alias — terminal में markdown files render करें
unalias <name>
Alias हटाएँ
alias
सभी active aliases list करें
which <command>
दिखाएँ कि command या alias किसमें resolve होता है

Key Bindings

zsh का line editor (zle) पूरी तरह customizable है। किसी भी key को किसी भी action से rebind कर सकते हैं, और सैकड़ों built-in widgets चुनने के लिए हैं।

Key Bindings
bindkey
सभी current key bindings list करें
bindkey -e
Emacs key bindings इस्तेमाल करें (default)
bindkey -v
Vi key bindings पर switch करें
bindkey "^X^E" edit-command-line
Ctrl-x Ctrl-e bind करें $EDITOR में current line edit करने के लिए
bindkey "^[[A" history-search-backward
Up arrow current input से matching history search करे
bindkey "^[[B" history-search-forward
Down arrow current input से matching history search करे
bindkey "\e." insert-last-word
Alt-. पिछले command का आखिरी word insert करे
bindkey -l
Available keymaps list करें
zle -la
सभी available zle widgets list करें

Vi Mode

अगर आप vim/nvim user हैं, तो vi mode zsh को घर जैसा feel कराता है। Normal mode, insert mode, और ज़्यादातर motions जो आप पहले से जानते हैं मिलते हैं।

Vi Mode
bindkey -v
Vi mode enable करें
Esc
Normal mode पर switch करें
i
Insert mode में enter करें
a
Cursor के बाद insert mode में enter करें
0
Line की शुरुआत पर jump करें (normal mode)
$
Line के अंत पर jump करें (normal mode)
w / b
Word से आगे / पीछे जाएँ (normal mode)
dd
पूरी line delete करें
dw
Cursor से word के अंत तक delete करें
ci"
Quotes के अंदर change करें (और अन्य text objects)
v
Text select करने के लिए visual mode में enter करें
/
Command history search करें (normal mode)

oh-my-zsh Essentials

oh-my-zsh सबसे popular zsh framework है, और यह इसके लायक है। लेकिन 300+ plugins के साथ, config bloat करना आसान है। ये plugins और patterns हैं जो वाकई load करने लायक हैं।

oh-my-zsh Setup
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
oh-my-zsh install करें
plugins=(git z fzf)
~/.zshrc में plugins enable करें (space-separated list)
ZSH_THEME="robbyrussell"
~/.zshrc में theme set करें
omz update
oh-my-zsh latest version में update करें
omz plugin list
सभी available plugins दिखाएँ
omz theme list
सभी available themes दिखाएँ
source ~/.zshrc
Changes के बाद config reload करें
Recommended Plugins
git
100+ git aliases जोड़ता है (gst, gco, gp, gl, आदि)
z
Partial name से frequently visited directories पर jump करें
fzf
Ctrl-r / Ctrl-t से files, history, और बहुत कुछ fuzzy-find करें
zsh-autosuggestions
History पर based Fish-style suggestions (ghost text)
zsh-syntax-highlighting
Type करते समय commands color करता है — red मतलब typo
sudo
Current या last command में sudo जोड़ने के लिए Esc दो बार press करें
copypath
Current directory path clipboard पर copy करें
web-search
Terminal से ही Google/GitHub/Stack Overflow search करें

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_Storefind . -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 से।

Related Tools