Skip to content

Instantly share code, notes, and snippets.

@pozgo
Last active July 5, 2024 15:24
Show Gist options
  • Save pozgo/6488fd8b9092bb94fc7dbd101a289117 to your computer and use it in GitHub Desktop.
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
#!/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
fi
if [ $1 == "user" ]; then
mkdir -p $HOME/bin
curl -s https://ohmyposh.dev/install.sh | bash -s -- -d ~/bin
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"
@pozgo
Copy link
Author

pozgo commented Nov 24, 2023

wget https://gist.githubusercontent.com/pozgo/6488fd8b9092bb94fc7dbd101a289117/raw/18b1bb9139ddbeec234031571564bf6fac44097f/provision.sh

or
curl -s https://gist.githubusercontent.com/pozgo/6488fd8b9092bb94fc7dbd101a289117/raw/18b1bb9139ddbeec234031571564bf6fac44097f/provision.sh | bash -s root

chmod +x provosion.sh

./provision.sh root

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment