-
Notifications
You must be signed in to change notification settings - Fork 0
/
setprompt.sh
executable file
·45 lines (40 loc) · 974 Bytes
/
setprompt.sh
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
#!/bin/bash --
# this script is intended to be called in the context of
# the calling bash. thus all variables are not script-local
# and would exist after script is done. thats why variables
# are explicitly unset at the end.
GLOBAL_DIR=/usr/local/share
USER_DIR=~/.local
if [ -f $GLOBAL_DIR/Prompt_ori.txt ]; then
PDIR=$GLOBAL_DIR
elif [ -f $USER_DIR/Prompt_ori.txt ]; then
PDIR=$USER_DIR
else
PDIR=
fi
if [ "$1-" == "hide-" ]; then
echo -e "HIDE prompt ...\n'pshow' to restore original"
tput civis
sleep 2
if [ -n "$PDIR" ]; then
if [ -f $PDIR/Prompt_non.txt ]; then
PS1=`less ${PDIR}/Prompt_non.txt`
else
PS1='\e[0;30m'
fi
else
echo $PS1 > $USER_DIR/Prompt_ori.txt
PS1='\e[0;30m'
fi
clear
else
if [ -n "$PDIR" ]; then
PS1="`less ${PDIR}/Prompt_ori.txt` "
else
PS1='\[\e[0m\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
tput cnorm
fi
unset PDIR
unset GLOBAL_DIR
unset USER_DIR