-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
145 lines (132 loc) · 3.67 KB
/
.bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# ~/.bashrc: executed by bash(1) for non-login shells.
# if not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# vi mode
set -o vi
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# if set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
shopt -s globstar
# disable completion when the input buffer is empty. i.e. hitting tab
# and waiting a long time for bash to expand all of $PATH.
shopt -s no_empty_cmd_completion
# append to the history file, don't overwrite it
shopt -s histappend
# ~/.bash_variables
if [[ -f ~/.bash_variables ]]; then
. ~/.bash_variables
fi
# make less more friendly for non-text input files, see lesspipe(1)
[[ -x /usr/bin/lesspipe ]] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [[ -z "${debian_chroot:-}" ]] && [[ -r /etc/debian_chroot ]]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
if [[ -z "${FORCE_COLOR_PS1}" ]] && [[ "${TERM}" == "linux" ]]; then
PS1='${debian_chroot:+($debian_chroot)}\u@\H:\w\$ '
else
set_prompt() {
local last_command=$?
local reset='\[\e[0m\]'
#local black='\[\e[0;30m\]'
local red='\[\e[0;31m\]'
local green='\[\e[0;32m\]'
local yellow='\[\e[0;33m\]'
local blue='\[\e[0;34m\]'
local magenta='\[\e[0;35m\]'
local cyan='\[\e[0;36m\]'
local white='\[\e[0;37m\]'
#local bblack='\[\e[1;30m\]'
#local bred='\[\e[1;31m\]'
#local bgreen='\[\e[1;32m\]'
#local byellow='\[\e[1;33m\]'
local bblue='\[\e[1;34m\]'
#local bmagenta='\[\e[1;35m\]'
#local bcyan='\[\e[1;36m\]'
#local bwhite='\[\e[1;37m\]'
#local crossIcon='\342\234\227'
#local checkmarkIcon='\342\234\223'
# line one
PS1="\n┌─["
# user@host
if [[ $EUID == 0 ]]; then
PS1+="${red}\\u${green}@${blue}\\h${reset}"
else
PS1+="${yellow}\\u${green}@${blue}\\h${reset}"
fi
# datetime
PS1+="](${cyan}\\t${reset})"
# work dir
PS1+="[${bblue}\\w${reset}] "
# git
if [[ -n "$(command -v __git_ps1)" ]]; then
local fstype="$(df --output=fstype . 2> /dev/null | tail -n +2)"
if [[ "${fstype}" != *"fuse.sshfs"* ]]; then
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
PS1+=$(__git_ps1 "${magenta}{%s}${reset}")
fi
fi
# line two
PS1+="\n└─"
# exit code
if [[ $last_command != 0 ]]; then
PS1+="[${red}\$?${reset}]─"
fi
# ssh
if [[ -n "${SSH_CLIENT}" ]]; then
PS1+="(${green}ssh${reset})-"
fi
# chroot
if [[ -n "${debian_chroot}" ]]; then
PS1+="(${white}chroot${reset})-"
fi
# venv
if [[ -n "${VIRTUAL_ENV}" ]]; then
PS1+="(${white}venv${reset})─"
VIRTUAL_ENV_DISABLE_PROMPT=1
fi
# vim subshell or fg
if [[ -n "${VIMRUNTIME}" ]] || jobs -l | grep -q 'vim'; then
PS1+="(${white}vim${reset})-"
fi
# screen
if [[ "${TERM}" =~ ^"screen." ]]; then
PS1+="(${white}screen${reset})-"
fi
# $ for user, # for root
PS1+="${white}\\\$${reset} "
}
if [[ -n "${PROMPT_COMMAND}" ]]; then
PROMPT_COMMAND="set_prompt; ${PROMPT_COMMAND}"
else
PROMPT_COMMAND="set_prompt"
fi
# colour coreutils
eval $(dircolors -b $HOME/.dircolors)
fi
# ~/.bash_local
if [[ -f ~/.bash_local ]]; then
. ~/.bash_local
fi
# ~/.bash_functions
if [[ -f ~/.bash_functions ]]; then
. ~/.bash_functions
fi
# ~/.bash_aliases
if [[ -f ~/.bash_aliases ]]; then
. ~/.bash_aliases
fi
# enable programmable completion features
if ! shopt -oq posix; then
if [[ -f /usr/share/bash-completion/bash_completion ]]; then
. /usr/share/bash-completion/bash_completion
elif [[ -f /etc/bash_completion ]]; then
. /etc/bash_completion
fi
fi