-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·140 lines (117 loc) · 3.12 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·140 lines (117 loc) · 3.12 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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
git_prompt () {
OK='\033[32m' ;
KO='\033[31m' ;
GIT_STATUS="$( git status | grep 'Your branch is up to date' )" ;
if [ "$GIT_STATUS" ]
then
echo "$OK`git branch -a | cat | grep '\*' | cut -d' ' -f2`" ;
else
echo "$KO`git branch -a | cat | grep '\*' | cut -d' ' -f2`" ;
fi
}
px_set_prompt () {
RESET='\033[0m'
export PS1="\u@\h|\w [$?]"
if [ "$(git status | wc -l)" -eq '4' ]
then
export PS1="$PS1(\033[32m`git_prompt`$RESET)\n> "
else
export PS1="$PS1(\033[31m`git_prompt`$RESET)\n> "
fi
}
px_choose_shell () {
SHELL_OK=`cat /etc/shells | sed -e '/^#/d' | sed -e '/^$/d'` ;
echo "Your current shell: $SHELL" ;
select var in $SHELL_OK
do
if [ "$var" ]
then
echo "You choose $var" ;
break ;
fi
done ;
}
add_cd_path () {
for i in $@
do
if [ ! "$(echo $CDPATH | tr ':' '\n' | grep \'$i'$'\')" ]
then
export CDPATH="${CDPATH:+$CDPATH:}$i"
fi
done
}
pimpx_set_xdg () {
if [ ! "$XDG_DATA_HOME" ]
then
export XDG_DATA_HOME="$HOME/.local/share"
mkdir -p "$XDG_DATA_HOME"
chmod 0700 "$XDG_DATA_HOME"
fi
if [ ! "$XDG_CONFIG_HOME" ]
then
export XDG_CONFIG_HOME="$HOME/.config"
mkdir -p "$XDG_CONFIG_HOME"
chmod 0700 "$XDG_CONFIG_HOME"
fi
if [ ! "$XDG_DATA_DIRS" ]
then
export XDG_DATA_DIRS="/usr/local/share/:/usr/share/"
fi
if [ ! "$XDG_CONFIG_DIRS" ]
then
export XDG_CONFIG_DIRS="/etc/xdg"
fi
if [ ! "$XDG_CACHE_HOME" ]
then
export XDG_CACHE_HOME="$HOME/.cache"
mkdir -p "$XDG_CACHE_HOME"
chmod 0700 "$XDG_CACHE_HOME"
fi
}
pimpx_launch () {
pimpx_set_xdg
}
pimpx_rc () {
PIMPXRC="$PIMPX/pimpx.rc"
echo '#- Pimp X Configuration file -#' > "$PIMPXRC"
echo "PIMPX='$PIMPX'" >> "$PIMPXRC"
echo '#- Load pimpx functions in pimpx/functions -#' >> "$PIMPXRC"
echo "for i in \`ls $PIMPX/functions\` ;\n do ;\n source \"$PIMPX/functions/\$i\" ;\n done" >> "$PIMPXRC"
}
pimpx_install () {
cat <<-EOF
██████╗ ██╗███╗ ███╗██████╗ ██╗ ██╗
██╔══██╗██║████╗ ████║██╔══██╗ ╚██╗██╔╝
██████╔╝██║██╔████╔██║██████╔╝ ╚███╔╝
██╔═══╝ ██║██║╚██╔╝██║██╔═══╝ ██╔██╗
██║ ██║██║ ╚═╝ ██║██║ ██╔╝ ██╗
╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
EOF
echo "## \/ Pimp X uninstall function \/ ##
pimpx_uninstall () {
echo 'Good Bye, friend..\n See you soon.'
rm -rf '$PIMPX'
echo 'BYBYEE'
}" > "$PIMPX/functions/pimpx_unistall.sh"
echo "Default shell: $SHELL"
pimpx_set_xdg
export PIMPX="$XDG_CONFIG_HOME/pimpx"
if [ -d "$PIMPX" ]
then
echo "Pimpx already installed :)"
read -p "Update ? (y/n): " stdin
if [ "$stdin" = 'y' ]
then
cd "$PIMPX" && git pull && echo "Now up-to-date :)"
fi
else
echo "Installing PimpX here: $PIMPX"
if [ "$(git --version | grep version)" ]
then
git clone https://github.com/thdelmas/pimpx "$PIMPX"
fi
pimpx_rc
echo "PimpX is now installed"
fi
}
pimpx_install