Skip to content

Commit 8ed2265

Browse files
author
nnyyxxxx
committed
Move mybash and CTT nvim to Linutil with minor refactoring
1 parent 699b8fc commit 8ed2265

File tree

3 files changed

+165
-2
lines changed

3 files changed

+165
-2
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/sh -e
2+
3+
. ../common-script.sh
4+
5+
gitpath="$HOME/.local/share/neovim"
6+
7+
cloneNeovim() {
8+
mkdir -p "$HOME/.local/share" # Only create the dir if it doesn't exist.
9+
cd "$HOME" && git clone https://github.com/ChrisTitusTech/neovim.git "$HOME/.local/share/neovim"
10+
}
11+
12+
setupNeovim() {
13+
echo "Install Neovim if not already installed"
14+
case "$PACKAGER" in
15+
pacman)
16+
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm neovim ripgrep fzf python-virtualenv luarocks go shellcheck
17+
;;
18+
apt)
19+
$ESCALATION_TOOL "$PACKAGER" install -y neovim ripgrep fd-find python3-venv luarocks golang-go shellcheck
20+
;;
21+
dnf)
22+
$ESCALATION_TOOL "$PACKAGER" install -y neovim ripgrep fzf python3-virtualenv luarocks golang ShellCheck
23+
;;
24+
zypper)
25+
$ESCALATION_TOOL "$PACKAGER" install -y neovim ripgrep fzf python3-virtualenv luarocks golang ShellCheck
26+
;;
27+
*)
28+
printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}" # The packages above were grabbed out of the original nvim-setup-script.
29+
exit 1
30+
;;
31+
esac
32+
}
33+
34+
backupNeovimConfig() {
35+
[ -d "$HOME/.config/nvim" ] && cp -r "$HOME/.config/nvim" "$HOME/.config/nvim-backup"
36+
rm -rf "$HOME/.config/nvim"
37+
}
38+
39+
linkNeovimConfig() {
40+
mkdir -p "$HOME/.config/nvim"
41+
ln -s "$gitpath/titus-kickstart/"* "$HOME/.config/nvim/" # Wild card is used here to link all contents of titus-kickstart.
42+
}
43+
44+
checkEnv
45+
checkEscalationTool
46+
cloneNeovim
47+
setupNeovim
48+
backupNeovimConfig
49+
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)