Skip to content

Instantly share code, notes, and snippets.

@soreana
Created April 27, 2018 20:38
Show Gist options
  • Save soreana/c57f17a18f7d0dacd8302bdbddabd87e to your computer and use it in GitHub Desktop.
Save soreana/c57f17a18f7d0dacd8302bdbddabd87e to your computer and use it in GitHub Desktop.
my bash profile
alias cisco='sudo cp /opt/cisco/anyconnect/profile/profile.xml.backup /opt/cisco/anyconnect/profile/profile.xml'
alias rand='java -jar ~/.my_programs/rand-command.jar'
alias shamir='java -jar ~/.my_programs/secretshare.jar'
alias dec_m='sh ~/.my_programs/minecraft/dec_m.sh'
alias enc_m='sh ~/.my_programs/minecraft/enc_m.sh'
alias pg_start="launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist"
alias pg_stop="launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist"
alias add_ut_net="sudo route -n add -net 172.18.0.0/16 $(netstat -nr | grep default | awk '{print $2}')"
alias del_ut_net="sudo route -n delete -net 172.18.0.0/16 $(netstat -nr | grep default | awk '{print $2}')"
alias hpc="ssh pipe -t 'ssh hpc'"
function emulator { cd "$(dirname "$(which emulator)")" && ./emulator "$@"; }
export GEM_HOME=~/.gem
export GEM_PATH=~/.gem
export PATH="~/.gem/bin:$PATH"
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
export M2_HOME=/Users/sinakashipazha/.maven/apache-maven-3.3.9
export PATH=$PATH:$M2_HOME/bin
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
# ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# below lines from :
# https://natelandau.com/my-mac-osx-bash_profile/
# -----------------------------
# 2. MAKE TERMINAL BETTER
# -----------------------------
alias cp='cp -iv' # Preferred 'cp' implementation
alias mv='mv -iv' # Preferred 'mv' implementation
alias mkdir='mkdir -pv' # Preferred 'mkdir' implementation
alias ll='ls -FGlAhp' # Preferred 'ls' implementation
cd() { builtin cd "$@"; ls; } # Always list directory contents upon 'cd'
alias cd..='cd ../' # Go back 1 directory level (for fast typers)
alias ..='cd ../' # Go back 1 directory level
alias ...='cd ../../' # Go back 2 directory levels
alias .3='cd ../../../' # Go back 3 directory levels
alias .4='cd ../../../../' # Go back 4 directory levels
alias .5='cd ../../../../../' # Go back 5 directory levels
alias .6='cd ../../../../../../' # Go back 6 directory levels
alias f='open -a Finder ./' # f: Opens current directory in MacOS Finder
alias ~="cd ~" # ~: Go Home
alias c='clear' # c: Clear terminal display
alias cic='set completion-ignore-case On' # cic: Make tab-completion case-insensitive
mcd () { mkdir -p "$1" && cd "$1"; } # mcd: Makes new Dir and jumps inside
trash () { command mv "$@" ~/.Trash ; } # trash: Moves a file to the MacOS trash
ql () { qlmanage -p "$*" >& /dev/null; } # ql: Opens any file in MacOS Quicklook Preview
# extract: Extract most know archives with one command
# ---------------------------------------------------------
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# ---------------------------
# 4. SEARCHING
# ---------------------------
alias qfind="find . -name " # qfind: Quickly search for file
ff () { /usr/bin/find . -name "$@" ; } # ff: Find file under the current directory
ffs () { /usr/bin/find . -name "$@"'*' ; } # ffs: Find file whose name starts with a given string
ffe () { /usr/bin/find . -name '*'"$@" ; } # ffe: Find file whose name ends with a given string
# spotlight: Search for a file using MacOS Spotlight's metadata
# -----------------------------------------------------------
spotlight () { mdfind "kMDItemDisplayName == '$@'wc"; }
# ---------------------------
# 5. PROCESS MANAGEMENT
# ---------------------------
# findPid: find out the pid of a specified process
# -----------------------------------------------------
# Note that the command name can be specified via a regex
# E.g. findPid '/d$/' finds pids of all processes with names ending in 'd'
# Without the 'sudo' it will only find processes of the current user
# -----------------------------------------------------
findPid () { lsof -t -c "$@" ; }
# ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"
# postgres commands
alias pg-start="launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist"
alias pg-stop="launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist"
export HOMEBREW_NO_AUTO_UPDATE=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment