DEV Community


Customising our bash shell

Leo Lanese
I'm a passionately curious Front-end Engineer. I like sharing what I know, and learning what I don't. London, UK. @leolaneseltd
Updated on ・14 min read

Alt Text
image: Leonora Cavalieri

What is the bash_profile

bash is a shell: a command interpreter. The main purpose of bash is to allow you to interact with the computer's operating system so that you can accomplish whatever you need to do, "bash_profile" is a configuration file for the bash shell.

A cool common bash_profile

The idea is to share best practices, suggestions, tricks and keep the same profile across multiple development platforms easily cloning from the repository that we can share across projects and working stations we control, making the interface more familiar or maybe just take few shortcuts and create your own custom one. Hopefully, you will find some of them useful.

Alt Text
running: git-log2, git-log3 and git-log4 alliases

System Operation versions

MAC version:

A typical install of OSX won't create a .bash_profile for you.
When you want to run functions from your command line, this is a must-have.


MAC version setup

Startup Terminal
Type: "cd ~/" to go to your home folder
Type: "touch .bash_profile" to create your new file.
Edit: .bash_profile with your favorite editor (or you can just type "open -e .bash_profile" to open it in TextEdit.
Type: ". .bash_profile" to reload .bash_profile and update any functions you add (reload by the system)

Commands and alliases:

edit bash_profile

open -e ~/.bash_profile

if you don't have this file, create it!

touch ~/.bash_profile

paste the bash_profile

reload profile

. ~/.bash_profile
// from now on we will use the bash_profile
To edit: "edit_profile"
to reload: "reload_profile" (reload by using bash_profile)

Windows version setup:

Note: Use double quotes instead of a single one.

git config --global "commit -v"
 git config --global alias.log "log --pretty=oneline"
 git config --global alias.log1 "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

Ready to go

The commands you see there will map 1:1 to other UNIX-based development environments (e.g. Linux or the Windows 10 Linux Bash Shell).

Alt Text
running: network allias

Be aware that in some cases, the specific commands for a specific platform are slightly different from the commands I used. Now we ready to go, all we need to do is open the bash file and paste the content from the bash_file:

A complete bash_profile (Github link down below. Have a suggestion? Please create a Pull/Request)

#   ------------------------------------------------------------
export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"
export PATH="/usr/local/bin:$PATH"
export PATH="/usr/bin:$PATH"
export PATH="/usr/local/bin:$PATH"
export LC_CTYPE="en_UK.UTF-8"
export LC_ALL="en_UK.UTF-8"

# Allow npm install -g without needing sudo
# This is that a placeholder for us to fill in, like I'd set it to "$HOME/.npm"
npm config set prefix $dir

# nvm
#   ------------------------------------------------------------
# node version(s) active on this computer
alias node_versions=' nvm ls '

#   ------------------------------------------------------------
# export JAVA_HOME="$(/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin)"
alias java_jre='/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java'

#   ------------------------------------------------------------
alias npmOld=" npm outdated " 
alias npmNot=" npm prune " 
alias npmAllDependencies=" npm shrinkwrap "
alias npmV3=" npm install -g npm@3 "

## Angular Version
alias ngv='ng v | grep 'Angular:''

## MAC commands
#   ------------------------------------------------------------
alias showExt=" defaults write NSGlobalDomain AppleShowAllExtensions -bool true "
alias hideAll=" defaults write AppleShowAllFiles true "
alias showPath=" defaults write _FXShowPosixPathInTitle -bool true "
alias showLIbrary=" chflags nohidden ~/Library "

alias setBootVolume=" bless --mount "/path/to/mounted/volume" --setBoot "
alias showAll=" diskutil list "
alias hideFolder=" chflags hidden /path/to/folder/ "
alias clearFontCache="
    atsutil databases -removeUser && \
    atsutil server -shutdown && \
    atsutil server -ping"
alias macScreen=" system_profiler SPDisplaysDataType | grep Resolution "
alias lock=" /System/Library/CoreServices/Menu\ Extras/ -suspend " 
alias bell=" tput bel "
alias show_all="defaults write AppleShowAllFiles TRUE && killall Dock"
alias hide_all='defaults write ShowAllFiles FALSE  && killall Dock'
alias notification_center="launchctl unload -w /System/Library/LaunchAgents/ killall NotificationCenter"

## root commands
#   ------------------------------------------------------------
alias rootMode=" dsenableroot "
alias su=" sudo su "

## index commands
#   ------------------------------------------------------------
alias disable=" Indexingmdutil -i off -d /path/to/volume "

# Show hidden files 
alias l.='ls -d .* --color=auto'

## MAC diagnosis commands
#   ------------------------------------------------------------
alias macScan=" sudo sysdiagnose -f ~/Desktop/ "
alias macInfo=" networksetup -listallhardwareports "
alias showOSX=" sw_vers "
alias macCore=" sysctl -n machdep.cpu.brand_string "
# Wakeup sleeping servers (replace mac with your actual server mac address)
alias wakeupnas01='/usr/bin/wakeonlan 00:11:32:11:15:FC'

# Printer
#   ------------------------------------------------------------
alias dontSleep=" caffeinate -u -t 3600 "
alias goSleep=" sudo pmset sleep 5 "
alias checkSleep=" sudo systemsetup -getcomputersleep "

# Audio
#   ------------------------------------------------------------
alias mute=" osascript -e 'set volume output muted true' "
alias noMute=" osascript -e 'set volume output muted false' "
alias audio1=" osascript -e 'set volume 1' "
alias audio2=" osascript -e 'set volume 2' "
alias audio3=" osascript -e 'set volume 3' "
alias audio4=" osascript -e 'set volume 4' "
alias audio5=" osascript -e 'set volume 5' "
alias audio6=" osascript -e 'set volume 6' "
alias audio7=" osascript -e 'set volume 7' "

# Printer
#   ------------------------------------------------------------
alias wifyPassword=" security find-generic-password -D 'AirPort network password' -a 'SSID' -gw "
alias wirelessScan=" airport -s "
alias said=" /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}' "
alias clearPrinterQueue=" cancel -a - "

#   ------------------------------------------------------------
alias secureDelete=" srm -r /path/to/file " 

# Disk Use
#   ------------------------------------------------------------
alias list=" du -h * " 

#   Change Prompt
#   ------------------------------------------------------------
echo -n -e "\033]0;LeoLaneseltd\007"
echo -e "Kernel Information: " ;uname -smr
echo -e "${COLOR_BROWN}"; bash --version
echo -ne "${COLOR_GRAY}Uptime: "; uptime
echo -ne "${COLOR_GRAY}Server time is: "; date  

## dev LESS (lessc: npm install -g less) preprocessors
#   ------------------------------------------------------------
alias allwms="find ~/Sites/ -name '*.less' -exec lessc {} \; > ~/Sites/;"

## instead doing this I can use Grunt: Compile LESS directly and copy into deployment CSS folder directory.
#   ------------------------------------------------------------
alias wms="lessc ~/Sites/ > ~/Sites/;
           lessc ~/Sites/ > ~/Sites/;

## dev port
## find all .less and combined them into 1 CSS.
#   ------------------------------------------------------------
alias allport="find ~/Sites/ptf/less/ -name '*.less' -exec lessc {} \; > ~/Sites/ptf/css/combined.css;"

## instead doing this I can use Grunt: Compile LESS directly and copy into deployment CSS folder directory.
#   ------------------------------------------------------------
alias port="lessc ~/Sites/ptf/less/grid.less > ~/Sites/ptf/css/grid.css;
            lessc ~/Sites/ptf/less/mindex.less > ~/Sites/ptf/css/mindex.css;

## dev rsyncs
#   ------------------------------------------------------------
alias sync="rsync -avp --stats --prune-empty-dirs --exclude='*~' --exclude='.DS_Store' /Users/llanese/Sites/ /Volumes/;
            rsync -avp --stats --prune-empty-dirs --exclude='*~' --exclude='.DS_Store' /Users/llanese/Sites/ /Volumes/;

## all together
#   ------------------------------------------------------------
alias go="less sync"
alias texttofile="say -o urgentAssistance.aiff -v 'Kate' 'Your status has been updated to Urgent Assistance'"

## shortcuts & directions
#   ------------------------------------------------------------
alias  rm='rm -rfv'
alias  root="cd ~/Documents/root"
alias  goto_myP="goto_web; cd myProject"
alias  l="ls -la"
alias  ls="ls -aFhlG"
alias  ll="ls -l" 
alias  ls='ls -GFh'
alias  search=grep
alias  ..="cd .."
alias  ...="cd ../.."
alias  h="history"
alias  dh="sqlite3 ~/Library/Preferences/* 'select LSQuarantineDataURLString from LSQuarantineEvent'"
alias  ddh="sqlite3 ~/Library/Preferences/* 'delete from LSQuarantineEvent'"
alias  used="defaults write persistent-others -array-add '{ "tile-data" = { "list-type" = 1; }; "tile-type" = "recents-tile"; }'; killall Dock"

## automatic tasks manages shortcuts
#   ------------------------------------------------------------
alias bower_dependencies="grunt bower-install-simple; bower update"

## git
#   ------------------------------------------------------------
# list remote branches
alias git-remote=" git branch -r "

# delete all local branches but master, develop and staging
alias git-purge=' git branch --merged | grep -v "\*" | grep -v "master" | grep -v "develop" | grep -v "staging" | xargs -n 1 git branch -d '

# Git remote branches and last commit
alias git-remote-branches=" git for-each-ref --sort=-committerdate refs/remotes/origin --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))' "

alias git-change-to-push=" git diff --stat --patch origin master "
alias git-config=" cat .git/config "
alias git-end-sprint=" git branch | grep -v 'master' | xargs git branch -D "
alias git-merge=" git difftool "
alias git-branch=" git branch -a "
alias git-log1=" git log --graph --oneline --all --decorate --color "
alias git-log2=" git log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short "
alias git-log3=" git log --pretty=oneline "
alias git-log4=" git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit "
alias git-log5=" git whatchanged -3 -p "
alias git-users=" git log --format='%aN' | sort -u "
alias git-diff=" git log -p "
alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gd='git diff'
alias go='git checkout '
alias gk='gitk --all&'
alias gx='gitx --all &'
alias git-i=" git add -i "
alias git-me=" git log --author=LeoLanese "
alias git-remote=" git remote -v "
alias git-clean=" find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch; 
        git config --global core.excludesfile ~/.gitignore;
        echo .DS_Store >> ~/.gitignore "
alias git-all-users='git log --format='%aN' | sort -u '
alias git-tasks=' grep --exclude-dir=.git -rEI "TODO|FIXME" . 2>/dev/null '

#alias git-last='for k in 'git branch|sed s/^..//';do echo -e 'git log -1 --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" "$k"'\\t"$k";done|sort'

alias git-ignore=' find . \( -type d -empty \) -and \( -not -regex ./\.git.* \) -exec touch {}/.gitignore \; '
alias git-undelete=' git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file" '
alias git-idea=' git rm -r --cached .idea '
alias n=' NODE_ENV=development grunt server '
alias sprint-start=" git branch -D 'git branch | grep -E 'IVMA-..*'' "  
alias contributors=' git shortlog -sn '
alias git-name=' git config '
# Revert All Local Changes
alias git-reverse=' git checkout . '
# Show changes
alias git-show=' git diff --staged '
# Modify The Most Recent Commit
alias git-commits=' git commit --amend '
# Interactively Add Selected Parts of Files
alias git-parts=' git add -p '
# Interactively Stash Selected Parts of Files
alias git-stash=' git stash -p '
# Stash with untracked
alias git-tracks=' git stash -u '
# Interactively Revert Selected Parts of Files
alias git-revert=' git checkout -p '
# Switch to Previous Branch
alias git-switch=' git checkout - '
# Rename Branches Locally
alias git-rename=' git branch -m old-name new-name '
# Open All Files with Conflicts at Once
alias git-open=' git diff --name-only --diff-filter=U | uniq  | xargs $EDITOR '
# What changed in the last 2 weeks?
alias git-whatchanged='  git whatchanged —-since="2 weeks ago" '
# Optimize the repository locally
alias git-gc=' git gc --prune=now --aggressive '
# git manual & help
alias git-help=' git help workflows '

## ports
#   ------------------------------------------------------------
alias check_open_ports="lsof -Pi | grep LISTEN"
alias check_port="lsof -i :8888"
alias check_establish="lsof -i | grep -i estab"

# Watch Network Traffic
#   ------------------------------------------------------------
alias network=" nettop -m route "

## aliases
#   ------------------------------------------------------------
# Ethernet Address
alias get_macaddress=' networksetup -getmacaddress Wi-Fi '
# public IP
alias ip='curl -s'
# public IP
alias ip2='curl'
# header
alias header='curl -I'
alias validate_json='curl -s "" | python -m json.tool | less -R'
# flushDNS:     Flush out the DNS Cache
alias flushDNS='dscacheutil -flushcache'    
# lsock:        Display open sockets
alias lsock='sudo /usr/sbin/lsof -i -P'   
# lsockU:       Display only open UDP sockets
alias lsockU='sudo /usr/sbin/lsof -nP | grep UDP'  
# lsockT:       Display only open TCP sockets
alias lsockT='sudo /usr/sbin/lsof -nP | grep TCP'   
# ipInfo0:      Get info on connections for en0
alias ipInfo0='ipconfig getpacket en0'    
 # ipInfo1:      Get info on connections for en1
alias ipInfo1='ipconfig getpacket en1'     
 # openPorts:    All listening connections
alias openPorts='sudo lsof -i | grep LISTEN'   
# showBlocked:  All ipfw rules inc/ blocked IPs
alias showBlocked='sudo ipfw list'                  
alias crazy=" LC_ALL=C tr -c '[:digit:]' ' ' < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR='1;32' grep --color '[^ ]' "
# alias matrix=" yes 'c=(" " "  " "   " 0 1); printf "${c[RANDOM%5]}"' | bash "
alias make_svg=' open '

## aliases validate JSON
#   ------------------------------------------------------------
alias JSONValidate=" open "
alias JSONTools=" open "

## aliases Mock RestAPI (local and remote)
#   ------------------------------------------------------------
alias mockRestAPI1=" open " 
alias mockRestAPI2=" open "
alias mockRestAPI3=" open "
alias mockRestAPI4=" open "
alias mockRestAPI4=" open "

## aliases pouchDB and Futon (PouchDB UI)
#   ------------------------------------------------------------
alias db_alive=' curl | python -m json.tool '
alias db=' curl -X GET | python -m json.tool '
alias db_put=' curl -X PUT | python -m json.tool '
alias db_delete=' curl -X DELETE '
alias db_insert=' curl -H "Content-Type: application/json" --data @tt.json '
alias db_restart=' curl -X POST http://localhost:5984/_restart -H 111 "Content-Type: application/json" '

## the "qp" alias ("que pasa")
#   ------------------------------------------------------------
alias qp="ps auxwww"

## Python Server
#   ------------------------------------------------------------
# run a python server
alias server='python -m SimpleHTTPServer 8888'
# dump to :simple http server to dump request headers
alias dump=" curl -s -H 'X-Something: test' localhost:8888 > /dev/null "

# mongoDB
#   ------------------------------------------------------------
alias mon="mongod --dbpath /Users/{user}/met/data/db --rest"

## fun
#   ------------------------------------------------------------
alias radio=" open "
alias radio2="  open " 
# play all music files from the current directory
alias playwave='for i in *.wav; do mplayer "$i"; done'
alias playogg='for i in *.ogg; do mplayer "$i"; done'
alias playmp3='for i in *.mp3; do mplayer "$i"; done'

# IT dev essential shortcuts
#   ------------------------------------------------------------
## BS3 components
alias bs3_1=" open "
alias bs3_2=" open " 
alias bs3_3=" open "
alias bs3_4=" open "
alias bs3_5=" open "
alias bs3_6=" open " 

## BS4 components
alias bs4_1=" open "

## BS3 grids
alias grid1=" open "
alias grid2=" open "
alias grid3=" open "
alias grid4=" open "

## fonts/icons components
alias icons=" open "
alias icons2=" open "

## AJS best practices
alias papajuan=" open "

## handy shotcuts to bookmark
alias pass=" open chrome://settings/cookies "
alias traceur=" open "
alias caniuse=" open " 
alias es6features=" open "
alias json=" open "
alias regexp=" open " 
alias images=" "

## personal projects
#   ------------------------------------------------------------
alias follow_me1=" open" 
alias follow_me2=" open "
alias follow_me3=" open "

## testing
#   ------------------------------------------------------------
alias ios6=" open /Applications/\ "
alias ios5=" open /Applications/ "
alias ios3=" open /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone "
alias safari=" open -a safari http://localhost:9000/ "
alias chrome=" open -a '/Applications/Google' "
alias lynx=" lynx '' "
alias run_casper="casperjs /Users/llanese/Sites/tests/go.js" 

## profile
#   ------------------------------------------------------------
alias edit_profile=" open -e ~/.bash_profile "
alias reload_profile=" source ~/.bash_profile "

## web development, so I need to edit these non-owned files fairly often
#   ------------------------------------------------------------
alias edit_hosts="open -e /etc/hosts"
alias edit_httpd="open -e /etc/apache2/httpd.conf"
alias edit_php="open -e /etc/php.ini"
alias edit_vhosts="open -e /etc/apache2/extra/httpd-vhosts.conf"

# Git branch in prompt.
#   ------------------------------------------------------------
parse_git_branch() {
 while read -r branch; do
     [[ $branch = \** ]] && current_branch=${branch#* }
 done < <(git branch 2>/dev/null)

 [[ $current_branch ]] && printf ' [%s]' "$current_branch"

## Modify Bash Prompt, Enable colors, improve ls
#   ------------------------------------------------------------
export PS1="-->\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$(parse_git_branch)\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad

## FIX logging (don not stop running processes)
alias logout=" /System/Library/CoreServices/Menu\ Extras/ -suspend "
alias logoff=" /System/Library/CoreServices/Menu\ Extras/ -suspend "

## FIX sleep problem on MAC laptops (handle with care)
#   ------------------------------------------------------------
alias when_sleep=' sudo pmset -a '
alias hibernate=' sudo pmset -a hibernatemode 25 '
alias sleep=' sudo pmset -a hibernatemode 0 '
alias safesleep=' sudo pmset -a hibernatemode 3 '
alias smartsleep=' sudo pmset -a hibernatemode 2 '

#   ---------------------------------------
alias mountReadWrite='/sbin/mount -uw /'    # mountReadWrite:   For use when booted into single-user

## FIX and destroy .DS_Store files in the folder I am currently in
#   ------------------------------------------------------------
alias killDS='find . -name *.DS_Store -type f -delete'

## git configuration
# specify a global exclusion list
#   ------------------------------------------------------------
git config --global core.excludesfile ~/.gitignore
# adding .DS_Store to that list
echo .DS_Store >> ~/.gitignore

## testing libs available status
#   ------------------------------------------------------------
alias testme='          
        uname -a;
        java -version;
            apachectl -v;
        git --version;
        node --version;
        npm --version;
        karma --version;
            phantomjs --version;
        casperjs --version;
            php -v;
        mongo --version; 
        mongod --version;
        mongos --version;
            sass -v;
        protractor --version;
        webpack -v;

## get the VB (virtual box)
#   ------------------------------------------------------------
alias modernio='curl -O -L "{1.sfx,2.rar,3.rar,4.rar,5.rar}"'
alias vb='curl -O -L ""'

## chmod +x IE*.sfx
## ./IE11.Win10.For.MacVirtualBox.part1.sfx
## This will deploy an .dmg, double click and rock and roll!

## finder
#   ------------------------------------------------------------
alias f='open -a Finder ./'

## where is my stuff
#   ------------------------------------------------------------
alias where='
        which git;
            which express;
        which yo; 
        which gulp;
        which mongo;
        which cordova;
        which php;
        which npm;
        which node;
        which bower;
        which pouchdb;
        which couchdb;
        which java;

## REMOVING all the Node dependencies
#   ------------------------------------------------------------
alias npm_dev=' npm ls | grep -v 'npm@' | awk '/@/ {print $2}' | awk -F@ '{print $1}' | xargs npm rm '

# Start calculator with math support
alias bc='bc -l'

## Improving the terminal for fast typers
#   ------------------------------------------------------------        
alias cd..='cd ../'                         # Go back 1  level 
alias ..='cd ../'                           # Go back 1  level
alias ...='cd ../../'                       # Go back 2  levels
alias .3='cd ../../../'                     # Go back 3  levels
alias .4='cd ../../../../'                  # Go back 4  levels
alias .5='cd ../../../../../'               # Go back 5  levels
alias .6='cd ../../../../../../'            # Go back 6  levels
alias c='clear'   
alias show_options=' shopt '
alias make1mb=' mkfile 1m ./1MB.dat '         # make1mb:      Creates a file of 1mb size (all zeros)
alias make5mb=' mkfile 5m ./5MB.dat '         # make5mb:      Creates a file of 5mb size (all zeros)
alias make10mb=' mkfile 10m ./10MB.dat '      # make10mb:     Creates a file of 10mb size (all zeros)

#   extract:  Extract most know archives with one command
#   -----------------------------------------------------------
    extract () {
        if [ -f $1 ] ; then
          case $1 in
            *.tar.bz2)   tar xjf $1     ;;
            *.tar.gz)    tar xzf $1     ;;
            *.bz2)       bunzip2 $1     ;;
            *.rar)       unrar e $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()" ;;
             echo "'$1' is not a valid file"

