Created
December 20, 2018 05:26
-
-
Save antonmedv/dfab56ad5445aa774e6c7034c86905c6 to your computer and use it in GitHub Desktop.
My bash profile
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
# Brew | |
export PATH="/usr/local/sbin:$PATH" | |
# Php | |
export PATH="/usr/local/opt/[email protected]/bin:$PATH" | |
export PATH="$PATH:~/.composer/vendor/bin" | |
export dep="/Users/anton/Projects/deployer/bin/dep" | |
#export COMPOSER_DISABLE_XDEBUG_WARN=1 | |
eval "$(symfony-autocomplete)" | |
# Node | |
export NODE_PATH=/usr/local/lib/node_modules | |
# Go | |
export GOPATH=/Users/anton/.go | |
export PATH="/Users/anton/.go/bin:$PATH" | |
alias godep="/usr/local/Cellar/dep/0.5.0/bin/dep" | |
# Python | |
eval "$(pyenv init -)" | |
# Rust | |
export PATH="$PATH:~/.cargo/bin" | |
# Bash | |
if [ -f /usr/local/share/bash-completion/bash_completion ]; then | |
. /usr/local/share/bash-completion/bash_completion | |
fi | |
# Git | |
alias so='git status' | |
alias up='(git stash && git pull >&2 ) | grep -v "No local changes to save" && git stash pop' | |
alias gf='git fetch --all --prune' | |
alias gc='git add . && git commit -a && git pull && git push' | |
alias hard='confirm && git reset --hard HEAD' | |
# Other aliases | |
alias profile='mate -w ~/.profile && source ~/.profile' | |
alias ll='ls-color -ab' | |
# 'exa -la --group-directories-first' | |
# 'ls -lahG' | |
alias rm=trash | |
alias ..='cd ..' | |
alias ~='cd ~' | |
alias d='cd ~/Desktop' | |
alias tree='tree -C -L 2 -h' | |
alias hl='pbpaste | highlight -O rtf -s andes --font=Monaco --font-size=20 -S js | pbcopy' | |
alias phpunit='php vendor/bin/phpunit' | |
alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome" | |
alias dry='docker run -it -v /var/run/docker.sock:/var/run/docker.sock moncho/dry' | |
# Prompt | |
PATH_COLOR="\[$(tput setaf 47)\]" | |
GIT_BRANCH_COLOR="\[$(tput setaf 51)\]" | |
PROMPT_COLOR="\[$(tput setaf 76)\]" | |
RESET="\[$(tput sgr0)\]" | |
function find_git_branch { | |
local branch | |
if branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null); then | |
if [[ "$branch" == "HEAD" ]]; then | |
branch='detached*' | |
fi | |
GIT_BRANCH=" ${GIT_BRANCH_COLOR}⎇ $branch${RESET}" | |
else | |
GIT_BRANCH="" | |
fi | |
} | |
function set_tab_title { | |
echo -ne "\033]0;${PWD##*/}\007" | |
} | |
function set_ps1 { | |
find_git_branch; | |
set_tab_title; | |
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then | |
export PS1="⌘ ${PATH_COLOR}\W${RESET}${GIT_BRANCH} ${PROMPT_COLOR}\$${RESET} " | |
#export PS1='$(printf "%$((COLUMNS-1))s\r")'$PS1 # Add expra new line if needed | |
else | |
export PS1="\W \$ " | |
fi | |
} | |
function set_no { | |
export PS1="\$ " | |
} | |
export PROMPT_COMMAND="set_ps1;" | |
# | |
# Functions | |
# | |
function port { | |
if [ -z "$1" ]; then | |
sudo lsof -n -i4TCP | |
else | |
sudo lsof -n -i4TCP:$1 | |
fi | |
} | |
function confirm { | |
read -r -p "${1:-Are you sure? [Y/n]} " response | |
case $response in | |
[nN]) | |
false | |
;; | |
*) | |
true | |
;; | |
esac | |
} | |
function new { | |
mkdir $1 && cd $1 | |
} | |
function show_all_colors { | |
for code in $(seq -w 0 255); do for attr in 0 1; do printf "%s-%03s %bTest%b\n" "${attr}" "${code}" "\e[${attr};38;05;${code}m" "\e[m"; done; done | column -c $((COLUMNS*2)) | |
} | |
# hh | |
alias hh=hstr | |
export HSTR_CONFIG=hicolor,prompt-bottom,raw-history-view,keywords | |
shopt -s histappend # append new history items to .bash_history | |
export HISTCONTROL=ignorespace # leading space hides commands from history | |
export HISTFILESIZE=1000000 # increase history file size (default is 500) | |
export HISTSIZE=${HISTFILESIZE} # increase history size (default is 500) | |
export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}" # mem/file sync | |
# if this is interactive shell, then bind hh to Ctrl-r (for Vi mode check doc) | |
if [[ $- =~ .*i.* ]]; then bind '"\C-r": "\C-a hstr -- \C-j"'; fi | |
# Z | |
. /usr/local/etc/profile.d/z.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment