Update fzf location
[dotfiles] / .bash_customization
1 #!/bin/sh
2 # my personal customization
3
4 # Current Format: [TIME USER@HOST PWD] >
5 # TIME:
6 # Green == machine load is low
7 # Orange == machine load is medium
8 # Red == machine load is high
9 # ALERT == machine load is very high
10 # USER:
11 # Cyan == normal user
12 # Orange == SU to user
13 # Red == root
14 # HOST:
15 # Cyan == local session
16 # Green == secured remote connection (via ssh)
17 # Red == unsecured remote connection
18 # PWD:
19 # Green == more than 10% free disk space
20 # Orange == less than 10% free disk space
21 # ALERT == less than 5% free disk space
22 # Red == current user does not have write privileges
23 # Cyan == current filesystem is size zero (like /proc)
24 # >:
25 # White == no background or suspended jobs in this shell
26 # Cyan == at least one background job in this shell
27 # Orange == at least one suspended job in this shell
28 #
29 # Command is added to the history file each time you hit enter,
30 # so it's available to all shells (using 'history -a').
31
32
33 # # Test connection type:
34 # if [ -n "${SSH_CONNECTION}" ]; then
35 # CNX=${Green} # Connected on remote machine, via ssh (good).
36 # elif [[ "${DISPLAY%%:0*}" != "" ]]; then
37 # CNX=${ALERT} # Connected on remote machine, not via ssh (bad).
38 # else
39 # CNX=${BCyan} # Connected on local machine.
40 # fi
41
42 # # Test user type:
43 # if [[ ${USER} == "root" ]]; then
44 # SU=${Red} # User is root.
45 # elif [[ ${USER} != $(logname) ]]; then
46 # SU=${BRed} # User is not login user.
47 # else
48 # SU=${BCyan} # User is normal (well ... most of us are).
49 # fi
50
51
52 # NCPU=$(grep -c 'processor' /proc/cpuinfo) # Number of CPUs
53 # SLOAD=$(( 100*${NCPU} )) # Small load
54 # MLOAD=$(( 200*${NCPU} )) # Medium load
55 # XLOAD=$(( 400*${NCPU} )) # Xlarge load
56
57 # # Returns system load as percentage, i.e., '40' rather than '0.40)'.
58 # function load()
59 # {
60 # local SYSLOAD=$(cut -d " " -f1 /proc/loadavg | tr -d '.')
61 # # System load of the current host.
62 # echo $((10#$SYSLOAD)) # Convert to decimal.
63 # }
64
65 # # Returns a color indicating system load.
66 # function load_color()
67 # {
68 # local SYSLOAD=$(load)
69 # if [ ${SYSLOAD} -gt ${XLOAD} ]; then
70 # echo -en ${ALERT}
71 # elif [ ${SYSLOAD} -gt ${MLOAD} ]; then
72 # echo -en ${Red}
73 # elif [ ${SYSLOAD} -gt ${SLOAD} ]; then
74 # echo -en ${BRed}
75 # else
76 # echo -en ${Green}
77 # fi
78 # }
79
80 # # Returns a color according to free disk space in $PWD.
81 # function disk_color()
82 # {
83 # if [ ! -w "${PWD}" ] ; then
84 # echo -en ${Red}
85 # # No 'write' privilege in the current directory.
86 # elif [ -s "${PWD}" ] ; then
87 # local used=$(command df -P "$PWD" |
88 # awk 'END {print $5} {sub(/%/,"")}')
89 # if [ ${used} -gt 95 ]; then
90 # echo -en ${ALERT} # Disk almost full (>95%).
91 # elif [ ${used} -gt 90 ]; then
92 # echo -en ${BRed} # Free disk space almost gone.
93 # else
94 # echo -en ${Green} # Free disk space is ok.
95 # fi
96 # else
97 # echo -en ${Cyan}
98 # # Current directory is size '0' (like /proc, /sys etc).
99 # fi
100 # }
101
102 # # Returns a color according to running/suspended jobs.
103 # function job_color()
104 # {
105 # if [ $(jobs -s | wc -l) -gt "0" ]; then
106 # echo -en ${BRed}
107 # elif [ $(jobs -r | wc -l) -gt "0" ] ; then
108 # echo -en ${BCyan}
109 # fi
110 # }
111
112 # # Adds some text in the terminal frame (if applicable).
113
114
115 # Now we construct the prompt.
116 # PROMPT_COMMAND="history -a"
117 # case ${TERM} in
118 # *term | rxvt | linux)
119 # # PS1="\[\$(load_color)\][\A\[${NC}\] "
120 # # Time of day (with load info):
121 # # PS1="\[\$(load_color)\][\A\[${NC}\] "
122 # # User@Host (with connection type info):
123 # PS1=${PS1}"\[${SU}\]\u\[${NC}\]@\[${CNX}\]\h\[${NC}\] "
124 # # PWD (with 'disk space' info):
125 # # PS1=${PS1}"\[\$(disk_color)\]\W]\[${NC}\] "
126 # # Prompt (with 'job' info):
127 # # PS1=${PS1}"\[\$(job_color)\]>\[${NC}\] "
128 # # Set title of current xterm:
129 # PS1=${PS1}"\[\e]0;[\u@\h] \w\a\]"
130 # ;;
131 # *)
132 # PS1="(\A \u@\h \W) > " # --> PS1="(\A \u@\h \w) > "
133 # # --> Shows full pathname of current dir.
134 # ;;
135 # esac
136
137
138
139 # export TIMEFORMAT=$'\nreal %3R\tuser %3U\tsys %3S\tpcpu %P\n'
140 # export HISTIGNORE="&:bg:fg:ll:h"
141 # export HISTTIMEFORMAT="$(echo -e ${BCyan})[%d/%m %H:%M:%S]$(echo -e ${NC}) "
142 # export HISTCONTROL=ignoredups
143 # export HOSTFILE=$HOME/.hosts # Put a list of remote hosts in ~/.hosts