#   spotlight: Search for a file using MacOS Spotlight's metadata
#   -----------------------------------------------------------
spotlight () { mdfind "kMDItemDisplayName == '$@'wc"; }

#   memHogsTop, memHogsPs:  Find memory hogs
#   -----------------------------------------------------
alias memHogsTop=' top -l 1 -o rsize | head -20 '
alias memHogsPs=' ps wwaxm -o pid,stat,vsize,rss,time,command | head -10 '

## get top process eating memory
alias psmem='ps aux | sort -nr -k 4'
alias psmem10='ps aux | sort -nr -k 4 | head -10'

## get top process eating cpu ##
alias pscpu=' ps aux | sort -nr -k 3 '
alias pscpu10=' ps aux | sort -nr -k 3 | head -10 '

#   cpuHogs:  Find CPU hogs
#   -----------------------------------------------------
alias cpu_hogs=' ps wwaxr -o pid,stat,%cpu,time,command | head -10 '

# screensaverDesktop: Run a screensaver on the Desktop
#   -----------------------------------------------------------------------------------
alias screensaverDesktop='/System/Library/Frameworks/ScreenSaver.framework/Resources/ -background'

#   process on memory track
#   -----------------------------------------------------
alias track=' ps aux | grep  grunt ' 
# and finally 
# sudo kill -9 
# or killall -9 firefox

