Last active
August 21, 2024 23:12
-
-
Save pozgo/6488fd8b9092bb94fc7dbd101a289117 to your computer and use it in GitHub Desktop.
Quick provision Debian 12 with OhMyPosh neovim and kickstart and few base packages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
export TERM=xterm | |
# Bash Colors | |
green=`tput setaf 2` | |
bold=`tput bold` | |
reset=`tput sgr0` | |
# Functions | |
log() { | |
if [[ "$@" ]]; then echo "${bold}${green}[LOG `date +'%T'`]${reset} $@"; | |
else echo; fi | |
} | |
system_setup() { | |
# Update System and install base packages | |
log "Updating system and installing base packages" | |
apt update -y | |
apt install -y nala | |
nala install -y \ | |
sudo \ | |
wget \ | |
curl \ | |
mc \ | |
telnet \ | |
iftop \ | |
iotop \ | |
htop \ | |
git \ | |
bpytop \ | |
bat \ | |
lsd \ | |
unzip \ | |
gcc \ | |
iperf | |
} | |
update_envs() { | |
log "System Updated and base packages installed" | |
update_bashrc "alias ll='lsd -lah'" | |
update_bashrc "alias cat='batcat'" | |
update_bashrc "alias vi='nvim'" | |
update_bashrc "eval \"\$(oh-my-posh init bash --config https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/slimfat.omp.json)\"" | |
} | |
update_bashrc() { | |
log "Updating ${HOME}/.bashrc with record: $1" | |
line=${1} | |
grep -qF -- "$line" $HOME/.bashrc || echo "$line" >> $HOME/.bashrc | |
} | |
install_neovim() { | |
log "Installing neovim from source" | |
wget -O nvim.tgz https://github.com/neovim/neovim/releases/download/stable/nvim-linux64.tar.gz | |
tar zxvf nvim.tgz | |
rm -f nvim.tgz | |
mv ~/nvim-linux64 ~/nvim | |
update_bashrc "export PATH=\$HOME/nvim/bin:\$PATH" | |
} | |
install_neovim_kickstart() { | |
log "Installing neovim kickstart" | |
git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim | |
} | |
install_ohmyposh() { | |
log "Installing OhMyPosh" | |
if [ $1 == "root" ]; then | |
curl -s https://ohmyposh.dev/install.sh | bash -s | |
update_bashrc "export PATH=\$HOME/.local/bin:\$PATH" | |
fi | |
if [ $1 == "user" ]; then | |
mkdir -p $HOME/bin | |
curl -s https://ohmyposh.dev/install.sh | bash -s -- -d ~/bin | |
update_bashrc "export PATH=\$HOME/bin:\$PATH" | |
fi | |
} | |
cd $HOME | |
if [ $1 == "root" ]; then | |
log "Runnign script for root" | |
system_setup | |
install_neovim | |
install_neovim_kickstart | |
install_ohmyposh "root" | |
update_envs | |
else | |
log "Running script for user $(whoami)" | |
install_neovim | |
install_neovim_kickstart | |
install_ohmyposh "user" | |
update_envs | |
fi | |
log " Please run 'source $HOME/.bashrc' for changes to take effect" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wget https://gist.githubusercontent.com/pozgo/6488fd8b9092bb94fc7dbd101a289117/raw/920a32e3aa340cda19de89db6927a9fec1f0cdbe/provision.sh
or
curl -s https://gist.githubusercontent.com/pozgo/6488fd8b9092bb94fc7dbd101a289117/raw/920a32e3aa340cda19de89db6927a9fec1f0cdbe/provision.sh | bash -s root
chmod +x provosion.sh
./provision.sh root