Use arguments in sync script and refactor swim.fish

This commit is contained in:
mitchell 2020-10-31 19:00:45 -04:00
parent 30781146ad
commit fabaacb0d0
2 changed files with 47 additions and 37 deletions

View File

@ -27,16 +27,22 @@ function swim_format -d 'Format fish scripts'
end end
function swim_sync -d 'Run the sync script' function swim_sync -d 'Run the sync script'
./sync ./sync $argv
end end
function swim_install_arch -d 'Run the install_arch script' function swim_install_arch -d 'Run the install_arch script'
./install_arch ./install_arch $argv
end end
function swim_provision_linux -a distro -d 'Run the provision_linux script with the specified distro' function swim_upgrade_debi -d 'Run the debian_upgrade script'
if test -n "$distro" ./upgrade_debian $argv
set -g distro $distro end
function swim_provision -d 'Run the provision_linux script with the specified distro'
argparse 'd/distro=' -- $argv
if test -n "$_flag_d"
set -g distro $_flag_d
end end
./provision_linux $argv[2..-1] ./provision_linux $argv[2..-1]

68
sync
View File

@ -1,11 +1,12 @@
#!/usr/bin/env fish #!/usr/bin/env fish
function main function main
argparse 'd/desktop' 'g/git' -- $argv
set -l start_dir (pwd) set -l start_dir (pwd)
set -l cwd (string match -r '\w+$' $start_dir) set -l cwd (string match -r '\w+$' $start_dir)
set -l uname (uname) set -l uname (uname)
echo 'Syncing configuration files to your home dir...' log 'Syncing shell environment configurations'
set_color grey set_color grey
setup_tmp_space $cwd setup_tmp_space $cwd
@ -14,20 +15,29 @@ function main
set_fish_universal_vars set_fish_universal_vars
set_kitty_font_size $uname
install_fisher_packages install_fisher_packages
install_nvim_plugins install_nvim_plugins
set_git_user if test -n "$_flag_d"
set_color normal
log 'Syncing desktop environment configurations'
set_color grey
sync_desktop_env sync_desktop_env
set_kitty_font_size $uname
end
set_color normal if test -n "$_flag_g"
set_color normal
log 'Set git user'
set_git_user
set_color grey
end
clean_up_tmp_space $cwd $start_dir clean_up_tmp_space $cwd $start_dir
set_color normal
echo -s \n 'Done syncing.' echo -s \n 'Done syncing.'
end end
@ -55,22 +65,16 @@ function sync_terminal_env
end end
function sync_desktop_env function sync_desktop_env
set -l prompt 'Would you like to sync the desktop environment?' rsync -aP ./.config/kitty ~/.config/
read -p "set_color red; printf '\n$prompt (y/N) '; set_color normal" sync_desktop_env rsync -aP ./.config/bspwm ~/.config/
rsync -aP ./.config/sxhkd ~/.config/
if test "$sync_desktop_env" = 'y'; or test "$sync_desktop_env" = 'Y' rsync -aP ./.config/picom ~/.config/
set_color grey rsync -aP ./.config/xfce4 ~/.config/
rsync -aP ./.config/kitty ~/.config/ rsync -aP ./.config/qutebrowser ~/.config/
rsync -aP ./.config/bspwm ~/.config/ rsync -aP ./.config/polybar ~/.config/
rsync -aP ./.config/sxhkd ~/.config/ rsync -aP ./.ideavimrc ~/
rsync -aP ./.config/picom ~/.config/ rsync -aP ./.yabairc ~/
rsync -aP ./.config/xfce4 ~/.config/ rsync -aP ./.skhdrc ~/
rsync -aP ./.config/qutebrowser ~/.config/
rsync -aP ./.config/polybar ~/.config/
rsync -aP ./.ideavimrc ~/
rsync -aP ./.yabairc ~/
rsync -aP ./.skhdrc ~/
end
end end
function set_kitty_font_size -a uname function set_kitty_font_size -a uname
@ -88,16 +92,12 @@ function install_nvim_plugins
end end
function set_git_user function set_git_user
set -l prompt 'Would you like to set your git user name and email?' echo 'Please set your git user:'
read -p "set_color red; printf '\n$prompt (y/N) '; set_color normal" set_git_user read -P 'name: ' name
read -P 'email: ' email
if test "$set_git_user" = 'y'; or test "$set_git_user" = 'Y' git config --global user.name $name
read -P 'name: ' name git config --global user.email $email
read -P 'email: ' email
git config --global user.name $name
git config --global user.email $email
end
end end
function set_fish_universal_vars function set_fish_universal_vars
@ -112,4 +112,8 @@ function clean_up_tmp_space -a cwd start_dir
end end
end end
main function log -a message
echo \n"---------------- $message ----------------"\n
end
main $argv