Files
home/install.sh

126 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
set -e
files=".config/fish \
.config/git \
.config/omf \
.config/starship.toml \
.local/share/omf \
.emacs \
.tmux.conf.local"
function this_script_root_dir() {
dirname $(realpath ${BASH_SOURCE[0]})
}
function run() {
# echo "$@"
$@
}
function load_gnome_terminal_profiles() {
if which dconf 1>/dev/null
then
run dconf load /org/gnome/terminal/legacy/profiles:/ < $(this_script_root_dir)/gnome-terminal-profiles.dconf
fi
}
function use_fish() {
if ! which fish 1>/dev/null
then
echo "Installing fish"
run sudo apt-get install -y fish
else
echo "Fish is installed"
fi
fish=$(which fish)
current_shell=$(grep $USER /etc/passwd | cut -d ":" -f 7)
if [ $current_shell != $fish ]
then
echo "Changing shell to $fish (you will be prompted for passwd)"
run chsh -s $fish
else
echo "Default shell is $fish"
fi
}
function use_direnv() {
if ! which direnv 1>/dev/null
then
echo "Installing direnv"
run sudo apt-get install -y direnv
else
echo "direnv is installed"
fi
}
function use_starship() {
if ! which starship 1>/dev/null
then
echo "Installing starship"
run curl -sS https://starship.rs/install.sh | sh
else
echo "Starship is installed"
fi
}
function install_ubuntu_mono_nerd() {
if ! fc-list | grep "UbuntuMono Nerd" 1>/dev/null
then
pushd /tmp
run wget https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/UbuntuMono.zip
run unzip UbuntuMono.zip
run mkdir -p ~/.local/share/fonts
cp *.ttf ~/.local/share/fonts/
run fc-cache -f
popd
else
echo "UbuntuMono Nerd font is installed"
fi
if [ ! -e /usr/share/terminfo/x/xterm-direct ]
then
run sudo apt-get install -y ncurses-term
else
echo "xterm-direct is in terminfo database"
fi
}
function install_deps() {
use_fish
use_direnv
use_starship
install_ubuntu_mono_nerd
}
function install_home() {
install_deps
for f in $files
do
run rm -Rf $HOME/$f
dir=$(dirname $f)
if [ ! "$dir" = "." ]
then
run mkdir -p $HOME/$dir
fi
run ln -sf $(this_script_root_dir)/$f $HOME/$f
done
run ln -sf $(this_script_root_dir)/.tmux/.tmux.conf $HOME/.tmux.conf
load_gnome_terminal_profiles
}
pushd $(this_script_root_dir) 1>/dev/null
echo "Updating git.tuleu.science:atuleu/home.git"
git pull 1>/dev/null
git submodule init 1>/dev/null
git submodule update 1>/dev/null
popd 1>/dev/null
install_home
echo "git.tuleu.science:atuleu/home.git updated and set"