Created
December 12, 2017 15:34
-
-
Save varunyellina/165c384efe28d92c9a8337ed0a2a2a60 to your computer and use it in GitHub Desktop.
Useful aliases for ZSH
This file contains 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
# Changing Directory | |
alias .~='cd ~' | |
alias ..='cd ..' | |
alias .2='cd ../../' | |
alias .3='cd ../../../' | |
alias .4='cd ../../../../' | |
# List size of all folders | |
alias fsize='du -h -d 1 | sort -n' | |
# Terminal tools | |
alias c='clear' | |
alias ls='ls -1FG' | |
alias ll='ls -lhBFG' | |
alias la='ls -lhAFG' | |
alias lr='ls -lhRFG' | |
# Network Tools | |
alias ping='ping -c 5' | |
# Git | |
alias ga='git add' | |
alias gp='git push' | |
alias gl='git log' | |
alias gs='git status' | |
alias gd='git diff' | |
alias gdc='git diff --cached' | |
alias gm='git commit -m' | |
alias gma='git commit -am' | |
alias gb='git branch' | |
alias gc='git checkout' | |
alias gra='git remote add' | |
alias grr='git remote rm' | |
alias gpu='git pull' | |
alias gcl='git clone' | |
# Helpers for screen | |
alias screenl='screen -ls' | |
alias screenr='screen -r' | |
alias screens='screen -S' | |
# Mac Helpers | |
alias showhidden="defaults write com.apple.finder AppleShowAllFiles TRUE && killall Finder" | |
alias hidehidden="defaults write com.apple.finder AppleShowAllFiles FALSE && killall Finder" | |
# Determine your IP addresses | |
exip () { | |
# gather external ip address | |
echo -n "Current External IP: " | |
curl -s -m 5 http://myip.dk | grep "ha4" | sed -e 's/.*ha4">//g' -e 's/<\/span>.*//g' | |
} | |
ips () { | |
# determine local IP address | |
ifconfig | grep "inet " | awk '{ print $2 }' | |
} | |
# Grep functions | |
dls () { | |
# directory LS | |
echo `ls -l | grep "^d" | awk '{ print $9 }' | tr -d "/"` | |
} | |
psgrep() { | |
if [ ! -z $1 ] ; then | |
echo "Grepping for processes matching $1..." | |
ps aux | grep $1 | grep -v grep | |
else | |
echo "!! Need name to grep for" | |
fi | |
} | |
# Extract file based on file type | |
extract () { | |
if [ -f $1 ] ; then | |
case $1 in | |
*.tar.bz2) tar xjf $1 ;; | |
*.tar.gz) tar xzf $1 ;; | |
*.bz2) bunzip2 $1 ;; | |
*.rar) unrar x $1 ;; | |
*.gz) gunzip $1 ;; | |
*.tar) tar xf $1 ;; | |
*.tbz2) tar xjf $1 ;; | |
*.tgz) tar xzf $1 ;; | |
*.zip) unzip $1 ;; | |
*.Z) uncompress $1 ;; | |
*) echo "'$1' cannot be extracted via extract()" ;; | |
esac | |
else | |
echo "'$1' is not a valid file" | |
fi | |
} | |
# Nginx | |
alias nginx.start='sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist' | |
alias nginx.stop='sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist' | |
alias nginx.restart='nginx.stop && nginx.start' | |
# PHP-FPM | |
alias php-fpm.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist" | |
alias php-fpm.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist" | |
alias php-fpm.restart='php-fpm.stop && php-fpm.start' | |
# MariaDB | |
alias mysql.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist" | |
alias mysql.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist" | |
alias mysql.restart='mysql.stop && mysql.start' | |
alias nginx.logs.error='tail -250f /usr/local/etc/nginx/logs/error.log' | |
alias nginx.logs.access='tail -250f /usr/local/etc/nginx/logs/access.log' | |
alias nginx.logs.default.access='tail -250f /usr/local/etc/nginx/logs/default.access.log' | |
alias nginx.logs.phpmyadmin.error='tail -250f /usr/local/etc/nginx/logs/phpmyadmin.error.log' | |
alias nginx.logs.phpmyadmin.access='tail -250f /usr/local/etc/nginx/logs/phpmyadmin.access.log' | |
# Adding user folder to path for testing scripts and executables | |
export PATH=/Users/varun/Code/bin:$PATH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment