Bash Editor Tips: Terminal Productivity for DevOps
Your bash editor is only as productive as your terminal skills. These tips help you work faster whether you use vim, VS Code, or any other editor.
For choosing the right editor, see our bash editor comparison.
Essential Readline Shortcuts
These work in bash, zsh, and most terminal applications.
Navigation
| Shortcut | Action |
|---|---|
Ctrl+A | Beginning of line |
Ctrl+E | End of line |
Alt+F | Forward one word |
Alt+B | Back one word |
Ctrl+XX | Toggle between start and current position |
Editing
| Shortcut | Action |
|---|---|
Ctrl+U | Delete to beginning of line |
Ctrl+K | Delete to end of line |
Ctrl+W | Delete previous word |
Alt+D | Delete next word |
Ctrl+Y | Paste deleted text |
Ctrl+T | Swap characters |
Alt+T | Swap words |
History
| Shortcut | Action |
|---|---|
Ctrl+R | Reverse search history |
Ctrl+G | Cancel search |
!! | Repeat last command |
!$ | Last argument of previous command |
!* | All arguments of previous command |
Terminal Multiplexers
Run multiple sessions in one terminal—essential for bash editing over SSH.
tmux Basics
# Start new session
tmux new -s work
# Split horizontally
Ctrl+B %
# Split vertically
Ctrl+B "
# Navigate panes
Ctrl+B arrow-key
# Detach
Ctrl+B d
# Reattach
tmux attach -t work
Useful tmux Configuration
Add to ~/.tmux.conf:
# Better prefix
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# Mouse support
set -g mouse on
# Vim-style pane navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Easy split keys
bind | split-window -h
bind - split-window -v
Command-Line Editing Mode
Switch between editing modes for your shell.
Enable Vi Mode
# In ~/.bashrc or ~/.zshrc
set -o vi
Now you have vim keybindings at the command line:
Escto enter command modeito insertw,b,0,$for navigationddto clear line
Enable Emacs Mode (Default)
set -o emacs
Bash History Optimization
Make history more useful.
Better History Settings
# In ~/.bashrc
# Bigger history
HISTSIZE=10000
HISTFILESIZE=20000
# Ignore duplicates and spaces
HISTCONTROL=ignoreboth
# Append instead of overwrite
shopt -s histappend
# Save after each command
PROMPT_COMMAND="history -a"
# Timestamp in history
HISTTIMEFORMAT="%F %T "
Search History Effectively
# Search for commands starting with 'kubectl'
history | grep "^.*kubectl"
# Interactive fuzzy search (with fzf)
Ctrl+R
Fzf: Fuzzy Finding Everywhere
Fzf transforms command-line productivity.
Installation
# macOS
brew install fzf
$(brew --prefix)/opt/fzf/install
# Ubuntu
sudo apt install fzf
Key Bindings
| Shortcut | Action |
|---|---|
Ctrl+T | Find files |
Ctrl+R | Search history |
Alt+C | Change directory |
Fzf with Your Bash Editor
# Open file in vim with fzf
vim $(fzf)
# Edit matching files
vim $(grep -l "pattern" *.sh | fzf)
Aliases for Common Tasks
Speed up your bash editing workflow.
# In ~/.bashrc
# Quick edit common files
alias bashrc='$EDITOR ~/.bashrc && source ~/.bashrc'
alias vimrc='$EDITOR ~/.vimrc'
# Directory shortcuts
alias runbooks='cd ~/repos/runbooks && ls'
alias scripts='cd ~/scripts && ls'
# Git shortcuts
alias gs='git status'
alias gd='git diff'
alias gc='git commit'
# Editor shortcuts
alias v='vim'
alias c='code .'
# Quick previews
alias bat='batcat' # Better cat
alias l='ls -lah'
Shell Prompt Optimization
A good prompt provides context without clutter.
Useful Prompt Elements
# Git branch in prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1='\u@\h:\w$(parse_git_branch)\$ '
Starship Prompt
Modern, fast, customizable:
# Install
curl -sS https://starship.rs/install.sh | sh
# Enable (add to ~/.bashrc)
eval "$(starship init bash)"
Terminal Emulator Features
Your terminal emulator affects productivity.
Recommended Features
- Tabs and splits: Multiple sessions in one window
- Search: Find text in scrollback
- Clickable links: Open URLs directly
- Font ligatures: Better code readability
Popular Options
| Terminal | Platform | Strengths |
|---|---|---|
| iTerm2 | macOS | Features, integration |
| Alacritty | Cross-platform | Speed, GPU rendering |
| Windows Terminal | Windows | Modern, customizable |
| Kitty | Cross-platform | Performance, features |
From Terminal to Runbook
These terminal tips make you faster in your bash editor. But individual commands scattered across history are hard to share.
Capture your workflows as runbooks. See our guide on saving terminal commands.
Making Terminal Work Executable
Stew bridges the gap between terminal productivity and team documentation. Your bash commands become executable runbook cells.
# Deploy with Health Checks
## Pre-deploy verification
```bash
kubectl get pods -n production
```
## Deploy
```bash
kubectl apply -f deployment.yaml
```
## Verify
```bash
kubectl rollout status deployment/app -n production
```
Your terminal expertise becomes team knowledge. Every command runs with a click.
Join the waitlist and share your terminal workflows.