-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathterminalSetting.bash
More file actions
30 lines (26 loc) · 1.17 KB
/
Copy pathterminalSetting.bash
File metadata and controls
30 lines (26 loc) · 1.17 KB
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
# Setting up .bashrc
echo "Bash Setting."
read -p "Hit enter: "
# enable force_color_prompt
if [[ `cat $HOME/.bashrc | grep '#force_color_prompt=yes'` ]]; then
before='#force_color_prompt=yes'
after='force_color_prompt=yes'
mv $HOME/.bashrc $HOME/.bashrcTmp
sed -e "s/$before/$after/g" $HOME/.bashrcTmp > $HOME/.bashrc
rm $HOME/.bashrcTmp
fi
# Preparetion
# PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '
# ''でかこう。ただし内部の'は'"'"'とする。
defaultPS1='PS1='"'"'${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '"'"''
myPS1='PS1='"'"'\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '"'"''
# Replacing for grep and sed. not for fgrep.
defaultPS1=$(echo $defaultPS1 | sed -e "s/\\\\/\\\\\\\\/g" -e "s/\\\$/\\\\\$/g" -e "s/\[/\\\[/g")
myPS1=$(echo $myPS1 | sed -e "s/\\\\/\\\\\\\\/g" -e "s/\\\$/\\\\\$/g" -e "s/\[/\\\[/g")
if [[ `cat $HOME/.bashrc | grep "$defaultPS1"` ]]; then
# echo "YES"
mv $HOME/.bashrc $HOME/.bashrcTmp
sed -e "s/$defaultPS1/$myPS1/g" $HOME/.bashrcTmp > $HOME/.bashrc
rm $HOME/.bashrcTmp
fi
source $HOME/.bashrc