Bash profile shortcuts and terminal customizations
Trisha Aguinaldo
Posted on December 23, 2019
The type of work I do requires me to switch between git branches constantly. Over time, I've built a list of shortcuts and customizations that made my life easier.
Read along if you want to customize your terminal output and copy & paste some useful shortcuts for docker and git.
Jazz up your terminal
Add an emoji on your user name and show the relative path of your directory
Turn this:
trisha @ /codewars $
Into this:
trisha🔥 @ ~/projects/codewars $
- Copy and Paste into your .bash_profile and re-open your shell:
export PS1="\u🔥 @ \w $ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
PS1 will determine the display path. You can even add an emoji as seen above (🔥).
CLICOLOR will determine the output color theme
LSCOLORS determines the background.
Terminal profiles and window arrangements
Use a terminal emulator (like iTerm2) to quickly launch profile configurations. Useful if you have a couple of full-stack projects you're working on and want to launch the application using a single command.
CTRL + SHIFT + R
will quickly open a saved window arrangement with whatever profiles you configure it with. It'll look something like this:
^ Notice those tabs, eh?? What’s so cool about it is that you can save full-stack repos in a window arrangement once and then switch tabs without needing to change directories constantly. What a time saver! :D
Pro-tip: You can also add a starting script on your saved profile. I typically add cd <file_path>; git fetch; git status;
so when I open the profile, it’s already in the correct directory and it tells me the status of my current branch.
iTerm2 link https://iterm2.com/index.html
Terminal color schemes
If you want your bash outputs to look better, try out iTerm2's themes. It makes a difference when you are reading the logs and error stacks.
- Color Schemes https://github.com/mbadolato/iTerm2-Color-Schemes
- My fav (dracula): https://github.com/mbadolato/iTerm2-Color-Schemes/blob/master/schemes/Dracula.itermcolors
You'll want to download the .txt
file of your color scheme and then upload it on your iterm2 preferences < profiles < colors < color schemes
:
Shortcuts / Aliases
Here's a list of useful git and docker aliases that I use daily. It's super helpful especially when your repos have submodules that you need to update daily.
# ----------------------
# Git Aliases
# ----------------------
alias upstream='git push --set-upstream origin'
alias ga='git add -A'
alias gb='git branch'
alias gbd='git branch --D '
alias gcm='git commit --message'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gcod='git checkout development'
alias gd='git diff'
alias glg='git log --graph --oneline --decorate --all'
alias gp='git pull'
alias gs='git status'
alias gf='git fetch'
alias grh='git reset --hard'
# ----------------------
# Git Submodule ForEach Aliases
# ----------------------
alias gsf='git submodule foreach'
alias gcos='git submodule foreach git checkout'
alias gcods='git submodule foreach git checkout development'
alias gfs='git submodule foreach git fetch'
alias gss='git submodule foreach git status'
alias gbs='git submodule foreach git branch'
alias gps='git submodule foreach git pull'
alias grhs='git submodule foreach git reset --hard'
# ----------------------
# Docker Aliases
# ----------------------
alias dc='docker-compose'
alias dcb='docker-compose up --build'
alias dps='docker ps -a'
alias drm='docker container rm'
Posted on December 23, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.