From 054cd5e1e3491e1ff6db2afa767db4eb442b6fff Mon Sep 17 00:00:00 2001 From: ziro Date: Sat, 11 Apr 2020 18:03:04 +0700 Subject: [PATCH] + Added .bashrc --- .bashrc | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 .bashrc diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..117b7a1 --- /dev/null +++ b/.bashrc @@ -0,0 +1,127 @@ +# +# ~/.bashrc +# + +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +alias ls='ls --color=auto' + +# get current branch in git repo +function parse_git_branch() { + BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` + if [ ! "${BRANCH}" == "" ] + then + STAT=`parse_git_dirty` + echo " [${BRANCH}${STAT}]" + else + echo "" + fi +} + +# get current status of git repo +function parse_git_dirty { + status=`git status 2>&1 | tee` + dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"` + untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"` + ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?"` + newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?"` + renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?"` + deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?"` + bits='' + if [ "${renamed}" == "0" ]; then + bits=">${bits}" + fi + if [ "${ahead}" == "0" ]; then + bits="*${bits}" + fi + if [ "${newfile}" == "0" ]; then + bits="+${bits}" + fi + if [ "${untracked}" == "0" ]; then + bits="?${bits}" + fi + if [ "${deleted}" == "0" ]; then + bits="x${bits}" + fi + if [ "${dirty}" == "0" ]; then + bits="!${bits}" + fi + if [ ! "${bits}" == "" ]; then + echo " ${bits}" + else + echo "" + fi +} + +function _myps1() { + local __name_hostname="\[$(tput bold)\]\[\033[38;5;45m\]\u\[$(tput sgr0)\]@\[$(tput sgr0)\]\[$(tput bold)\]\[\033[38;5;45m\]\h\[$(tput sgr0)\]" + local __space="\[$(tput sgr0)\]" + local __git_branch='`parse_git_branch`' + local __git_status='`parse_git_dirty`' + local __ps1end="\[\033[00m\]$> $__space" + local __dir="\[\033[38;5;7m\]\w" + PS1="$__name_hostname $__space$__dir$__git_branch $__ps1end" +} +_myps1 + +pfetch + +#function _update_ps1() { +# PS1=$(powerline-shell $?) +#} + +#if [[ $TERM != linux && ! $PROMPT_COMMAND =~ _update_ps1 ]]; then +# PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND" +#fi + +#Aliases +export EDITOR="nvim" +export BROWSER='firefox' +export TERMINAL='urxvt' + +#Askpass +export SUDO_ASKPASS=/usr/bin/rofi-askpass +export XDG_CACHE_HOME="$HOME/.cache" +export XDG_DATA_HOME="$HOME/.local/share" +export XDG_CONFIG_HOME="$HOME/.config" + +#vim +export VIMINIT='let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" | source $MYVIMRC' + +#Aliases +alias vim='nvim' +alias weather='curl wttr.in' +alias pac='sudo pacman' +alias aur='yay' +alias spotifyrip='spotify-ripper -u palembani@gmail.com' +alias xreload='xrdb ~/.Xresources' +alias ytv='youtube-viewer' +alias yt='youtube-dl' +alias ytaudio='youtube-dl -x --audio-format' +alias gravit='~/my\ Files/Gravit/GravitDesigner.AppImage' +alias redoom='~/doom refresh' +alias config='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME' +alias rvim='sudo vim' +alias py='python' +alias ps2c='sudo sh $HOME/.scripts/ps2c' +alias cls='clear' +alias classprop='xprop WM_CLASS' +alias storagelist='lsblk -f' +alias ..='cd ..' +alias ls='exa --color=auto' +alias ll='ls -alF' +alias l='ls -CF' +alias la='ls -A' +alias cfvim='vim $XDG_CONFIG_HOME/vim/vimrc' +alias cfbash='vim $HOME/.bashrc' +alias cfbsp='vim $XDG_CONFIG_HOME/bspwm/bspwmrc' +alias cfpoly='vim $XDG_CONFIG_HOME/polybar/config' +alias cfkeys='vim $XDG_CONFIG_HOME/sxhkd/sxhkdrc' +alias htop='htop -t' + +#Git Aliases +alias gs='git status' +alias gaa='git add --all' +alias gcm='git commit -m' +alias gp='git push'