1+ #! /bin/sh -e
2+
3+ . ../common-script.sh
4+
5+ gitpath=" $HOME /.local/share/mybash"
6+
7+ cloneMyBash () {
8+ mkdir -p " $HOME /.local/share" # Only create the dir if it doesn't exist.
9+ cd " $HOME " && git clone https://github.com/ChrisTitusTech/mybash.git " $gitpath "
10+ }
11+
12+ installDepend () {
13+ echo " Install mybash if not already installed"
14+ case " $PACKAGER " in
15+ pacman)
16+ $ESCALATION_TOOL " $PACKAGER " -S --needed --noconfirm bash bash-completion tar bat tree unzip fontconfig
17+ ;;
18+ apt)
19+ $ESCALATION_TOOL " $PACKAGER " install -y bash bash-completion tar bat tree unzip fontconfig
20+ ;;
21+ dnf)
22+ $ESCALATION_TOOL " $PACKAGER " install -y bash bash-completion tar bat tree unzip fontconfig
23+ ;;
24+ zypper)
25+ $ESCALATION_TOOL " $PACKAGER " install -y bash bash-completion tar bat tree unzip fontconfig
26+ ;;
27+ * )
28+ printf " %b\n" " ${RED} Unsupported package manager: $PACKAGER ${RC} " # The packages above were grabbed out of the original mybash-setup-script.
29+ exit 1
30+ ;;
31+ esac
32+ }
33+
34+ installFont () {
35+ # Check to see if the MesloLGS Nerd Font is installed (Change this to whatever font you would like)
36+ FONT_NAME=" MesloLGS Nerd Font Mono"
37+ if fc-list :family | grep -iq " $FONT_NAME " ; then
38+ echo " Font '$FONT_NAME ' is installed."
39+ else
40+ echo " Installing font '$FONT_NAME '"
41+ # Change this URL to correspond with the correct font
42+ FONT_URL=" https://github.com/ryanoasis/nerd-fonts/releases/latest/download/Meslo.zip"
43+ FONT_DIR=" $HOME /.local/share/fonts"
44+ TEMP_DIR=$( mktemp -d)
45+ curl -sSLo " $TEMP_DIR " /" ${FONT_NAME} " .zip " $FONT_URL "
46+ unzip " $TEMP_DIR " /" ${FONT_NAME} " .zip -d " $TEMP_DIR "
47+ mkdir -p " $FONT_DIR " /" $FONT_NAME "
48+ mv " ${TEMP_DIR} " /* .ttf " $FONT_DIR " /" $FONT_NAME "
49+ fc-cache -fv
50+ rm -rf " ${TEMP_DIR} "
51+ echo " '$FONT_NAME ' installed successfully."
52+ fi
53+ }
54+
55+ installStarshipAndFzf () {
56+ if command_exists starship; then
57+ echo " Starship already installed"
58+ return
59+ fi
60+
61+ if ! curl -sSL https://starship.rs/install.sh | sh; then
62+ printf " %b\n" " ${RED} Something went wrong during starship install!${RC} "
63+ exit 1
64+ fi
65+ if command_exists fzf; then
66+ echo " Fzf already installed"
67+ else
68+ git clone --depth 1 https://github.com/junegunn/fzf.git ~ /.fzf
69+ $ESCALATION_TOOL ~ /.fzf/install
70+ fi
71+ }
72+
73+ installZoxide () {
74+ if command_exists zoxide; then
75+ echo " Zoxide already installed"
76+ return
77+ fi
78+
79+ if ! curl -sSL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh; then
80+ printf " %b\n" " ${RED} Something went wrong during zoxide install!${RC} "
81+ exit 1
82+ fi
83+ }
84+
85+ linkConfig () {
86+ OLD_BASHRC=" $HOME /.bashrc"
87+ if [ -e " $OLD_BASHRC " ]; then
88+ printf " %b\n" " ${YELLOW} Moving old bash config file to $HOME /.bashrc.bak${RC} "
89+ if ! mv " $OLD_BASHRC " " $HOME /.bashrc.bak" ; then
90+ printf " %b\n" " ${RED} Can't move the old bash config file!${RC} "
91+ exit 1
92+ fi
93+ fi
94+
95+ printf " %b\n" " ${YELLOW} Linking new bash config file...${RC} "
96+ ln -svf " $gitpath /.bashrc" " $HOME /.bashrc" || {
97+ printf " %b\n" " ${RED} Failed to create symbolic link for .bashrc${RC} "
98+ exit 1
99+ }
100+ ln -svf " $gitpath /starship.toml" " $HOME /.config/starship.toml" || {
101+ printf " %b\n" " ${RED} Failed to create symbolic link for starship.toml${RC} "
102+ exit 1
103+ }
104+ printf " %b\n" " ${GREEN} Done!\nrestart your shell to see the changes.${RC} "
105+ }
106+
107+ checkEnv
108+ checkEscalationTool
109+ cloneMyBash
110+ installDepend
111+ installFont
112+ installStarshipAndFzf
113+ installZoxide
114+ linkConfig
0 commit comments