How to Set Up a Productive Terminal From Scratch Properly
Build a productive terminal on a new machine: history, readline, prompt, fuzzy search, tmux and a dotfiles repository, with startup time kept low.

The default terminal is usable, and a few settings change how much it costs you to find a command you ran last week, jump to a project or keep a session alive over a bad connection. The trap is the opposite one: pasting a stranger's two-hundred-line config, and ending with a shell that takes a second to open and breaks when something updates. This is a short, ordered setup, with the reasons, for Bash on Linux or macOS. It begins the developer terminal setup guide; the next posts cover fonts and themes and consistent script formatting.
The settings are for Bash 5.2 on Debian 13; the tools are the Debian packages fzf, ripgrep, bat, zoxide and tmux.
1. History that remembers
HISTSIZE=100000
HISTFILESIZE=200000
HISTCONTROL=ignoreboth:erasedups
shopt -s histappend
PROMPT_COMMAND='history -a'A bigger history and histappend make terminals share one file instead of the last one closing overwriting the rest. history -a in PROMPT_COMMAND writes each command as it runs, so a crash does not lose it. ignoreboth skips duplicates and commands that start with a space. Be aware that a long history file also holds anything sensitive you typed, as keeping secrets out of shell history covers.
2. Readline: search by prefix
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on
With these, typing git and pressing the up arrow cycles through earlier commands starting with git, instead of everything. Completion lists matches on the first Tab and ignores case. These are read by every program that uses readline, not only Bash.
3. Tools that earn their place
sudo apt install fzf ripgrep bat zoxide tmux| Tool | What it does | Initialize with |
|---|---|---|
fzf | Fuzzy search for history (Ctrl+R), files (Ctrl+T), directories (Alt+C) | eval "$(fzf --bash)" (fzf 0.48 and later) |
zoxide | Jump to a frequently used directory with z name | eval "$(zoxide init bash)" |
ripgrep | Fast recursive search that respects .gitignore | Nothing; use rg |
bat | cat with syntax highlighting; the binary is batcat on Debian and Ubuntu | alias bat=batcat |
tmux | Sessions that survive disconnects, panes, windows | ~/.tmux.conf |
Do not add what you won't use. Each tool is a thing to install on every new machine and a line that runs at startup.
4. A prompt that tells you something
eval "$(starship init bash)"Starship is one binary configured by ~/.config/starship.toml, showing the Git branch, the exit status of the last command and the duration of slow ones. A plain prompt works as well if it carries the last exit status: PS1='\u@\h:\w [$?]\$ '. The point is to see failure without running echo $?.
5. tmux in one paragraph
set -g mouse on
set -g history-limit 50000
set -g default-terminal "tmux-256color"
set -as terminal-features ',xterm-256color:RGB'
tmux new -As work attaches to a session named work, or creates it. Detach with Ctrl+B then D; the session and its processes keep running on the server, which is what protects long jobs from a dropped SSH connection. The last two lines turn on correct colors, for tmux 3.2 and later.
6. Keep it in a repository
mkdir -p ~/dotfiles && cd ~/dotfiles && git init
mv ~/.bashrc ~/.inputrc ~/.tmux.conf .
ln -s ~/dotfiles/.bashrc ~/.bashrcSymbolic links point the usual locations into a Git repository, so a new machine is a clone and a few links. Write a small install script that links each file and refuses to overwrite a real one. Do not commit secrets: keep machine-specific values in a file such as ~/.bashrc.local that is ignored and sourced if it exists.
7. Measure startup
time bash -i -c exitEach new terminal runs your config. Tools that initialize version managers (nvm, pyenv) are the usual cause of delay; load them on first use with a small function. See how Bash reads startup files for what runs where.
What the history settings do, tested
History is the cheapest productivity tool in the shell, and its settings are easy to get wrong. The variable HISTCONTROL decides what is saved: ignorespace skips lines that begin with a space, ignoredups skips a line identical to the previous one, and ignoreboth does both. Use the leading space for a command that contains a secret you do not want recorded, and test that it works in your shell before you rely on it. The run adds three entries by hand and then lists what was kept (Bash 5.2.37).
HISTCONTROL=ignoreboth
history -c
history -s "echo one"
history -s " echo secret"
history -s "echo one"
history | sed 's/^ *[0-9]* *//'echo one
Only one entry survived: the space-led line was dropped by ignorespace, and the second echo one was dropped as a duplicate of the line before it, once the first was recorded. If you want the history shared between terminals, add shopt -s histappend and PROMPT_COMMAND='history -a', which append each command to the file as it runs and not at exit. Then a crashed terminal loses nothing.
What startup costs, measured
Every line in your startup file runs each time a shell starts, and a slow tool initialization is paid on every new tab. Measure the cost before you add anything: time bash -i -c exit starts an interactive shell, runs the startup files and leaves. As a test of the method, a startup file that only sleeps for 0.3 seconds, run with the interactive flag, was compared with a shell started without any startup file.
time bash --rcfile slowrc -i -c exit
time bash --norc -i -c exitslow rc: 0.30s
no rc: 0.001s
The bare shell starts in about a millisecond. All the rest of what you wait for is your own configuration, so a prompt that takes a quarter of a second to appear has a quarter second of startup commands. Version managers, cloud CLIs' completion scripts and prompt frameworks are the usual cost. Defer them: load completion on first use, and initialize a version manager with its lazy mode. Check the time again after each change. A startup under 100 milliseconds feels instant, and over 300 starts to be noticed.
Prompts that cost a process
A prompt that runs git status on every redraw stalls in a large repository, since the command may take a second. If your prompt shows the branch, use a fast path: read .git/HEAD directly, or use the shell's built-in __git_ps1 helper with its status flags turned off, which reads files instead of walking the tree. Prompt frameworks such as starship compile to a fast binary and cache work, and still run once per prompt, so measure the delay with a large project open. The setting that matters is a timeout: configure the prompt to give up after a short time and show nothing rather than make you wait.
Limits
This is Bash-centric. Zsh and fish have their own equivalents and more built-in features. Treat the list as a base, not a destination: change one thing at a time and keep what you notice you miss. The tools are documented at fzf and Starship, and the readline syntax in the Readline user manual.


