mirror of https://github.com/mitchell/dotfiles.git
Use arguments in sync script and refactor swim.fish
This commit is contained in:
parent
30781146ad
commit
fabaacb0d0
16
swim.fish
16
swim.fish
|
@ -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]
|
||||||
|
|
36
sync
36
sync
|
@ -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
|
||||||
|
|
||||||
|
if test -n "$_flag_g"
|
||||||
set_color normal
|
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,11 +65,6 @@ 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?'
|
|
||||||
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/kitty ~/.config/
|
||||||
rsync -aP ./.config/bspwm ~/.config/
|
rsync -aP ./.config/bspwm ~/.config/
|
||||||
rsync -aP ./.config/sxhkd ~/.config/
|
rsync -aP ./.config/sxhkd ~/.config/
|
||||||
|
@ -71,7 +76,6 @@ function sync_desktop_env
|
||||||
rsync -aP ./.yabairc ~/
|
rsync -aP ./.yabairc ~/
|
||||||
rsync -aP ./.skhdrc ~/
|
rsync -aP ./.skhdrc ~/
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function set_kitty_font_size -a uname
|
function set_kitty_font_size -a uname
|
||||||
if test "$uname" = 'Darwin'
|
if test "$uname" = 'Darwin'
|
||||||
|
@ -88,17 +92,13 @@ 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
|
|
||||||
|
|
||||||
if test "$set_git_user" = 'y'; or test "$set_git_user" = 'Y'
|
|
||||||
read -P 'name: ' name
|
read -P 'name: ' name
|
||||||
read -P 'email: ' email
|
read -P 'email: ' email
|
||||||
|
|
||||||
git config --global user.name $name
|
git config --global user.name $name
|
||||||
git config --global user.email $email
|
git config --global user.email $email
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function set_fish_universal_vars
|
function set_fish_universal_vars
|
||||||
source ./fish_universal_vars.fish
|
source ./fish_universal_vars.fish
|
||||||
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue