Plain Bash, Zsh-flavored
A small collection of Bash scripts that bring the quality-of-life features people love
about Zsh — an informative prompt, a z-style
directory jumper, better history, and handy aliases — to plain Bash.
curl -fsSL https://raw.githubusercontent.com/4msar/zsh-like-bash/main/install | bash
Six independent scripts. Source only what you want.
prompt.sh
Two-line, color-coded prompt: shortened cwd, Git branch with dirty/clean status and ahead/behind counts, last command duration and exit status.
z.sh
A lightweight z command that jumps to frequently/recently used directories by partial name. No external dependencies.
history.sh
Saner Bash history defaults: dedup, larger history size, append instead of overwrite, multi-line command support.
completion.sh
Loads system Bash completion and enables Zsh-like conveniences: autocd and cdspell.
aliases.sh
Common shortcuts for navigation (.., ...), ls variants, and Git (gs, ga, gc, gp...).
functions.sh
Handy functions: mkcd, extract, git-branch-name, and the zlb-* management commands.
One command, or clone it yourself and pick what you want.
curl -fsSL https://raw.githubusercontent.com/4msar/zsh-like-bash/main/install | bash
Clones the repo to ~/.bash and appends a snippet to
~/.bashrc (between
# >>> zsh-like-bash >>> /
# <<< zsh-like-bash <<< markers) that sources
every *.sh file in ~/.bash/.
Re-running the installer later just pulls the latest changes.
source ~/.bashrc
git clone https://github.com/4msar/zsh-like-bash.git ~/.bash
echo '# >>> zsh-like-bash >>>' >> ~/.bashrc
echo "source ~/.bash/init" >> ~/.bashrc
echo '# <<< zsh-like-bash <<<' >> ~/.bashrc
Pick and choose which files to source — each script is independent.
Every command, function, and alias zlb adds to your shell.
Records every directory you visit (via a hook in prompt.sh's
PROMPT_COMMAND) into ~/.bash/z-data/directories.
Requires prompt.sh to be sourced too.
| z foo | Jump to the best-matching visited directory containing "foo" |
| z foo bar | Match a directory containing both "foo" and "bar" |
| z | Go home |
| z - | Go to the previous directory (like cd -) |
| z /abs/path | Behaves like cd /abs/path |
| generate_password | Generate a random password (openssl rand -hex 16) |
| clear_git_branches | Fetch and prune, then force-delete local branches whose upstream is gone |
| remove_ds_store | Recursively delete .DS_Store files from the current directory |
| zlb-update | git pulls the latest zsh-like-bash changes into its install directory |
| zlb-help | Print available functions and aliases. Use zlb-help --aliases to list just the Git/nav aliases |
| .. | cd .. |
| ... | cd ../.. |
| .... | cd ../../.. |
| ll | ls -lah --color=auto |
| la | ls -A --color=auto |
| l | ls -CF --color=auto |
| cls | clear |
| grep | grep --color=auto |
| myip | Show your public IP details via ipinfo.io |
| myipconfig | Show full IP config JSON via ifconfig.me |
| gs / gst | git status |
| ga | git add |
| gaa | git add --all |
| gc | git commit |
| gcm | git commit -m |
| gp / gpl | git push / git pull |
| gl | git log --oneline --graph --decorate --all |
| gd / gds | git diff / git diff --staged |
| gb / gba | git branch / git branch -a |
| gco / gsw | git checkout / git switch |
| gcb | git switch -c |
| gr / grs | git restore / git restore --staged |
shopt and standard Bash builtins)bash-completion package (optional, for completion.sh)