homes/common/.config/fish/functions/update-homes.fish

306 lines
9 KiB
Fish
Raw Normal View History

#!/usr/bin/env fish
2023-09-04 16:14:08 +02:00
function update-homes -d "Update homes configuration"
2023-09-10 01:48:28 +02:00
argparse 'h/help' 'g/git' 'd/desktop' 'r/root' 'R/remove' 'i/install' 'D/fix-debian' -- $argv
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
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-10 01:48:28 +02:00
echo " -D --fix-debian"
echo " Install missing packages in debian into user path"
echo
echo " -h --help"
echo " Show this screen"
return
end
2023-09-10 01:48:28 +02:00
if set -q _flag_fix_debian
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-07 17:55:16 +02:00
echo
echo
echo (set_color 719cd6)"*** Install virtualfish ***"(set_color normal)
echo
2023-09-08 15:52:05 +02:00
pip install --user --upgrade --break-system-packages virtualfish
echo
echo
echo (set_color 719cd6)"*** Install pyright ***"(set_color normal)
echo
pip install --user --upgrade --break-system-packages -U pyright
2023-10-02 00:57:35 +02:00
echo
echo
echo (set_color 719cd6)"*** Install broot ***"(set_color normal)
echo
cargo install broot
echo
echo
echo (set_color 719cd6)"*** Install onefetch ***"(set_color normal)
echo
cargo install onefetch
end
2023-09-04 16:14:08 +02:00
2023-09-10 01:48:28 +02:00
if set -q _flag_desktop && set -q _flag_fix_debian
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
2023-09-08 20:05:10 +02:00
echo
echo
echo (set_color 719cd6)"*** Install pms ***"(set_color normal)
echo
go install github.com/ambientsound/pms@latest
2023-09-06 02:22:26 +02:00
echo
echo
echo (set_color 719cd6)"*** Install poezio-omemo and epr ***"(set_color normal)
echo
2023-09-08 15:52:05 +02:00
pip install --user --upgrade --break-system-packages -U poezio-omemo epr-reader
2023-09-04 16:14:08 +02:00
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
2023-09-08 15:52:05 +02:00
mkdir -p ~/.local/share/poezio/logs
2023-09-04 16:14:08 +02:00
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
end
2023-09-04 16:14:08 +02:00
2023-09-10 01:48:28 +02:00
if set -q _flag_install
echo
echo
echo (set_color 719cd6)"*** Install virtualfish ***"(set_color normal)
echo
vf install auto_activation compat_aliases global_requirements projects environment
echo
echo
echo (set_color 719cd6)"*** Install fundle plugins ***"(set_color normal)
echo
fundle install
fundle update
echo
echo
echo (set_color 719cd6)"*** Install pygments style ***"(set_color normal)
echo
pip install "git+https://procrastinator.nerv-project.eu/kujiu/pygments_nightfox_style" --user --break-system-packages
2023-10-02 00:57:35 +02:00
echo
echo
echo (set_color 719cd6)"*** Install xonsh plugins ***"(set_color normal)
echo
echo "xpip install -U xontrib-commands xontrib-gitinfo \
xontrib-broot xontrib-hist-navigator xontrib-prompt-vi-mode \
xontrib-vox xontrib-abbrevs xontrib-argcomplete xontrib-django \
xonsh-docker-tabcomplete xontrib-fish-completer xontrib-jedi\
xontrib-makefile-complete --break-system-packages; exit(1)" | xonsh
2023-09-10 01:48:28 +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/tmuxinator
2023-09-04 16:14:08 +02:00
rm -rf ~/.config/toot
rm -rf ~/.config/vdirsyncer
rm -rf ~/.local/share/json-fortune
rm ~/.fortunes.json
rm ~/.wikiquote-sources.json
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
2023-09-08 15:52:05 +02:00
set_nightfox_vars
2023-09-04 16:14:08 +02:00
end
if test -d $homes_private_path/common
pushd $homes_private_path
rsync --exclude=".*.swp" -av ./common/ ~/
popd
end
if set -q _flag_install
echo
echo
echo (set_color 719cd6)"*** Install json-fortune deps ***"(set_color normal)
echo
pip install --user --upgrade --break-system-packages wikiquote
if not test -f ~/.local/share/json-fortune/fortunes.json
update-quotes
end
end
2023-09-04 16:14:08 +02:00
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-04 16:14:08 +02:00
if set -q _flag_desktop
2023-09-10 01:48:28 +02:00
mkdir -p ~/.local/share/poezio2/logs
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
2023-09-10 01:48:28 +02:00
update-homes-secrets $_flag_desktop $_flag_root $_flag_fix_debian
end
end