← Back to blog

Bash Editor Tips: Terminal Productivity for DevOps

· 5 min read · Stew Team
basheditorterminalproductivity

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.

ShortcutAction
Ctrl+ABeginning of line
Ctrl+EEnd of line
Alt+FForward one word
Alt+BBack one word
Ctrl+XXToggle between start and current position

Editing

ShortcutAction
Ctrl+UDelete to beginning of line
Ctrl+KDelete to end of line
Ctrl+WDelete previous word
Alt+DDelete next word
Ctrl+YPaste deleted text
Ctrl+TSwap characters
Alt+TSwap words

History

ShortcutAction
Ctrl+RReverse search history
Ctrl+GCancel 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:

  • Esc to enter command mode
  • i to insert
  • w, b, 0, $ for navigation
  • dd to 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

ShortcutAction
Ctrl+TFind files
Ctrl+RSearch history
Alt+CChange 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.

  • Tabs and splits: Multiple sessions in one window
  • Search: Find text in scrollback
  • Clickable links: Open URLs directly
  • Font ligatures: Better code readability
TerminalPlatformStrengths
iTerm2macOSFeatures, integration
AlacrittyCross-platformSpeed, GPU rendering
Windows TerminalWindowsModern, customizable
KittyCross-platformPerformance, 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.