# Grunt shortcuts
#   ------------------------------------------------------------
alias cleanstart='  cleanstart -d -v '
alias cleanend=' grunt cleanend '
alias default=' grunt default '
alias build=' grunt build '
alias buildjs=' grunt buildjs '
alias buildjslib=' grunt buildjslib '
alias buildjshtml=' grunt buildjshtml '
alias buildcss=' grunt buildcss '
alias buildfonts=' grunt buildfonts '
alias buildresources=' grunt buildresources '
alias buildstubs=' grunt buildstubs '
alias ut=' grunt test verbose '
alias utd=' grunt debugtest '
alias validatejs=' grunt validatejs '
alias release=' grunt release '
alias debugrelease=' grunt debugrelease '
alias analyseapp=' grunt analyseapp '

# LOCAL JSON-Server as a Fake REST API in Frontend Development
# npm install -D json-server
# ------------------------------------------------------------
alias fakeServer=' json-server --watch db.json '

# ONLINE JSON-Server as a Fake REST API in Frontend Development
# npm install -D json-server
#   ------------------------------------------------------------
alias fakeJson=' open-a '

view bash_profile


{ 'Leo Lanese',

'Building Inspiring Responsive Reactive Solutions',

'London, UK' }



Questions / Suggestion / Recommendation ?

