Introduction
I spend a lot of time in the terminal. Over the years, I’ve picked up habits and tools that make me faster and less error-prone. Here are the tips I actually use daily.
1. Master Keyboard Shortcuts
Most terminals support Emacs-style shortcuts by default. Learn these:
-
Ctrl + A/Ctrl + E– jump to start/end of line -
Ctrl + U– delete from cursor to start -
Ctrl + K– delete from cursor to end -
Ctrl + W– delete word backward -
Ctrl + R– reverse search through history
Practice until they’re muscle memory. It saves seconds on every command.
2. Use History Expansion
Bash and Zsh let you reuse previous commands quickly:
-
!!– repeat last command (addsudo !!to rerun with sudo) -
!$– last argument of previous command -
!^– first argument of previous command -
!npm– run the most recent command that starts with “npm”
Example:
$ mkdir project
$ cd !$
Enter fullscreen mode Exit fullscreen mode
3. Fuzzy Find Everything
Install fzf – a fuzzy finder that works with files, history, processes, and more.
Key bindings after install:
-
Ctrl + T– paste selected file/directory path -
Ctrl + R– fuzzy search command history (better than default) -
Alt + C– fuzzy cd into subdirectories
You can combine with ** in Zsh for tab completion:
$ vim **<TAB> # fuzzy find file
$ cd **<TAB> # fuzzy find directory
Enter fullscreen mode Exit fullscreen mode
4. Navigate with Autojump or Zoxide
Stop typing cd ../../... Use z (via zoxide) to jump to directories by name:
$ z projects # jumps to /home/user/work/projects
$ z mydoc # jumps to /home/user/Documents/mydoc
Enter fullscreen mode Exit fullscreen mode
It learns your most used directories. Install zoxide once, add eval "$(zoxide init zsh)" to your .zshrc, and you’re set.
5. Simplify Git with Aliases
Add these to your .gitconfig:
[alias]
co = checkout
br = branch
ci = commit
st = status
unstage = reset HEAD --
last = log -1 HEAD
lg = log --oneline --graph --all
Enter fullscreen mode Exit fullscreen mode
Then use git co instead of git checkout. Saves a lot of keystrokes.
6. Batch Rename with rename
Instead of writing loops, use the Perl rename command (install via brew install rename or apt install rename):
# Rename all .jpeg to .jpg
$ rename 's/\.jpeg$/.jpg/' *.jpeg
# Add prefix to all files
$ rename 's/^/backup_/' *
Enter fullscreen mode Exit fullscreen mode
7. Use bat Instead of cat
bat is cat with syntax highlighting and line numbers. It also integrates with less for paging.
$ bat script.py # shows file with colors
Enter fullscreen mode Exit fullscreen mode
Set export BAT_THEME="Dracula" in your shell config.
8. Quick File Creation with touch and mkdir -p
Create nested directories and files in one go:
$ mkdir -p project/src/components && touch project/src/components/Header.jsx
Enter fullscreen mode Exit fullscreen mode
Or use a one-liner with brace expansion:
$ mkdir -p {src,test}/{components,utils}
Enter fullscreen mode Exit fullscreen mode
9. Pipe to Clipboard
Copy command output directly to clipboard:
$ cat file.txt | pbcopy # macOS
$ cat file.txt | xclip -selection clipboard # Linux
Enter fullscreen mode Exit fullscreen mode
I alias clip to the appropriate command for my OS.
10. Use Tmux for Session Management
Tmux lets you keep terminals running even after you close your window. Basic commands:
-
tmux new -s mysession– create named session -
Ctrl + B d– detach -
tmux attach -t mysession– reattach -
Ctrl + B c– new window -
Ctrl + B %– split vertically -
Ctrl + B "– split horizontally
I never lose my work when my SSH connection drops.
Conclusion
Start with one or two tips. Install fzf and zoxide first – they give the biggest productivity boost. Then gradually add aliases and shortcuts. Your future self will thank you.
답글 남기기