/
.bash-functions
78 lines (63 loc) · 1.4 KB
/
.bash-functions
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
# functions
term_title() {
printf "\033]0;%s\007" $1
}
# job control
cdjob() {
local d
: ${1:?"usage $FUNCNAME %N"}
d=$(jobs $1 | perl -lane 'print "cd $1" if m/.*\(wd: (.*)\).*/')
test "$d" && eval $d
}
# for new git installations
git-useradd() {
case "${1:-}" in
jsh)
git config --global user.name "Jeffrey S. Haemer"
git config --global user.email "jeffrey.haemer@gmail.com"
;;
*)
echo "Unknown user '$1'" >&2
;;
esac
}
pylint() {
command pylint -rn $* | sort -t: -k2 -n -r
}
return
# What follows is prompt customization, which may not be something you want.
# set up a pair of prompts -- one for success, one for failure
export _r="\[\e[01;31m\]"
export _g="\[\e[01;32m\]"
export _n="\[\e[0m\]"
_success=${_g}'\$'${_n}' '
_failure=${_r}'\$'${_n}' '
prompt() {
if ! [[ "${1:-}" ]]; then
echo $prompt_type
return 0
fi
oprompt_type=$prompt_type
prompt_type=$1
case $prompt_type in
short) _base='' ;;
normal) _base='\u@\h:\W' ;;
long) _base='\u@\h:\w' ;;
GutH) _base='\w' ;;
time) _base='[\t] ' ;;
off) unset PROMPT_COMMAND
*) echo 'usage: prompt [short|normal|long|GutH|time|off]' >&2
prompt_type=$oprompt_type
;;
esac
}
put_prompt() {
if [[ $? == 0 ]]; then
PS1=$_base$_success
else
PS1=$_base$_failure
fi
term_title $PWD
}
export PROMPT_COMMAND=put_prompt
prompt normal