Skip to content

Commit f3e3ddc

Browse files
Merge pull request #335 from nnyyxxxx/testing-12
Move mybash and CTT nvim to Linutil with minor refactoring
2 parents f888e5e + 9228327 commit f3e3ddc

File tree

3 files changed

+175
-2
lines changed

3 files changed

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

tabs/applications-setup/tab_data.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ script = "alacritty-setup.sh"
66

77
[[data]]
88
name = "Bash Prompt"
9-
command = "bash -c \"$(curl -s https://raw.githubusercontent.com/ChrisTitusTech/mybash/main/setup.sh)\""
9+
script = "mybash-setup.sh"
1010

1111
[[data]]
1212
name = "DWM-Titus"
@@ -18,7 +18,7 @@ script = "kitty-setup.sh"
1818

1919
[[data]]
2020
name = "Neovim"
21-
command = "bash -c \"$(curl -s https://raw.githubusercontent.com/ChrisTitusTech/neovim/main/setup.sh)\""
21+
script = "neovim-setup.sh"
2222

2323
[[data]]
2424
name = "Rofi"

0 commit comments

Comments
 (0)