Last active
April 8, 2021 11:57
-
-
Save mfurquimdev/50b23f01c01cf41addf0ec874a1ed715 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # System-wide .bashrc file for interactive bash(1) shells. | |
| if [ -z "$PS1" ]; then | |
| return | |
| fi | |
| # Make bash check its window size after a process completes | |
| shopt -s histappend | |
| shopt -s checkwinsize | |
| bind 'set show-all-if-ambiguous off' | |
| bind 'set completion-ignore-case on' | |
| [ -r "/etc/bashrc_$TERM_PROGRAM" ] && . "/etc/bashrc_$TERM_PROGRAM" | |
| export CLICOLORS=1 | |
| # Original Colors | |
| # LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:'; | |
| # export LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=38;5;153;01:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:'; | |
| # Disallow existing regular files to be overwritten by redirection of shell output | |
| set -o noclobber | |
| shopt -s histappend | |
| bind 'set show-all-if-ambiguous off' | |
| bind 'set completion-ignore-case on' | |
| cd () { builtin cd "$@" && chpwd; } | |
| chpwd () { | |
| if [ -d "$PWD/venv" ]; then | |
| source ./venv/bin/activate | |
| fi | |
| } | |
| function p() { | |
| for f in *; do | |
| if [ -f "$f" ]; then | |
| if [[ ! $f == *.png ]]; then | |
| echo -e "\033[38;1;32m$f\033[38;1;0m"; | |
| cat "$f"; | |
| echo ""; | |
| fi; | |
| fi; | |
| done; | |
| } | |
| alias j="\vim -p ~/.vimjournal/\"\$(date '+Week %W-%Y').md\" ${HOME}/.mfurquim.ledger" | |
| alias l="\vim -O ~/.ledger/\"\$(date '+%Y_%b').ledger\" ~/.ledger/\"\$(date --date=\"last month\" '+%Y_%b').ledger\"" | |
| alias gl='git log --graph --pretty="%C(yellow)%h %C(red)%d %Creset%s %C(blue)%aN %C(black)%ar"' | |
| alias ga='git add' | |
| alias gap='git add -p' | |
| alias gs='git status' | |
| alias gc='git commit' | |
| alias gcm='git commit -m' | |
| alias gca='git commit --amend --no-edit' | |
| alias gd='git diff' | |
| alias gds='git diff --staged' | |
| alias gp='git push' | |
| alias gk='git checkout' | |
| alias gb='git branch' | |
| alias gr='git rebase master' | |
| alias grc='git rebase --continue' | |
| alias mv='\mv -v' | |
| alias rm='\rm -v' | |
| alias cp='\cp -v' | |
| alias mkdir='\mkdir -pv' | |
| alias chown='\chown -v' | |
| alias chmod='\chmod -v' | |
| alias vim='\vim -p' | |
| alias cat='bat --paging=never --theme=Nord --style=snip,header,grid' | |
| alias ls='\ls -vXF --color=always --group-directories-first' | |
| alias lr='\ls -vXFrt1 --color=always --group-directories-first' | |
| alias tree='\tree --dirsfirst -FC -I "__pycache__|venv"' | |
| alias grepc='\grep --colour --exclude-dir=.venv' | |
| alias grep='\grep --colour -EIin --exclude-dir=.venv' | |
| alias cal='\cal -m' | |
| alias pac='sudo pacman --noconfirm' | |
| alias bunny="echo -e \"(\ /)\n( . .)\nc(\033[38;1;31m\\\"\033[38;1;0m)(\033[38;1;31m\\\"\033[38;1;0m)\"" | |
| # Eternal bash history. | |
| # --------------------- | |
| # Undocumented feature which sets the size to "unlimited". | |
| # http://stackoverflow.com/questions/9457233/unlimited-bash-history | |
| export HISTFILESIZE= | |
| export HISTSIZE= | |
| export HISTTIMEFORMAT="[%F %T] " | |
| # Change the file location because certain bash sessions truncate .bash_history file upon close. | |
| # http://superuser.com/questions/575479/bash-history-truncated-to-500-lines-on-each-login | |
| export HISTFILE=~/.bash_eternal_history | |
| # Bash history: “ignoredups” and “erasedups” setting conflict with common history across sessions | |
| # https://unix.stackexchange.com/questions/18212/bash-history-ignoredups-and-erasedups-setting-conflict-with-common-history/18443#18443?newreg=ad3ea662cd754c148058a0c44d22102f | |
| # https://www.linuxjournal.com/content/using-bash-history-more-efficiently-histcontrol | |
| HISTCONTROL=ignorespace:ignoredups:erasedups | |
| shopt -s histappend | |
| PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND" | |
| ESC=$(printf "\e") | |
| F_RED="$ESC[0;9;31m" | |
| F_GREEN="$ESC[0;0;32m" | |
| PS1='' | |
| function parse_git_branch() { | |
| git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
| } | |
| function prompt_right() { | |
| # echo -e "\033[38;5;8m$(date '+%a, %b %d - %H:%M:%S')\033[0m" | |
| echo -e "\033[0;0;2m$(date '+%a, %b %d - %H:%M:%S')\033[0m" | |
| } | |
| function prompt_left() { | |
| # https://www.tutorialkart.com/bash-shell-scripting/bash-split-string/ | |
| str=$(pwd) | |
| oldest="" | |
| old="" | |
| current="" | |
| IFS='/' # hyphen (/) is set as delimiter | |
| read -ra ADDR <<< "$str" # str is read into an array as tokens separated by IFS | |
| for i in "${ADDR[@]}"; do # access each element of array | |
| oldest="$old" | |
| old="$current" | |
| current="$i" | |
| done | |
| IFS=' ' # reset to default value after usage | |
| path="" | |
| if [ -z "$oldest" ] | |
| then | |
| if [ -z "$old" ] | |
| then | |
| path="/$current" | |
| else | |
| path="$old/$current" | |
| fi | |
| else | |
| path="$oldest/$old/$current" | |
| fi | |
| VENV="" | |
| if [ $VIRTUAL_ENV ] | |
| then | |
| VENV=" \033[0;0;4m$(basename "$VIRTUAL_ENV")" | |
| fi | |
| # echo -e "\u\033[38;1;97m@\033[38;1;0m\h\033[38;5;7m\033[72;1;34m [$path]\033[38;1;93m$(parse_git_branch)\033[0;1;0m" | |
| echo -e "\u\033[0;1;1m@\033[0;0;34m[$path]\033[0;0;33m$(parse_git_branch)$VENV\033[0;1;0m" | |
| } | |
| function prompt() { | |
| if [[ $? == 0 ]]; then | |
| err=0 | |
| err_color=$F_GREEN | |
| else | |
| err=1 | |
| err_color=$F_RED | |
| fi | |
| compensate=12 | |
| PS1=$(printf "%*s\r%s\n\$ " "$(($(tput cols)+${compensate}))" "$(prompt_right)" "$(echo -n $err_color)$(prompt_left)") | |
| # Force prompt to write history after every command. | |
| # http://superuser.com/questions/20900/bash-history-loss | |
| history -a; history -c; history -r | |
| } | |
| export PROMPT_COMMAND=prompt';export PREV_COMMAND=""' | |
| # The next line updates PATH for the Google Cloud SDK. | |
| if [ -f '/opt/google-cloud-sdk/path.bash.inc' ]; then . '/opt/google-cloud-sdk/path.bash.inc'; fi | |
| # The next line enables shell command completion for gcloud. | |
| if [ -f '/opt/google-cloud-sdk/completion.bash.inc' ]; then . '/opt/google-cloud-sdk/completion.bash.inc'; fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment