2023-09-03 00:36:15 +02:00
|
|
|
#!/usr/bin/env fish
|
|
|
|
|
2023-09-04 16:14:08 +02:00
|
|
|
function update-homes -d "Update homes configuration"
|
|
|
|
argparse 'h/help' 'g/git' 'd/desktop' 'r/root' 'R/remove' 'i/install' -- $argv
|
2023-09-03 00:36:15 +02:00
|
|
|
|
2023-09-04 16:14:08 +02:00
|
|
|
set -f homes_path ~/homes
|
|
|
|
set -f homes_private_path ~/homes-private
|
|
|
|
|
|
|
|
if set -q HOMES_PATH
|
|
|
|
set -f homes_path $HOMES_PATH
|
|
|
|
end
|
|
|
|
|
|
|
|
if set -q HOMES_PRIVATE_PATH
|
|
|
|
set -f homes_private_path $HOMES_PRIVATE_PATH
|
|
|
|
end
|
|
|
|
|
|
|
|
if not test -d $homes_path
|
|
|
|
echo (set_color c94f6d)"*** ERROR ***"(set_color normal)
|
|
|
|
echo "*** $homes_path does not exists"
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if not test -n homes_path
|
|
|
|
echo (set_color c94f6d)"*** ERROR ***"(set_color normal)
|
|
|
|
echo "*** HOMES_PATH variable is empty"
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if not test -n homes_private_path
|
|
|
|
echo (set_color c94f6d)"*** ERROR ***"(set_color normal)
|
|
|
|
echo "*** HOMES_PRIVATE_PATH is empty, unset or change it"
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if not test -d $homes_private_path
|
|
|
|
echo (set_color f4a261)"*** WARNING ***"(set_color normal)
|
|
|
|
echo "*** $homes_private_path does not exist"
|
2023-09-06 02:22:26 +02:00
|
|
|
echo
|
|
|
|
echo
|
2023-09-04 16:14:08 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if not functions -q update-homes-secrets
|
|
|
|
echo (set_color f4a261)"*** WARNING ***"(set_color normal)
|
|
|
|
echo "*** update-homes-secrets is not defined"
|
2023-09-06 02:22:26 +02:00
|
|
|
echo
|
|
|
|
echo
|
2023-09-04 16:14:08 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if set -q _flag_help
|
2023-09-03 00:36:15 +02:00
|
|
|
echo "Update home's configuration"
|
|
|
|
echo
|
|
|
|
echo "You need to have homes and homes-private in your home directory."
|
|
|
|
echo "This function launch the two scripts to update your conf."
|
|
|
|
echo
|
|
|
|
echo " -g --git"
|
|
|
|
echo " Pull-rebase before launch script"
|
|
|
|
echo
|
|
|
|
echo " -d --desktop"
|
|
|
|
echo " Update desktop part"
|
|
|
|
echo
|
|
|
|
echo " -r --root"
|
|
|
|
echo " Update root part"
|
|
|
|
echo
|
|
|
|
echo " -R --remove"
|
|
|
|
echo " Remove old configuration"
|
|
|
|
echo
|
2023-09-04 16:14:08 +02:00
|
|
|
echo " -i --install"
|
|
|
|
echo " Install user packages and softwares"
|
|
|
|
echo
|
2023-09-03 00:36:15 +02:00
|
|
|
echo " -h --help"
|
|
|
|
echo " Show this screen"
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2023-09-04 16:14:08 +02:00
|
|
|
if set -q _flag_install
|
2023-09-06 02:22:26 +02:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo (set_color 81b29a)"*** Install user softwares ***"(set_color normal)
|
|
|
|
echo
|
|
|
|
echo (set_color 719cd6)"*** Install nvimpager ***"(set_color normal)
|
|
|
|
echo
|
2023-09-04 16:14:08 +02:00
|
|
|
mkdir -p ~/.cache
|
|
|
|
rm -rf ~/.cache/nvimpager-git
|
|
|
|
git clone --depth 1 https://github.com/lucc/nvimpager ~/.cache/nvimpager-git
|
|
|
|
pushd ~/.cache/nvimpager-git
|
|
|
|
make PREFIX=$HOME/.local install
|
|
|
|
popd
|
|
|
|
rm -rf ~/.cache/nvimpager-git
|
2023-09-03 00:36:15 +02:00
|
|
|
end
|
2023-09-04 16:14:08 +02:00
|
|
|
|
|
|
|
if set -q _flag_desktop && set -q _flag_install
|
2023-09-06 02:22:26 +02:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo (set_color 719cd6)"*** Install lazydocker ***"(set_color normal)
|
|
|
|
echo
|
|
|
|
go install github.com/jesseduffield/lazydocker@latest
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo (set_color 719cd6)"*** Install lazygit ***"(set_color normal)
|
|
|
|
echo
|
|
|
|
go install github.com/jesseduffield/lazygit@latest
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo (set_color 719cd6)"*** Install bluetuith ***"(set_color normal)
|
|
|
|
go install github.com/darkhz/bluetuith@latest
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo (set_color 719cd6)"*** Install poezio-omemo and epr ***"(set_color normal)
|
|
|
|
echo
|
2023-09-04 16:14:08 +02:00
|
|
|
pip install --user --break-system-packages -U poezio-omemo epr-reader
|
|
|
|
|
2023-09-06 02:22:26 +02:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo (set_color 719cd6)"*** Install poezio plugins ***"(set_color normal)
|
|
|
|
echo
|
2023-09-04 16:14:08 +02:00
|
|
|
rm -rf ~/.local/share/poezio/plugins
|
|
|
|
mkdir -p ~/.local/share/poezio
|
|
|
|
|
|
|
|
set -l poezio_version $(poezio --version | cut -d " " -f 2)
|
|
|
|
rm -rf ~/.cache/poezio-git
|
2023-09-06 02:22:26 +02:00
|
|
|
git clone --depth 1 -b $poezio_version https://codeberg.org/poezio/poezio ~/.cache/poezio-git
|
2023-09-04 16:14:08 +02:00
|
|
|
pushd ~/.cache/poezio-git
|
|
|
|
popd
|
|
|
|
cp -r ~/.cache/poezio-git/plugins ~/.local/share/poezio
|
|
|
|
rm -rf ~/.cache/poezio-git
|
2023-09-03 00:36:15 +02:00
|
|
|
end
|
2023-09-04 16:14:08 +02:00
|
|
|
|
|
|
|
if set -q _flag_remove
|
2023-09-06 02:22:26 +02:00
|
|
|
echo (set_color 81b29a)"**** Remove old config ***"(set_color normal)
|
2023-09-04 16:14:08 +02:00
|
|
|
|
|
|
|
# Remove zsh
|
|
|
|
rm ~/.zcompdump
|
|
|
|
rm -rf ~/.zsh* ~/.local/share/zsh
|
|
|
|
|
|
|
|
# Remove old tmux files
|
|
|
|
rm -f ~/.tmux.conf ~/.tmux-theme
|
|
|
|
|
|
|
|
rm -rf ~/.config/aerc
|
|
|
|
rm -rf ~/.config/fish
|
|
|
|
rm -rf ~/.config/khal
|
|
|
|
rm -rf ~/.config/khard
|
|
|
|
rm -rf ~/.config/lvim
|
|
|
|
rm -rf ~/.config/neomutt
|
|
|
|
rm -rf ~/.config/newsboat
|
|
|
|
rm -rf ~/.config/nvim
|
|
|
|
rm -rf ~/.config/poezio
|
|
|
|
rm -rf ~/.config/tmux
|
|
|
|
rm -rf ~/.config/toot
|
|
|
|
rm -rf ~/.config/vdirsyncer
|
2023-09-03 00:36:15 +02:00
|
|
|
end
|
|
|
|
|
2023-09-04 16:14:08 +02:00
|
|
|
if set -q _flag_git
|
2023-09-06 02:22:26 +02:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo (set_color 81b29a)"*** Update homes configuration directories ***"(set_color normal)
|
|
|
|
echo
|
2023-09-04 16:14:08 +02:00
|
|
|
pushd $homes_path
|
|
|
|
gitpr
|
|
|
|
popd
|
|
|
|
|
|
|
|
if test -d $homes_private_path
|
|
|
|
pushd $homes_private_path
|
2023-09-03 00:44:13 +02:00
|
|
|
gitpr
|
2023-09-04 16:14:08 +02:00
|
|
|
popd
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-09-06 02:22:26 +02:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo (set_color 81b29a)"*** Synchronize files ***"(set_color normal)
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo (set_color 719cd6)"*** Copying common part ***"(set_color normal)
|
|
|
|
echo
|
2023-09-04 16:14:08 +02:00
|
|
|
if test -d $homes_path/common
|
|
|
|
pushd $homes_path
|
|
|
|
rsync --exclude=".*.swp" -av ./common/ ~/
|
|
|
|
popd
|
|
|
|
end
|
|
|
|
if test -d $homes_private_path/common
|
|
|
|
pushd $homes_private_path
|
|
|
|
rsync --exclude=".*.swp" -av ./common/ ~/
|
|
|
|
popd
|
|
|
|
end
|
|
|
|
|
|
|
|
if set -q _flag_root
|
2023-09-06 02:22:26 +02:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo (set_color 719cd6)"*** Copying root part ***"(set_color normal)
|
|
|
|
echo
|
2023-09-04 16:14:08 +02:00
|
|
|
if test -d $homes_path/root
|
|
|
|
pushd $homes_path
|
|
|
|
rsync --exclude=".*.swp" -av ./root/ ~/
|
|
|
|
popd
|
|
|
|
end
|
|
|
|
if test -d $homes_private_path/root
|
|
|
|
pushd $homes_private_path
|
|
|
|
rsync --exclude=".*.swp" -av ./root/ ~/
|
|
|
|
popd
|
2023-09-03 00:44:13 +02:00
|
|
|
end
|
2023-09-04 16:14:08 +02:00
|
|
|
end
|
2023-09-03 00:36:15 +02:00
|
|
|
|
2023-09-04 16:14:08 +02:00
|
|
|
if set -q _flag_desktop
|
2023-09-06 02:22:26 +02:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo (set_color 719cd6)"*** Copying desktop part ***"(set_color normal)
|
|
|
|
echo
|
2023-09-04 16:14:08 +02:00
|
|
|
if test -d $homes_path/desktop
|
|
|
|
pushd $homes_path
|
|
|
|
rsync --exclude=".*.swp" -av ./desktop/ ~/
|
|
|
|
popd
|
2023-09-03 00:44:13 +02:00
|
|
|
end
|
2023-09-04 16:14:08 +02:00
|
|
|
if test -d $homes_private_path/desktop
|
|
|
|
pushd $homes_private_path
|
|
|
|
rsync --exclude=".*.swp" -av ./desktop/ ~/
|
|
|
|
popd
|
2023-09-03 00:44:13 +02:00
|
|
|
end
|
2023-09-04 16:14:08 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if functions -q update-homes-secrets
|
|
|
|
update-homes-secrets $_flag_desktop $_flag_root
|
2023-09-03 00:36:15 +02:00
|
|
|
end
|
|
|
|
end
|