Skip to content

Instantly share code, notes, and snippets.

@macintacos
Created June 29, 2018 14:55
Show Gist options
  • Save macintacos/12ad8cf468140929e41bebb24f2e8949 to your computer and use it in GitHub Desktop.
Save macintacos/12ad8cf468140929e41bebb24f2e8949 to your computer and use it in GitHub Desktop.
My Dumb GZSH Profile
## PROFILING INFORMATION.
## Uncomment the following line (and last line) to get loading times for zshell
# zmodload zsh/zprof
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$PATH
PATH=~/perl5/perlbrew/bin:$PATH
PATH=/usr/local/lib/node_modules:$PATH
export TERM="xterm-256color"
export EDITOR="code"
export ZSH=/Users/juliant/.oh-my-zsh
export SSH_KEY_PATH="~/.ssh/rsa_id"
export ATLAS_API_USER=""
export ATLAS_API_KEY=""
export ATLAS_PROJECT_ID=""
export SCALA_HOME=/usr/local/share/scala
# GO PATH/executables
export GOPATH="/Users/juliant/Dropbox/Developer/go-workspace"
export PATH="$PATH:$GOPATH/bin:$SCALA_HOME/bin:/usr/local/mysql-8.0.11-macos10.13-x86_64/bin/"
# ZSH Settings
DEFAULT_USER="juliant"
ZSH_THEME="arrow"
HYPHEN_INSENSITIVE="true"
COMPLETION_WAITING_DOTS="true"
# PLUGINS & CACHE LOADING
plugins=(git zsh-completions zsh_completions_mongodb httpie npm node python calc alias-tips thefuck)
autoload -Uz compinit
for dump in ~/.zcompdump(N.mh+24); do
compinit
done
compinit -C
# USER CONFIGURATION
## Preferred editor for local and remote sessions
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='vim'
else
export EDITOR='mvim'
fi
## 'source'-ing oh-my-zsh.sh, so that things can work properly afterwards.
source $ZSH/oh-my-zsh.sh
# ALIASES
alias ohmyzsh="code ~/.oh-my-zsh"
alias editalias='cd ~/.oh-my-zsh/plugins/common-aliases && micro common-aliases.plugin.zsh'
alias numFiles='echo $(gls -1 | wc -l)' # numFiles: Count of non-hidden files in current dir
alias lr='gls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'' | less'
alias c='clear && l' # c: Clear terminal display
alias cp='cp -iv' # Preferred 'cp' implementation
alias mv='mv -iv' # Preferred 'mv' implementation
alias f='open -a Finder ./' # f: Opens current directory in MacOS Finder
alias less='less'
# 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'
# cpuHogs: Find CPU hogs
# -----------------------------------------------------
alias cpu_hogs='ps wwaxr -o pid,stat,%cpu,time,command | head -10'
# topForever: Continual 'top' listing (every 10 seconds)
# -----------------------------------------------------
alias topForever='top -l 9999999 -s 10 -o cpu'
# ttop: Recommended 'top' invocation to minimize resources
# ------------------------------------------------------------
# Taken from this macosxhints article
# http://www.macosxhints.com/article.php?story=20060816123853639
# ------------------------------------------------------------
alias ttop="top -R -F -s 10 -o rsize"
# ls, the common ones I use a lot shortened for rapid fire usage
alias ls='gls --color=auto'
alias l='ls -lFh' # size,show type,human readable
alias la='ls -lAFh' # long list,show almost all,show type,human readable
alias lt='ls -ltFh' # long list,sorted by date,show type,human readable
alias ll='ls -FGlAhp' # Preferred 'ls' implementation
alias ldot='ls -ld .*'
alias lS='ls -1FSsh'
alias lart='ls -1Fcart'
alias lrt='ls -1Fcrt'
alias edit='micro'
alias grep='grep -iE --color'
alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} '
alias t='tail -f'
# Command line head / tail shortcuts
alias -g H='| head'
alias -g T='| tail'
alias -g G='| grep'
alias -g L="| less"
alias -g M="| most"
alias -g LL="2>&1 | less"
alias -g CA="2>&1 | cat -A"
alias -g NE="2> /dev/null"
alias -g NUL="> /dev/null 2>&1"
alias -g P="2>&1| pygmentize -l pytb"
alias dud='du -d 1 -h'
alias duf='du -sh *'
alias fd='find . -type d -name'
alias ff='find . -type f -name'
alias h='history'
alias hgrep="fc -El 0 | grep"
alias help='man'
alias p='ps -f'
alias sortnr='sort -n -r'
alias unexport='unset'
alias whereami=display_info
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# zsh is able to auto-do some kungfoo
# depends on the SUFFIX :)
if is-at-least 4.2.0; then
# open browser on urls
if [[ -n "$BROWSER" ]]; then
_browser_fts=(htm html de org net com at cx nl se dk)
for ft in $_browexitser_fts; do alias -s $ft=$BROWSER; done
fi
_editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex md js css json scpt)
for ft in $_editor_fts; do alias -s $ft=$EDITOR; done
if [[ -n "$XIVIEWER" ]]; then
_image_fts=(jpg jpeg png gif mng tiff tif xpm)
for ft in $_image_fts; do alias -s $ft=$XIVIEWER; done
fi
_media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm)
for ft in $_media_fts; do alias -s $ft=mplayer; done
#read documents
alias -s pdf=acroread
alias -s ps=gv
alias -s dvi=xdvi
alias -s chm=xchm
alias -s djvu=djview
#list whats inside packed file
alias -s zip="unzip -l"
alias -s rar="unrar l"
alias -s tar="tar tf"
alias -s tar.gz="echo "
alias -s ace="unace l"
fi
# CUSTOM FUNCTIONS
pretty_csv() { column -t -s "$@" | less -F -S -X -K } # pretty_csv: prettify CSV files
cd() { # Always list directory contents upon 'cd
builtin cd "$@";
echo "Current directory: $PWD";
ll;
}
grepip() { # grep unique IPs from within a log file
\grep -E -o "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" "$@" | sort | uniq
}
my_ps() { ps "$@" -u "$USER" -o pid,%cpu,%mem,start,time,bsdtime,command ; } # my_ps: List processes owned by my user:
ii() { # ii: display useful host related informaton
echo -e "\nYou are logged on $HOST"
echo -e "\nAdditionnal information: " ; uname -a
echo -e "\nUsers logged on: " ; w -h
echo -e "\nCurrent date :$NC " ; date
echo -e "\nMachine stats :$NC " ; uptime
echo -e "\nCurrent network location :$NC " ; scselect
echo -e "\n" ; myip
#echo -e "\n${RED}DNS Configuration:$NC " ; scutil --dns
echo
}
mcd () { mkdir -p "$1" && cd "$1"; } # mcd: Makes new Dir and jumps inside
myip() { echo "My WAN/Public IP address: $(dig +short myip.opendns.com @resolver1.opendns.com)" } # myip: prints out your current IP
# Make zsh know about hosts already accessed by SSH
zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })'
source /Users/juliant/perl5/perlbrew/etc/bashrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use # This loads nvm
#[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" --no-use # This loads nvm bash_completion
alias node='unalias node ; unalias npm ; nvm use default ; node $@'
alias npm='unalias node ; unalias npm ; nvm use default ; npm $@'
# ZSH-specific commands
# ZSH taking forever? use this to debug, then check zsh_startup.log
zshdebug() {
zsh -xv 2>&1 | ts -i "%.s" > ~/.latest_zsh_startup.log && micro ~/.latest_zsh_startup.log; # zsh_startup.log will be erased initially, to ensure that only the latest run is shown
}
alias zshconfig="vim ~/.zshrc"
alias zshrc='vim ~/.zshrc' # Quick access to the ~/.zshrc file
eval $(gdircolors $HOME/.dircolors/dircolors.ansi-universal)
## THINGS NOT LOADING FAST ENOUGH?
## Comment out the following line (and the first ling at the top of this file)
## Start a new shell, analyze the results.
# zprof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment