Last active
July 10, 2020 16:23
-
-
Save thiagolsfortunato/1314ddbc021586e17434b7377c523a6f to your computer and use it in GitHub Desktop.
my custom manjaro .bashrc
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
# shellcheck shell=bash | |
# ~/.bashrc | |
# | |
[[ $- != *i* ]] && return | |
colors() { | |
local fgc bgc vals seq0 | |
printf "Color escapes are %s\n" '\e[${value};...;${value}m' | |
printf "Values 30..37 are \e[33mforeground colors\e[m\n" | |
printf "Values 40..47 are \e[43mbackground colors\e[m\n" | |
printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n" | |
# foreground colors | |
for fgc in {30..37}; do | |
# background colors | |
for bgc in {40..47}; do | |
fgc=${fgc#37} # white | |
bgc=${bgc#40} # black | |
vals="${fgc:+$fgc;}${bgc}" | |
vals=${vals%%;} | |
seq0="${vals:+\e[${vals}m}" | |
printf " %-9s" "${seq0:-(default)}" | |
printf " ´-=-m------------------------------------------ǘn,ji,;lj/ljggj,;k..km.ŋ ·̉·̉ ......jjjjjj./mmg mk,,ç,ç mv vmv mko0j;jp0- vm v ${seq0}TEXT\e[m" | |
printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m" | |
done | |
echo; echo | |
done | |
} | |
# Change the window title of X terminals | |
case ${TERM} in | |
xterm*|rxvt*|Eterm*|aterm|kterm|gnome*|interix|konsole*) | |
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#"$HOME"/\~}\007"' | |
;; | |
screen*) | |
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#"$HOME"/\~}\033\\"' | |
;; | |
esac | |
use_color=true | |
# Set colorful PS1 only on colorful terminals. | |
# dircolors --print-database uses its own built-in database | |
# instead of using /etc/DIR_COLORS. Try to use the external file | |
# first to take advantage of user additions. Use internal bash | |
# globbing instead of external grep binary. | |
safe_term=${TERM//[^[:alnum:]]/?} # sanitize TERM | |
match_lhs="" | |
[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)" | |
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)" | |
[[ -z ${match_lhs} ]] \ | |
&& type -P dircolors >/dev/null \ | |
&& match_lhs=$(dircolors --print-database) | |
[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
if ${use_color} ; then | |
# Enable colors for ls, etc. Prefer ~/.dir_colors #64489 | |
if type -P dircolors >/dev/null ; then | |
if [[ -f ~/.dir_colors ]] ; then | |
eval $(dircolors -b ~/.dir_colors) | |
elif [[ -f /etc/DIR_COLORS ]] ; then | |
eval $(dircolors -b /etc/DIR_COLORS) | |
fi | |
fi | |
if [[ ${EUID} == 0 ]] ; then | |
PS1='\[\033[01;32m\][\[\033[01;36m\]./\W/\[\033[01;32m\]]\[\033[01;33m\]$(parse_git_branch)\[\033[01;39m\]\n\[\033[01;32m\]\$\[\033[00m\] ' | |
else | |
PS1='\[\033[01;32m\][\[\033[01;36m\]./\W/\[\033[01;32m\]]\[\033[01;33m\]$(parse_git_branch)\[\033[01;39m\]\n\[\033[01;32m\]\$\[\033[00m\] ' | |
fi | |
else | |
if [[ ${EUID} == 0 ]] ; then | |
# show root@ when we don't have colors | |
PS1='\u@\h \W \$ ' | |
else | |
PS1='\u@\h \W \$ ' | |
fi | |
fi | |
unset use_color safe_term match_lhs sh | |
xhost +local:root > /dev/null 2>&1 | |
complete -cf sudo | |
# Bash won't get SIGWINCH if another process is in the foreground. | |
# Enable checkwinsize so that bash will check the terminal size when | |
# it regains control. #65623 | |
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11) | |
shopt -s checkwinsize | |
shopt -s expand_'alias'es | |
# export QT_SELECT=4 | |
# Enable history appending instead of overwriting. #139609 | |
shopt -s histappend | |
# | |
# # ex - archive extractor | |
# # usage: ex <file> | |
extract () { | |
if [ -f $1 ] ; then | |
case $1 in | |
*.tar.bz2) tar xjf $1 ;; | |
*.tar.gz) tar xzf $1 ;; | |
*.bz2) bunzip2 $1 ;; | |
*.rar) unrar x $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 ex()" ;; | |
esac | |
else | |
echo "'$1' is not a valid file" | |
fi | |
} | |
# better yaourt colors | |
export YAOURT_COLORS="nb=1:pkg=1:ver=1;32:lver=1;45:installed=1;42:grp=1;34:od=1;41;5:votes=1;44:dsc=0:other=1;35" | |
SSH_ENV=""$HOME"/.ssh/environment" | |
function start_agent { | |
echo "Initialising new SSH agent..." | |
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" | |
echo succeeded | |
chmod 600 "${SSH_ENV}" | |
. "${SSH_ENV}" > /dev/null | |
/usr/bin/ssh-add; | |
} | |
# Source SSH settings, if applicable | |
if [ -f "${SSH_ENV}" ]; then | |
. "${SSH_ENV}" > /dev/null | |
#ps ${SSH_AGENT_PID} doesn't work under cywgin | |
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || { | |
start_agent; | |
} | |
else | |
start_agent; | |
fi | |
[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion | |
# autocomplete vault | |
#complete -C '/usr/local/bin/vault' vault | |
# autocomplete for awscli install via pip --user | |
complete -C '/home/thiagofortunato/.local/bin/aws_completer' aws | |
# complete -C '/usr/bin/aws_completer' aws | |
# load my .'alias' | |
[[ -s ~/.alias_rc ]] && source ~/.alias_rc | |
[[ -s ~/.bash_aliases ]] && source ~/.bash_aliases | |
[[ -s ~/.kubectl_aliases ]] && source ~/.kubectl_aliases && | |
source <(kubectl completion bash) | |
complete -F __start_kubectl k | |
[[ -s ~/.docker_aliases ]] && source ~/.docker_aliases && | |
[[ -s ~/.git_aliases ]] && source ~/.git_aliases | |
[[ -s /usr/share/bash-completion/completions/git ]] && \ | |
source /usr/share/bash-completion/completions/git && \ | |
complete -o default -o nospace -F _git g | |
#SET ENVIRONMENTS PATHS | |
export PATH="$PATH":"$HOME"/scripts | |
export GOPATH="$HOME"/go | |
export PATH="$PATH":"$GOPATH"/bin | |
export VISUAL=vim | |
export EDITOR="$VISUAL" | |
export PATH="$PATH":"$HOME"/.pulumi/bin | |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" | |
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change. | |
export PATH="$PATH":"$HOME"/.rvm/bin | |
LS_COLORS='rs=0:di=01;36: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:*.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 | |
xset b off | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment