Last active
April 7, 2017 16:13
-
-
Save cjerrington/649186097b4dc5696d0b907966ef3110 to your computer and use it in GitHub Desktop.
My bash profile on MacOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #add some color | |
| export CLICOLOR=1 | |
| export LSCOLORS=ExFxBxDxCxegedabagacad | |
| # Clear the screen | |
| alias clr=clear | |
| alias cls=clear | |
| alias backup=$HOME/Documents/Utils/backup.sh | |
| #alias win='sudo bless -mount "/Volumes/BOOTCAMP" -legacy -setBoot -nextonly;sudo shutdown -r now' | |
| # Edit .bash_profile | |
| alias edit='atom ~/.bash_profile' | |
| alias reload='. ~/.bash_profile' | |
| # Show/Hide hidden files | |
| alias showhidden='defaults write com.apple.finder AppleShowAllFiles TRUE; killall Finder' | |
| alias hidehidden='defaults write com.apple.finder AppleShowAllFiles FALSE; killall Finder' | |
| # Quit Terminal | |
| alias qt='osascript -e "quit app \"Terminal\""&exit' | |
| #alias quit='osascript -e "quit app \"Terminal\""&exit' | |
| alias path='echo -e ${PATH//:/\\n}' | |
| alias me='whoami' | |
| # Date & Time | |
| alias now='date +"%T"' | |
| alias nowtime=now | |
| alias nowdate='date +"%d-%m-%Y"' | |
| #external IP | |
| alias exip='curl http://ipecho.net/plain; echo' | |
| alias ip='ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk "{print $2}"' | |
| # wifiIP: Get info on connections for en0, wifi on my OS | |
| alias wifiIP='ipconfig getpacket en0 | grep "yiaddr" | awk "{print $3;}"' | |
| # ethIP: Get info on connections for en1, ethernet on my OS | |
| alias ethIP='ipconfig getpacket en1' | |
| # CD to home path | |
| alias cdh='cd ~/' | |
| # make directory and then cd to it | |
| mkd () { | |
| mkdir -p $1 | |
| cd $1 | |
| } | |
| # extract compreessed files | |
| function extract { | |
| if [ -z "$1" ]; then | |
| # display usage if no parameters given | |
| echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>" | |
| else | |
| if [ -f $1 ] ; then | |
| NAME=${1%.*} | |
| mkdir $NAME && cd $NAME | |
| case $1 in | |
| *.tar.bz2) tar xvjf ../$1 ;; | |
| *.tar.gz) tar xvzf ../$1 ;; | |
| *.tar.xz) tar xvJf ../$1 ;; | |
| *.lzma) unlzma ../$1 ;; | |
| *.bz2) bunzip2 ../$1 ;; | |
| *.rar) unrar x -ad ../$1 ;; | |
| *.gz) gunzip ../$1 ;; | |
| *.tar) tar xvf ../$1 ;; | |
| *.tbz2) tar xvjf ../$1 ;; | |
| *.tgz) tar xvzf ../$1 ;; | |
| *.zip) unzip ../$1 ;; | |
| *.Z) uncompress ../$1 ;; | |
| *.7z) 7z x ../$1 ;; | |
| *.xz) unxz ../$1 ;; | |
| *.exe) cabextract ../$1 ;; | |
| *) echo "extract: '$1' - unknown archive method" ;; | |
| esac | |
| else | |
| echo "$1 - file does not exist" | |
| fi | |
| fi | |
| } | |
| # Machine info | |
| ii() { | |
| echo -e "\nYou are logged on ${RED}$HOST" | |
| echo -e "\nAdditionnal information:$NC " ; uname -a | |
| echo -e "\n${RED}Users logged on:$NC " ; w -h | |
| echo -e "\n${RED}Current date :$NC " ; date | |
| echo -e "\n${RED}Machine stats :$NC " ; uptime | |
| echo -e "\n${RED}Current network location :$NC " ; scselect | |
| echo -e "\n${RED}Public facing IP Address :$NC " ;exip | |
| #echo -e "\n${RED}DNS Configuration:$NC " ; scutil --dns | |
| echo | |
| } | |
| # Generates a tree view from the current directory | |
| function tree(){ | |
| pwd | |
| ls -R | grep ":$" | \ | |
| sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/' | |
| } | |
| # Generates a random password | |
| function ranpass() { | |
| if [ -z $1 ]; then | |
| MAXSIZE=10 | |
| else | |
| MAXSIZE=$1 | |
| fi | |
| array1=( | |
| q w e r t y u i o p a s d f g h j k l z x c v b n m Q W E R T Y U I O P A S D | |
| F G H J K L Z X C V B N M 1 2 3 4 5 6 7 8 9 0 | |
| \! \@ \$ \% \^ \& \* \! \@ \$ \% \^ \& \* \@ \$ \% \^ \& \* | |
| ) | |
| MODNUM=${#array1[*]} | |
| pwd_len=0 | |
| while [ $pwd_len -lt $MAXSIZE ] | |
| do | |
| index=$(($RANDOM%$MODNUM)) | |
| echo -n "${array1[$index]}" | |
| ((pwd_len++)) | |
| done | |
| echo | |
| } | |
| function quit () { | |
| if [ -z "$1" ]; then | |
| # display usage if no parameters given | |
| echo "Usage: quit appname" | |
| else | |
| for appname in $1; do | |
| osascript -e 'quit app "'$appname'"' | |
| done | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment