From 3f93599ba4633cec22f7ed0d4bf75d19ab29645b Mon Sep 17 00:00:00 2001 From: mitchell Date: Tue, 13 Oct 2020 19:05:07 -0400 Subject: [PATCH] Add repeat fish function and refactor sync script variables --- .config/fish/functions/repeat.fish | 5 +++++ sync | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 .config/fish/functions/repeat.fish diff --git a/.config/fish/functions/repeat.fish b/.config/fish/functions/repeat.fish new file mode 100644 index 0000000..aca5df5 --- /dev/null +++ b/.config/fish/functions/repeat.fish @@ -0,0 +1,5 @@ +function repeat -a count -d 'Repeat the given action the given number of times' + for i in (seq $count) + $argv[2..-1] + end +end diff --git a/sync b/sync index 89118b4..47bea2e 100755 --- a/sync +++ b/sync @@ -1,9 +1,9 @@ #!/usr/bin/env fish function main - set start_dir (pwd) - set cwd (string match -r '\w+$' $start_dir) - set uname (uname) + 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...' set_color grey @@ -55,7 +55,7 @@ function sync_terminal_env end function sync_desktop_env - set prompt 'Would you like to sync the desktop environment?' + 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' @@ -88,7 +88,7 @@ function install_nvim_plugins end function set_git_user - set prompt 'Would you like to set your git user name and email?' + 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'