Skip to content

Instantly share code, notes, and snippets.

@anechunaev
Last active May 10, 2023 18:18
Show Gist options
  • Save anechunaev/75600cf6a46de1eeafae0b464e5e837c to your computer and use it in GitHub Desktop.
Save anechunaev/75600cf6a46de1eeafae0b464e5e837c to your computer and use it in GitHub Desktop.
.bash_profile
#################
# Custom prompt #
#################
txtrst='\e[0m'
fgW='\e[38;5;7m'
bgDG1='\e[48;5;235m'
fgDG1='\e[38;5;235m'
bgDG2='\e[48;5;237m'
fgDG2='\e[38;5;237m'
bgDG3='\e[48;5;239m'
fgDG3='\e[38;5;239m'
bgB='\e[48;5;0m'
fgR='\e[38;5;1m'
fgC='\e[38;5;6m'
fgG='\e[38;5;2m'
PROMPT_DIRTRIM=3
function parse_git_dirty {
if [[ -n "$(git status --porcelain)" ]];
then
echo "${fgR} 🔴 ";
fi
}
function parse_git_stash {
local stash=`expr $(git stash list 2>/dev/null| wc -l)`
if [ "$stash" != "0" ]
then
echo "${fgC} 📦 "
fi
}
prompt_custom_git() {
local prompt='';
if [[ -n "$(git branch --show-current 2> /dev/null)" ]]
then
prompt="$(git branch --show-current)$(parse_git_stash)$(parse_git_dirty)"
fi
echo $prompt
}
prompt_current_dir() {
local dir=${PWD/#$HOME/'~'}
if (( $(echo $dir | tr '/' '\n' | wc -l) > 3 ))
then
echo $(echo $dir | rev | cut -d'/' -f1-3 | xargs -I{} echo {}"/…" | rev)
else
echo $dir
fi
}
function prompt_command() {
local x1="${fgDG1}${bgDG2} ${fgW}"
local x2="${fgDG2}${bgDG3} ${fgW}"
local x3="${fgDG3}${bgB} ${txtrst}"
printf "\n${bgDG1}${fgW} $(date +'%T') ${x1}$(prompt_current_dir) ${x2} $(prompt_custom_git) ${x3}"
}
export PS1="\$(prompt_command)\n\[${fgG}\]\$\[${txtrst}\] \[$(tput sgr0)\]"
############################
# Navigation and searching #
############################
alias '..'='cd ..'
alias 1='cd -'
alias 2='cd -2'
alias 3='cd -3'
alias 4='cd -4'
alias 5='cd -5'
alias 6='cd -6'
alias 7='cd -7'
alias 8='cd -8'
alias 9='cd -9'
alias g='grep -rnE --color=always'
alias grep='grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,node_modules}'
alias ls='ls -lah --color'
########
# FASD #
########
alias a='fasd -a'
alias d='fasd -d'
alias f='fasd -f'
alias o='a -e open_command'
alias sd='fasd -sid'
alias sf='fasd -sif'
alias z='fasd_cd -d'
alias zz='fasd_cd -d -i'
#######
# Git #
#######
alias gA='git add --all'
alias ga='git add .'
alias gb='git branch'
alias gba='git branch -a'
alias gbd='git branch -D'
alias gbl='git blame -b -w'
alias gbs='git bisect'
alias gbsb='git bisect bad'
alias gbsg='git bisect good'
alias gbsr='git bisect reset'
alias gbss='git bisect start'
alias gc='git checkout'
alias gcb='git checkout -b'
alias gclean='git clean -fd'
alias gcm='git commit'
alias 'gcm!'='git commit -v --amend'
alias gcma='git commit -a -m'
alias gcmm='git commit -m "Merged master"'
alias gcp='git cherry-pick'
alias gcpa='git cherry-pick --abort'
alias gcpc='git cherry-pick --continue'
alias gd='git d'
alias gf='git fetch'
alias gfa='git fetch --all --prune'
alias gfo='git fetch origin'
alias gignore='git update-index --assume-unchanged'
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
alias glast='git log --max-count=1'
alias glast2='git log --max-count=2'
alias glast3='git log --max-count=3'
alias glog='git log --oneline --decorate --graph'
alias gloga='git log --oneline --decorate --graph --all'
alias gm='git merge'
alias gmom='git merge origin/master'
alias gp='git pull'
alias gpo='git push origin HEAD'
alias gr='git reset --soft HEAD^'
alias grh='git reset --hard'
alias grhh='git reset HEAD --hard'
alias grs='git reset --soft'
alias gs='git status'
alias gsa='git stash apply'
alias gsc='git stash clear'
alias gss='git stash'
alias gssd='git stash drop'
alias gssl='git stash list'
alias gssp='git stash pop'
alias gsss='git stash show --text'
alias gu='git fetch && git pull origin HEAD'
alias gunignore='git update-index --no-assume-unchanged'
# Удаляет ветки, которых нет в origin
alias gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d'
# Показывает список изменённых файлов в коммите: gsf e1ada6bf6c3df5fb3e00ccc1dab77f6baa1580e5
# alias.sf diff-tree --no-commit-id --name-status -r
alias gsf='git sf'
########################
# Frontend and vagrant #
########################
alias t='tree -fisCI .js dist/js | g "\.js$"'
alias tc='tree -fisCI .css dist/css | g "\.css$"'
alias v='vagrant up'
alias vd='vagrant destroy default'
alias vh='vagrant halt'
alias vs='vagrant status'
alias vu='vagrant box update'
function goto() {
if [ "$1" == "webui" ]
then
cd /Users/artemnechunaev/devel/platform/eco/DXPServer/WebUI
fi
if [ "$1" == "vue" ]
then
cd /Users/artemnechunaev/devel/platform/eco/DXPServer/WebUI/VueJs
fi
if [ "$1" == "lib" ]
then
cd /Users/artemnechunaev/devel/platform/eco/DXPServer/WebUI/VueJsComponentLibrary
fi
if [ "$1" == "lib3" ]
then
cd /Users/artemnechunaev/devel/platform/eco/DXPServer/WebUI/VueJsComponentLibraryVue3
fi
if [ "$1" == "mf" ]
then
cd /Users/artemnechunaev/devel/platform/eco/DXPServer/Microfrontends
fi
}
###################
# Everything else #
###################
alias '!'='sudo !!'
alias h=history
alias history='fc -El 1'
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
batdiff() {
git diff --name-only --relative --diff-filter=d | xargs bat --diff $1
}
alias bathelp='bat --plain --language=help'
help() {
"$@" --help 2>&1 | bathelp
}
# export PYTHON=/opt/homebrew/bin/python3
export PYTHON=/Users/artemnechunaev/.pyenv/versions/2.7.18/bin/python2
export PATH=$PATH:/Users/artemnechunaev/.pyenv/versions/2.7.18/bin
# bind 'set show-all-if-ambiguous on'
# bind -s 'set completion-ignore-case on'
# bind 'TAB:menu-complete'
# bind '"\e[Z":menu-complete-backward'
# Key bindings, up/down arrow searches through history
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
bind '"\eOA": history-search-backward'
bind '"\eOB": history-search-forward'
eval "$(/opt/homebrew/bin/brew shellenv)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment