-
Notifications
You must be signed in to change notification settings - Fork 32
/
.sushrc
67 lines (55 loc) · 1.8 KB
/
.sushrc
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
case $- in
*i*) ;;
*) return;;
esac
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
build_profile=$([[ "$BASH_VERSION" == *-release ]] || echo "(${BASH_VERSION##*-})")
if [ "$color_prompt" = yes ]; then
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\b\[\033[00m\]\[\033[01;35m\]\w\[\033[00m\]'$build_profile'🍣 '
else
PS1='\u@\h:\w'$build_profile'🍣 '
fi
case "$TERM" in
xterm*|rxvt*)
PS1="\[\033]2;\u@\h: \w\007\]$PS1"
;;
*)
;;
esac
PS2='> '
PS4='+ '
alias ll='ls -l'
alias git-writing='git add -A ; git commit -m Writing ; git push'
# completion test
# thanks to: https://blog.cybozu.io/entry/2016/09/26/080000
_dummy () {
COMPREPLY=( $(compgen -W "one two" -- "${cur}" ) )
} && complete -F _dummy hoge
_git_comp () {
if [ "$COMP_CWORD" = 1 ] ; then
CANDS=( $( git |& grep '^ *[a-z]' | awk '{print $1}') )
COMPREPLY=( $(compgen -W "${CANDS[@]}" -- "${cur}") )
elif [ "$COMP_CWORD" = 2 -a "$prev" = switch ] ; then
COMPREPLY=( $(compgen -W "$( git branch | tr -d '*' )" -- "${cur}" ) )
elif [ "$COMP_CWORD" = 2 -a "$prev" = merge ] ; then
COMPREPLY=( $(compgen -W "$( git branch | tr -d '*' )" -- "${cur}" ) )
elif [ "$COMP_CWORD" = 2 -a "$prev" = diff ] ; then
COMPREPLY=( $(compgen -W "$( git branch | tr -d '*' ) $(compgen -f)" -- "${cur}" ) )
fi
} && complete -F _git_comp git
_colcon_comp () {
if [ "$COMP_CWORD" = 1 ] ; then
CANDS=( $( colcon |& sed -n 2p | tr , \\n | tr -d '{} ' ) )
COMPREPLY=( $(compgen -W "${CANDS[@]}" -- "${cur}") )
fi
} && complete -F _colcon_comp colcon
complete -u groups w
complete -j -P '"%' -S '"' disown fg jobs
complete -A stopped -P '"%' -S '"' bg
command_not_found_handle() {
if [ -e /usr/lib/command-not-found ] ; then
/usr/lib/command-not-found -- "$1"
fi
}