GitHub bash profile:


Discussion (6)

moopet profile image
Ben Sinclair

I have a few comments:
It's not going to load .bash_profile on a lot of systems, depending on where you are and what you're doing (.bashrc might be used instead).

You don't need to create a file before you edit it (if you leave this step out it's less for people to learn).

It looks like your "Windows version setup" is git configuration - did you paste this in from an article from your blog or something? On Windows it would be using WSL or Cygwin or git bash. I have no experience of the latter, so I don't know what I'm talking about!

If you run clear right at the start, then it makes the screen neat, but it means you miss any warnings or errors that might have appeared as the shell started up.

Why do you want it to beep (tput bel) every time your open a new shell?

What's $dir? in the npm section? It's never defined; is that a placeholder for us to fill in? I'd set it to "$HOME/.npm" or something.

alias='$EDITOR ~/.bashrc ; source ~/.bashrc' sets a variable called alias, which you never use (and it'd be a weird name!) so I think that's missing an alias name. You have this covered in your "profile" section later, anyway.

These files can get pretty long, and it's common to split out things like aliases to another file:

[ -f "$HOME/.bash_aliases" ] && . "$HOME/.bash_aliases"

Recently I've started calling this file .aliases and sharing it between zsh and bash so it works on any of my usual environments. Aliases are rarely shell-specific.

Your "Change prompt" section doesn't do anything with the prompt - it's more like a MOTD section - and it uses variables that aren't available as standard ("${COLOR_BROWN}"). It's a useful bunch of stats for you - I'd put it into a script or function instead so you can call it whenever you want.

Almost all your aliases are Mac-specific. I'd divide them up into Mac-only and portable. You said this is for Windows as well, you can split up with something like this:

case $OSTYPE in 
    alias ls='ls --color --group-directories-first -FhN'

    alias ls='ls -FhG'

    # I guess do whatever Windows needs?

You probably shouldn't alias .:

alias .='open -a Finder ./'

This shadows the . (source) command, so you'll no longer be able to do things like . ~/.bash_profile to reload your profile!

leolanese profile image
Leo Lanese Author

I really appretiate your feedback, I will be working with it to improve this post.

leolanese profile image
Leo Lanese Author

Thanks again. It is updated.
If you have any other suggestion, feel free to make a Pull/Request to the GitHub account: :)

cbmgit profile image

in aliases handlling JSON I notice some JSON tools , I also know about tool.

leolanese profile image
Leo Lanese Author

Thanks, updated:

## aliases validate JSON
#   ------------------------------------------------------------
alias JSONValidate=" open "
alias JSONTools=" open "

## aliases Mock RestAPI (local and remote)
#   ------------------------------------------------------------
alias mockRestAPI1=" open " 
alias mockRestAPI2=" open "
alias mockRestAPI3=" open "
alias mockRestAPI4=" open "
alias mockRestAPI4=" open "

If you have any other suggestion, feel free to make a Pull/Request to the GitHub account:

cbmgit profile image

Awesome.. Thank you.