Customizing Your Zsh/Bash Prompt for Peak Productivity
Simple Shell Tweaks to Speed Up Daily Dev Work
If you use the terminal every day, even small improvements can save you a ton of time. This post shares a set of practical shell commands and shortcuts not fancy, not obscure, just genuinely useful. These functions and aliases are the kind that make you think, “Why didn’t I do this earlier?”
In this article, we'll explore how customizing your Zsh or Bash prompt can transform your command line experience and significantly boost your daily productivity.
1) Fuzzy Directory Jumper with fzf
Put this in .zshrc
or .bashrc
(requires fzf
installed)
j() {
cd "$(find . -type d 2>/dev/null | fzf)"
}
What It Does
Searches all directories starting from current path.
Opens an interactive fuzzy finder.
You pick one, and it instantly jumps (
cd
) to that directory.
Why It’s Useful
When you’re in a deep project structure (e.g.,
src/main/java/com/xyz/foo/bar
)You don’t remember full paths but remember partial names
Much faster than typing out or tab-completing
Example Usage
cd ~/myproject
j
You type “foo”, hit enter, and you’re inside src/main/java/com/xyz/foo
.
2. git_clean_merged
: Clean Up Merged Git Branches
Put this in .zshrc
or .bashrc
(One of my favourite)
git_clean_merged() {
git checkout main &&
git pull &&
git branch --merged main | grep -vE "^\*|main" | xargs -n 1 git branch -d
}
What It Does
Switches to
main
branch and updates it.Lists all local branches merged into
main
.Deletes them, except
main
and currently checked-out branch.
Why It’s Useful
Avoids clutter from dozens of stale branches.
Prevents accidental pushes or merges from outdated branches.
Keeps your local Git lean and focused.
Example Usage
git_clean_merged
After you’ve merged feature branches into main
via PRs, this clears them from local.
3. glog
: Pretty Git Log Summary (One-Liner Commit History)
Put this in .zshrc
or .bashrc
alias glog="git log --oneline --graph --decorate --all"
What It Does
Shows Git commit history as:
One-line summaries
With branch/tag info
With commit graph (
--graph
)
Why It’s Useful
Gives you a visual overview of branches and merges.
Great for understanding commit flows in large teams.
Replaces the cluttered full
git log
.
Example Usage
cd your-project/
glog
* 8a1b3c2 (HEAD -> feature/login) Add auth validation
* f72d1a1 (origin/main, main) Merge pull request #15
|\
| * 9bd9f77 Add unit tests
|/
* 72f3df8 Refactor user service
Use this before a rebase or merge to understand what’s going on.
4. killport
: Kill the Process on a Given Port
killport() {
lsof -ti tcp:$1 | xargs kill -9
}
What It Does
Finds the process ID (
PID
) of any process using a TCP port.Force-kills it.
Why It’s Useful
Common when local servers (Spring Boot, Node, etc.) don’t release ports.
Saves you from restarting the machine or hunting down PIDs manually.
Example Usage
killport 8080
Instantly kills the process blocking port 8080.
5. extract
: Smart File Extractor
What to Write in .zshrc
or .bashrc
extract () {
if [ -f "$1" ]; then
case "$1" in
*.tar.bz2) tar xjf "$1" ;;
*.tar.gz) tar xzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;;
*.tar) tar xf "$1" ;;
*.tbz2) tar xjf "$1" ;;
*.tgz) tar xzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;;
*.7z) 7z x "$1" ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
What It Does
A smart wrapper around various extraction tools (
tar
,unzip
,gunzip
, etc.)Automatically detects the file type based on the extension
Runs the appropriate command to extract the archive
Why It’s Useful
You no longer have to remember whether to use
tar xzf
,unzip
, or7z x
Great for developers downloading SDKs, logs, dumps, or open-source code
Avoids typing mistakes or wrong flags (like
-z
,-j
, etc.)
Example Usage
extract backup_2023.tar.gz
extract site_data.zip
extract compressed.7z
Instead of Googling “how to untar bz2” or typing the wrong command, just use extract
.
6. Fast Search for Text in Files
findin() {
grep -rnw '.' -e "$1"
}
What It Does
Uses
grep
to recursively search all files under the current directoryFlags:
-r
: recursive-n
: show line numbers-w
: match whole word-e
: pattern to search
Why It’s Useful
Lightning-fast way to search codebases, logs, configs
Especially handy when:
You’re not using an IDE
You forgot where a variable or config is defined
You’re dealing with unfamiliar code
Example Usage
findin "database_url"
./config/dev.env:3:DATABASE_URL=postgres://user:pass@localhost:5432/db
./src/config.js:17:const dbUrl = process.env.DATABASE_URL;
Faster and more controlled than ripgrep
, ack
, or even Ctrl+Shift+F
in VS Code in some cases.
7. Tree View of Directory Structure
alias t="tree -C -L 2"
(Ensure you have tree
installed: brew install tree
or sudo apt install tree
)
What It Does
Shows a colored, hierarchical view of current folder and its subfolders
-C
: color output-L 2
: only go 2 levels deep to keep it readable
Why It’s Useful
Quickly visualize folder structure of a project
See which directories contain what
Useful when joining a new repo or debugging broken imports
Example Usage
cd ~/myproject
t
Output
.
├── README.md
├── src
│ ├── main.py
│ └── utils
├── tests
│ └── test_main.py
Can be expanded:
alias t3="tree -C -L 3"
Or filtered:
tree -C -L 2 --matchdirs -P '*config*'
8. Find Shell History Commands Starting With xyz
hstart() {
history | grep -E "^ *[0-9]+ +$1"
}What It Does
history
: shows your shell command history (numbered)grep '^ *[0-9]+ *xyz'
: filters lines that start with optional spaces, a number, then the literal textxyz
Why It’s Useful
Helps you recall past long commands you don’t want to rewrite
Lets you track usage of your own custom scripts or aliases
Useful when you remember what the command started with but not the whole thing
hstart docker
Lists all commands from your history that started with docker
.
(It only matches commands that start with the word, not those containing it somewhere in the middle.)
These aren’t theoretical tricks - they’re battle-tested shortcuts that make real dev life easier. Drop them into your .bashrc
or .zshrc
, reload your shell, and feel the difference right away.
If you liked this, consider building your own little library of custom commands. The shell is still one of the most powerful tools we use daily - might as well make it work for you.