Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Terminal: Mac OS X Terminal Aliases & How-To - .bash_profile / .profile

Mac OS X Terminal Aliases & How-To

Collection of some of my fav terminal aliases that i use often & collected from the web. This file will be updated with more aliases as i find more. Feel free to comment and share your fav aliases you use :)

###Follow these simple steps to add the following aliases:###

  1. Within the Terminal, run:

vim ~/.bash_profile

  1. Type i and then paste the following at the top of the file:

    Laravel Artisan

    alias art='php artisan'

    Open file with Sublime Text 2 $ st /folder/example.php

    alias st='open -a "Sublime Text 2"'

    Jump back n directories at a time

    alias ..='cd ..' alias ...='cd ../../' alias ....='cd ../../../' alias .....='cd ../../../../' alias ......='cd ../../../../../'

    Flush DNS (Mac OS X Moutain Lion or Lion)

    alias dnsflush='sudo killall -HUP mDNSResponder'

    To clear terminal

    alias c='clear'

    To exit terminal

    alias e='exit'


    alias sudo='sudo '

    This helps me edit files that my user isn't the owner of

    alias edit='SUDO_EDITOR="open -FWne" sudo -e'

    The alias that takes me here - to editing these very aliases

    alias edit_profile='open -e ~/.bash_profile'

    I do a lot of web development, so I need to edit these non-owned files fairly often

    alias edit_hosts='edit /etc/hosts' alias edit_httpd='edit /etc/apache2/httpd.conf' alias edit_php='edit /etc/php.ini' alias edit_vhosts='edit /etc/apache2/extra/httpd-vhosts.conf'

    Some of my goto commands, including one to open the php extension folder for when I need to install custom extensions

    alias goto_web='cd ~/Sites' alias goto_phpext='sudo open /usr/lib/php/extensions/no-debug-non-zts-20100525'

    Go to MAMP/htdocs

    alias goto_htdocs='cd /Applications/MAMP/htdocs'

    This alias recursively destroys all .DS_Store files in the folder I am currently in

    alias killDS='find . -name *.DS_Store -type f -delete'

    An alias to start my custom MySQL installation instead of the default one

    alias mysql='/usr/local/mysql-5.5.25-osx10.6-x86_64/bin/mysql -u root'

    This alias reloads this file

    alias reload_profile='. ~/.bash_profile'

    Mac get stuck very often and are extremely slow and unstable on shutdowns. This forces a shutdown.

    alias poweroff='sudo /sbin/shutdown -h now'

    All other aliases

    alias ls='ls -aFhlG' alias ll='ls -l' alias search=grep alias ports='sudo lsof -iTCP -sTCP:LISTEN -P'

    Run second instance of Skype (Good for using multiple accounts)

    alias ss='sudo /Applications/ /secondary'

    Get OS X Software Updates, update Homebrew itself, and upgrade installed Homebrew packages

    alias update="sudo softwareupdate -i -a; brew update; brew upgrade"

    Speed-up Terminal load time by clearing system logs

    alias speedup="sudo rm -rf /private/var/log/asl/*"

    Empty the Trash on all mounted volumes and the main HDD

    Also, clear Apple’s System Logs to improve shell startup speed

    alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; speedup"

    IP addresses

    To get my external IP

    alias myip='curl'

    Other IP / Method

    alias ip="dig +short" alias localip="ifconfig en0 inet | grep 'inet ' | awk ' { print $2 } '" alias ips="ifconfig -a | perl -nle'/(\d+.\d+.\d+.\d+)/ && print $1'"

    Enhanced WHOIS lookups

    alias whois="whois -h"

    Show Hidden files in Finder

    alias finder_s='defaults write AppleShowAllFiles TRUE; killAll Finder'

    Hide Hidden files in Finder

    alias finder_h='defaults write AppleShowAllFiles FALSE; killAll Finder'

  2. Hit ESC, Type :wq, and hit Enter

  3. Reload the bash profile, In Terminal, run:

source ~/.bash_profile

And we're done! If everything went good, you should be able to start using those aliases right away :)


This comment has been minimized.

Copy link
Owner Author

@irazasyed irazasyed commented Mar 28, 2014

Switched to Ohmyzsh!


This comment has been minimized.

Copy link

@ggwebdev ggwebdev commented Jul 29, 2015

Nice man, great help, tanks!


This comment has been minimized.

Copy link

@uchsarath uchsarath commented Feb 15, 2017

really nice man, awesome


This comment has been minimized.

Copy link

@Anietz Anietz commented Jan 28, 2019


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.