diff --git a/custom/alias.zsh b/custom/alias.zsh new file mode 100755 index 000000000..9392cde34 --- /dev/null +++ b/custom/alias.zsh @@ -0,0 +1,56 @@ +### Get the external ip of your network +alias external_ip='curl ipecho.net/plain; echo' + +### Ruby Stuff +alias rake="noglob rake" # necessary to make rake work inside of zsh + +### ls stuff +alias ls='ls -G' +alias ll='ls -lah' +alias ltr='ll -ltr' + +### MAC only +alias ql='qlmanage -p 2>/dev/null' # OS X Quick Look +alias oo='open .' # open current directory in OS X Finder +alias 'today=calendar -A 0 -f /usr/share/calendar/calendar.mark | sort' +alias 'mailsize=du -hs ~/Library/mail' # Size of mail app +alias 'smart=diskutil info disk0 | grep SMART' # display SMART status of hard drive +alias apps='mdfind "kMDItemAppStoreHasReceipt=1"' # alias to show all Mac App store apps +alias refreshbrew='brew outdated | while read cask; do brew upgrade $cask; done' # refresh brew by upgrading all outdated casks +alias rebuildopenwith='/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.fram ework/Support/lsregister -kill -r -domain local -domain system -domain user' # rebuild Launch Services to remove duplicate entries on Open With menu + +### Other stuff +alias sz='source ~/.zshrc' +alias grep='grep --color=auto' ### Colorize grep output +alias d_size="find . -type d -d 1 -print0 | xargs -0 du -sm | sort -nr" ### Get size of directories inside current dir +alias 'fcount=find . -type f | wc -l' # number of files +alias speedtest='wget -O /dev/null https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb' + +###GIT aliases +alias st='git st' +alias lg='git lg' +alias pop='git pop' +alias gcm='git ci -m' +alias gdiff='git diff' +alias gap='git add -p' +alias gpull='git pull' +alias gpush='git push' +alias stash='git stash' +alias gfetch='git fetch' +alias pull='git pull --rebase' +alias ghard='git reset --hard' +alias gsoft='git reset --soft' +alias gcount="git shortlog | grep -E '^[ ]+\w+' | wc -l" # shows the number of commits for the current repos for all developers +alias stpull='git stash && git pull --rebase && git stash pop' +alias gsync='git fetch upstream; git checkout master; echo "+++++ Merging +++++"; git merge upstream/master' + +### Personal +alias work='cd ~/Documents/work/' +alias down='cd ~/Downloads' +alias audio-dl='youtube-dl -x --audio-format best' + + +### iPhone simulator +alias iphone="open /Applications/Xcode.app/Contents/Applications/iOS\ Simulator.app" + +source /etc/profile.d/rvm.sh diff --git a/custom/bs_alias.zsh b/custom/bs_alias.zsh new file mode 100755 index 000000000..245f1fc0e --- /dev/null +++ b/custom/bs_alias.zsh @@ -0,0 +1,76 @@ +alias depl='ssh deploy.browserstack.com' +alias infra='ssh infra.browserstack.com' +alias repo='cd ~/Documents/work/repos' +alias snapshot='sh /Users/prashanth/Documents/work/repos/infra-automation/platform/snapshot.sh' +alias cpw='sh /Users/prashanth/Documents/work/repos/infra-automation/platform/cpw' +alias cpm='sh /Users/prashanth/Documents/work/repos/infra-automation/platform/cpm' +alias delay_numbers='sh /Users/prashanth/Documents/work/repos/infra-automation/platform/delay_numbers' + +function mssh() { + ssh -p4022 ritesharora@$1 +} + +function rebootm() { + curl http://$1:45680/r3b00t +} + +function rebootw() { + curl http://$1:4568/r3b00t +} + +function bsrakes(){ + bundle exec rake terminal:manage_pool1_start & + bundle exec rake terminal:cleanup_async & + bundle exec rake terminal:update_terminal_statuses & + bundle exec rake terminal:restore_from_snapshot & + bundle exec rake terminal:check_ports_for_restored_snapshots_wtf & +} + +function addmac(){ + if [[ $# -eq 0 ]]; then + echo "Usage - addmac " + exit + fi + curl --silent --data "ip=$2&tt=$3&os=mac$3®ion=us-east-1" admin:abcd@$1.browserstack.com/admin/add_mac -o /dev/null +} + +function blockip(){ + if [[ $# -eq 0 ]]; then + echo "Usage - blockip (f)" + exit + elif [[ $3 = "f" ]]; then + force="true" + else + force="false" + fi + ruby /Users/prashanth/Documents/work/repos/block.rb $1 $2 +} + +check_port() { + if [[ $(nc -z -G 2 $1 $2) =~ "succeeded" ]]; then + echo "$2 - OK" + else + echo "$2 - FAILED" + fi +} + +function esxi_ip() { + ssh root@$1 "python /browserstack/esxi_ip_map.py" +} + +function delete_terminal() { + if [[ $# -eq 0 ]]; then + echo "Usage - delete_terminal (f)" + exit + elif [[ $3 = "f" ]]; then + force="true" + else + force="false" + fi + curl http://admin:stevejobsrocks!!@www.browserstack.com/admin/delete_terminal?ip=$1\&name=$2\&force=$force +} + +function esxi_ssh() { + `ssh root@$1` +} + diff --git a/custom/exports.zsh b/custom/exports.zsh new file mode 100755 index 000000000..0fbad0a9e --- /dev/null +++ b/custom/exports.zsh @@ -0,0 +1,14 @@ +# Color in grep +export GREP_OPTIONS='--color=auto' +export GREP_COLOR='3;33' + +#useful for gems and mysql +export ARCHFLAGS='-arch x86_64' + +# Other useful stuff +export LESS='--ignore-case --raw-control-chars' +export PAGER='less' +export EDITOR='/usr/local/bin/mate -w' +#export EDITOR='subl -w' + +export HOMEBREW_CASK_OPTS="--appdir=/Applications --caskroom=/etc/Caskroom" diff --git a/custom/functions.zsh b/custom/functions.zsh new file mode 100755 index 000000000..3e7bbee7f --- /dev/null +++ b/custom/functions.zsh @@ -0,0 +1,37 @@ +#### Search for a running process +pg() { + emulate -L zsh + unsetopt KSH_ARRAYS + if [[ -z "$1" ]] ; then + echo "any - grep for process(es) by keyword" >&2 + echo "Usage: any " >&2 ; return 1 + else + ps xauwww | grep -i --color=auto "[${1[1]}]${1[2,-1]}" + fi +} + +#### Beautiful PATH +path() { + echo $PATH | tr ":" "\n" | \ + awk "{ sub(\"/usr\", \"$fg_no_bold[green]/usr$reset_color\"); \ + sub(\"/bin\", \"$fg_no_bold[blue]/bin$reset_color\"); \ + sub(\"/opt\", \"$fg_no_bold[cyan]/opt$reset_color\"); \ + sub(\"/sbin\", \"$fg_no_bold[magenta]/sbin$reset_color\"); \ + sub(\"/local\", \"$fg_no_bold[yellow]/local$reset_color\"); \ + print }" +} + +#### All interface ips +function myip() { + ifconfig lo0 | grep 'inet ' | sed -e 's/:/ /' | awk '{print "lo0 : " $2}' + ifconfig en0 | grep 'inet ' | sed -e 's/:/ /' | awk '{print "en0 (IPv4): " $2 " " $3 " " $4 " " $5 " " $6}' + ifconfig en0 | grep 'inet6 ' | sed -e 's/ / /' | awk '{print "en0 (IPv6): " $2 " " $3 " " $4 " " $5 " " $6}' + ifconfig en1 | grep 'inet ' | sed -e 's/:/ /' | awk '{print "en1 (IPv4): " $2 " " $3 " " $4 " " $5 " " $6}' + ifconfig en1 | grep 'inet6 ' | sed -e 's/ / /' | awk '{print "en1 (IPv6): " $2 " " $3 " " $4 " " $5 " " $6}' +} + +# ------------------------------------------------------------------- +# nice mount (http://catonmat.net/blog/another-ten-one-liners-from-commandlingfu-explained) +# displays mounted drive information in a nicely formatted manner +# ------------------------------------------------------------------- +function nicemount() { (echo "DEVICE PATH TYPE FLAGS" && mount | awk '$2="";1') | column -t ; } diff --git a/custom/history.zsh b/custom/history.zsh new file mode 100755 index 000000000..1467f2006 --- /dev/null +++ b/custom/history.zsh @@ -0,0 +1,3 @@ +HISTSIZE=1000000 +SAVEHIST=900000 +HISTFILE=~/.zsh_history diff --git a/custom/osx_alias.zsh b/custom/osx_alias.zsh new file mode 100755 index 000000000..d01557faf --- /dev/null +++ b/custom/osx_alias.zsh @@ -0,0 +1,13 @@ +### Get my ip +alias ip='ipconfig getifaddr en1' + +### Delete Spotlight's existing index and build a new one +################ Use this with caution. Takes time to build ################## +alias rebuild_spotlight_index='sudo mdutil -E /Volumes/Macintosh\ HD' + +### Search and install updates +alias update='sudo softwareupdate -ia' +alias mtr='/usr/local/Cellar/mtr/0.85/sbin/mtr' + +### top sory by cpu +alias top='top -o cpu' diff --git a/custom/ps1.zsh b/custom/ps1.zsh new file mode 100755 index 000000000..267d602db --- /dev/null +++ b/custom/ps1.zsh @@ -0,0 +1,33 @@ +function short_pwd { + echo $(pwd | sed -e "s,^$HOME,~,") +} +function prompt_sym { + git branch >/dev/null 2>/dev/null && echo '±' && return + echo '○' +} + +#setopt promptsubst + +### The Left Prompt +# Modify the colors and symbols in these variables as desired. +GIT_PROMPT_SYMBOL="%{$fg[blue]%}±" +GIT_PROMPT_PREFIX="%{$fg[green]%} [%{$reset_color%}" +GIT_PROMPT_SUFFIX="%{$fg[green]%}]%{$reset_color%}" +GIT_PROMPT_AHEAD="%{$fg[red]%}ANUM%{$reset_color%}" +GIT_PROMPT_BEHIND="%{$fg[cyan]%}BNUM%{$reset_color%}" +GIT_PROMPT_MERGING="%{$fg_bold[magenta]%}⚡︎%{$reset_color%}" +GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}u%{$reset_color%}" +GIT_PROMPT_MODIFIED="%{$fg_bold[yellow]%}d%{$reset_color%}" +GIT_PROMPT_STAGED="%{$fg_bold[green]%}s%{$reset_color%}" + +PROMPT='${ret_status} %{$fg[red]%}%n%{$reset_color%} %{$fg[cyan]%}$(short_pwd)%{$reset_color%}%{$reset_color%}$(git_prompt_info) +$(prompt_sym) ' + +### The right prompt +RPROMPT='%{$fg_bold[yellow]%}($(rvm-prompt i v g))%{$reset_color%} $(battery_pct_prompt)$(battery_level_gauge)' + +ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?" +ZSH_THEME_GIT_PROMPT_CLEAN="" diff --git a/custom/setopt.zsh b/custom/setopt.zsh new file mode 100755 index 000000000..ed616ee9b --- /dev/null +++ b/custom/setopt.zsh @@ -0,0 +1,42 @@ +# ===== Basics +setopt no_beep # don't beep on error +setopt interactive_comments # Allow comments even in interactive shells (especially for Muness) + +# # ===== Changing Directories +setopt auto_cd # If you type foo, and it isn't a command, and it is a directory in your cdpath, go there +setopt cdablevarS # if argument to cd is the name of a parameter whose value is a valid directory, it will become the current directory +setopt pushd_ignore_dups # don't push multiple copies of the same directory onto the directory stack + +# # ===== Expansion and Globbing +setopt extended_glob # treat #, ~, and ^ as part of patterns for filename generation + +# # ===== History +setopt append_history # Allow multiple terminal sessions to all append to one zsh command history +setopt extended_history # save timestamp of command and duration +setopt inc_append_history # Add comamnds as they are typed, don't wait until shell exit +setopt hist_expire_dups_first # when trimming history, lose oldest duplicates first +setopt hist_ignore_dups # Do not write events to history that are duplicates of previous events +setopt hist_ignore_space # remove command line from history list when first character on the line is a space +setopt hist_find_no_dups # When searching history don't display results already cycled through twice +setopt hist_reduce_blanks # Remove extra blanks from each command line being added to history +setopt hist_verify # don't execute, just expand history +setopt share_history # imports new commands and appends typed commands to history + +# # ===== Completion +setopt always_to_end # When completing from the middle of a word, move the cursor to the end of the word +setopt auto_menu # show completion menu on successive tab press. needs unsetop menu_complete to work +setopt auto_name_dirs # any parameter that is set to the absolute name of a directory immediately becomes a name for that directory +setopt complete_in_word # Allow completion from within a word/phrase + +unsetopt menu_complete # do not autoselect the first completion entry + +# # ===== Correction +setopt correct # spelling correction for commands +setopt correctall # spelling correction for arguments + +# # ===== Prompt +setopt prompt_subst # Enable parameter expansion, command substitution, and arithmetic expansion in the prompt +setopt transient_rprompt # only show the rprompt on the current prompt + +# # ===== Scripts and Functions +setopt multios # perform implicit tees or cats when multiple redirections are attempted