Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # .bashrc
- # Source global definitions
- if [ -f /etc/bashrc ]; then
- . /etc/bashrc
- fi
- # Uncomment the following line if you don't like systemctl's auto-paging feature:
- # export SYSTEMD_PAGER=
- # User specific aliases and functions
- bold='\[\e[1m\]'
- reset='\[\e[0m\]'
- textC='\e[38;5;'
- backC='\e[48;5;'
- noColor='0m'
- succBack='46m'
- failBack='160m'
- timeText='240m'
- timeBack='255m'
- hostText='255m'
- hostBack='236m'
- pathText='16m'
- pathBack='32m'
- gitText='255m'
- gitBack='236m'
- gitSText='255m'
- gitSBack='236m'
- mainBack='8m'
- botText='81m'
- #botStart=$'\xe2\x95\xb0\xe2\x95\xbc'
- #botStart=$'\xe2\x9c\x96'
- #botStart=$'\xe2\x9e\x9c \$'
- #botStart=$'\xe2\x91\x89'
- botStart=$'\xc2\xbb'
- bulletHead=$'\xee\x82\xb0'
- rBulletHead=$'\xee\x82\xb2'
- gitSymbolChar=$'\xee\x82\xa0'
- #dotSym=$'\xe2\x8f\xba'
- dotSym=$'\xe2\x9a\xab'
- get_back_color() {
- code=$1
- if [ "$code" != "0m" ]; then
- get_color $backC $code
- fi
- }
- get_text_color() {
- code=$1
- get_color $textC $code
- }
- get_color() {
- ignoreStart="\["
- ignoreEnd="\]"
- pref=$1
- code=$2
- printf "%s%s%s%s" "$ignoreStart" "$pref" "$code" "$ignoreEnd"
- }
- print_block() {
- str=$3
- if [ "$str" != "" ]; then
- textColor=`get_text_color $1`
- backColor=`get_back_color $2`
- printf "%s%s%s%s" "$reset" "$backColor" "$textColor" "$str"
- fi
- }
- get_user_size() {
- # +4 from the two spaces, the bullet and the "@".
- initSize=4
- user=`whoami`
- host=`hostname`
- userSize=$((${#user} + ${#host} + $initSize))
- echo $userSize
- }
- get_pwd_size() {
- # +3 from the two spaces and the bullet.
- # +2 from the other two spaces and the dot.
- initSize=$((3 + 2))
- userHome=`echo $HOME`
- path=`pwd`
- pathSize=${#path}
- if [ "$path" == "$userHome" ]; then
- # 1 from the "~" that will be left
- pathSize=1
- elif [ ! -z "`echo $path | grep $userHome`" ]; then
- # +2 from the "~" that will be added
- pathSize=$((${#path} - ${#userHome} + 1))
- fi
- pathSize=$(($pathSize + $initSize))
- echo $pathSize
- }
- get_git_size() {
- # +3 from the two spaces and the bullet.
- # +2 from the other two spaces and the dot.
- initSize=$((3 + 2))
- gitInfo=$1
- gitSize=0
- if [ ! -z "$gitInfo" ]; then
- ### +1 from symbol.
- gitSize=$((${#gitInfo} + $initSize + 1))
- fi
- echo $gitSize
- }
- get_time_size() {
- dotSize=0
- [ ! -z "$2" ]; dotSize=$2
- # +3 from the two spaces and the bullet.
- # + the size in
- initSize=$((3 + $dotSize))
- timeInfo=$1
- timeSize=0
- if [ ! -z $timeInfo ]; then
- timeSize=$((${#timeInfo} + $initSize))
- fi
- echo $timeSize
- }
- get_column_offset() {
- used=$1
- colNum=$COLUMNS
- while [ $colNum -lt $used ]; do
- colNum=$(($colNum + $COLUMNS))
- done
- offset=$(($colNum - $used))
- echo $offset
- }
- show_prompt() {
- if [ $? -eq 0 ]; then
- statusBack=$succBack
- else
- statusBack=$failBack
- fi
- statusBlock=`print_block $hostBack $statusBack $rBulletHead`
- hostBlock=`print_block $hostText $hostBack " \\u@\\h "`
- hostBullet=`print_block $hostBack $pathBack $bulletHead`
- pathBlock=`print_block $pathText $pathBack " \\w "`
- pathBullet=`print_block $pathBack $mainBack $bulletHead`
- leftDot=`print_block $noColor $pathBack $dotSym`
- gitBlock=""
- gitBullet=""
- gitSymbol=""
- timeInfo=`date +%T`
- timeBlock=`print_block $timeText $timeBack " $timeInfo "`
- timeBullet=`print_block $timeBack $mainBack $rBulletHead`
- rightDot=`print_block $noColor $timeBack $dotSym`
- gitInfo=$(__git_ps1)
- if [ ! -z "$gitInfo" ]; then
- ### Used when git is on the left
- # pathBullet=`print_block $pathBack $gitBack $bulletHead`
- ### Used when git is on the right
- timeBullet=`print_block $timeBack $gitBack $rBulletHead`
- gitBlock=`print_block $gitText $gitBack "$gitInfo "`
- gitBullet=`print_block $gitBack $mainBack $rBulletHead`
- gitSymbol=`print_block $gitSText $gitSBack "$gitSymbolChar "`
- rightDot=`print_block $noColor $gitBack $dotSym`
- fi
- termName="\[\e]0;\u@\h:\w\a\]"
- host="$hostBlock$hostBullet"
- path="$pathBlock$leftDot $pathBullet"
- ### Used when git is on the left
- # git="$gitBlock$gitBullet"
- ### Used when git is on the right
- git="$gitBullet$gitBlock$gitSymbol"
- time="$timeBullet$timeBlock"
- status="$statusBlock"
- if [ -z "$gitInfo" ]; then
- time="$timeBullet$rightDot $timeBlock"
- timeSize=2
- else
- git="$gitBullet$rightDot $gitBlock$gitSymbol"
- timeSize=0
- fi
- ### +1 from status.
- usedColumns=$((1 + `get_user_size` + `get_pwd_size` + `get_git_size "$gitInfo"` + `get_time_size $timeInfo $timeSize`))
- offset=`get_column_offset $usedColumns`
- #bottom=`print_block $botText $noColor $botStart`
- bottom=`print_block $botText $noColor "-=-"`
- ### Used when git is on the left
- # PS1="$termName`printf "%s%s%s%s%${offset}s%s" "$status" "$host" "$path" "$git" "" "$time"`$reset\n $bottom$reset "
- ### Used when git is on the right
- PS1="$termName`printf "%s%s%s%${offset}s%s%s%s" "$status" "$host" "$path" "" "$git" "$time"`$reset\n$bold$bottom$reset "
- # PS1="\[\e]0;\u@\h:\w\a\]$bold$whiteBox $thisTime $whiteToGreen$bulletHead$greenBox \u@\h $greenToBlue$bulletHead $blueBox\w $blueTo$bulletHead$redBox$gitInfo$gitBulletHead$reset\n$reset$bold$white$bot_start$reset "
- }
- PROMPT_COMMAND=show_prompt
- bashComp="/usr/share/bash-completion/bash_completion"
- [ -f $bashComp ]; . $bashComp
- gitPrompt="/etc/bash_completion.d/git-prompt"
- [ -f $gitPrompt ]; . $gitPrompt
- # Sourcing completions
- compFolder="/usr/share/bash-completion/completions"
- scripts=( "git" "apt" "apt-get" "apt-cache" "find" "cmake" "groupadd" "groupdel" \
- "modprobe" "mount" "gsettings" "ip" "java" "kill" "useradd" "userdel" "update-alternatives" )
- for script in ${scripts[@]}; do
- [ -f $compFolder/$script ]; . $compFolder/$script
- done
- # IBus utils
- export GTK_IM_MODULE=ibus
- export XMODIFIERS=@im=ibus
- export QT_IM_MODULE=ibus
- # Ssh anoyance
- export SSH_ASKPASS=
- # Default aliases
- alias ls='ls --color'
- alias grep='grep --color'
- alias tmux='TERM=screen-256color-bce tmux'
- # PATH configuration
- # export PATH=$PATH:/usr/local/cuda/bin
- screenfetch
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement