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
function swim_sync -d 'Run the sync script'
./sync
./sync $argv
end
function swim_install_arch -d 'Run the install_arch script'
./install_arch
./install_arch $argv
end
function swim_provision_linux -a distro -d 'Run the provision_linux script with the specified distro'
if test -n "$distro"
set -g distro $distro
function swim_upgrade_debi -d 'Run the debian_upgrade script'
./upgrade_debian $argv
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
./provision_linux $argv[2..-1]

36
sync
View File

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