2019-08-15 05:50:59 +00:00
|
|
|
#!/usr/bin/env fish
|
|
|
|
|
2020-08-11 16:14:46 +00:00
|
|
|
function main
|
2024-06-30 22:41:49 +00:00
|
|
|
argparse d/desktop g/git -- $argv
|
2020-10-13 23:05:07 +00:00
|
|
|
set -l start_dir (pwd)
|
2021-12-16 21:51:31 +00:00
|
|
|
and set -l tmp_dir (mktemp --directory 2>/dev/null; or mktemp -d -t 'dotfiles')
|
|
|
|
and set -l cwd (string match -r '\w+$' $start_dir)
|
|
|
|
and set -l uname (uname)
|
|
|
|
or return $status
|
2019-08-15 05:50:59 +00:00
|
|
|
|
2020-10-31 23:00:45 +00:00
|
|
|
log 'Syncing shell environment configurations'
|
2020-08-15 23:20:08 +00:00
|
|
|
set_color grey
|
2019-08-17 16:19:04 +00:00
|
|
|
|
2020-11-06 00:49:16 +00:00
|
|
|
setup_tmp_space $cwd $tmp_dir
|
2019-08-17 16:19:04 +00:00
|
|
|
|
2021-12-16 21:51:31 +00:00
|
|
|
and sync_terminal_env
|
2020-09-29 07:02:28 +00:00
|
|
|
|
2021-12-16 21:51:31 +00:00
|
|
|
and set_fish_universal_vars
|
2020-08-11 16:14:46 +00:00
|
|
|
|
2021-12-16 21:51:31 +00:00
|
|
|
and install_fisher_packages
|
2020-08-11 16:14:46 +00:00
|
|
|
|
2021-12-16 21:51:31 +00:00
|
|
|
and install_nvim_plugins
|
2020-09-29 07:02:28 +00:00
|
|
|
|
2020-10-31 23:00:45 +00:00
|
|
|
if test -n "$_flag_d"
|
|
|
|
set_color normal
|
|
|
|
log 'Syncing desktop environment configurations'
|
|
|
|
set_color grey
|
2020-08-11 16:14:46 +00:00
|
|
|
|
2020-11-15 05:23:44 +00:00
|
|
|
sync_desktop_env $uname
|
2020-10-31 23:00:45 +00:00
|
|
|
end
|
2020-10-09 00:19:38 +00:00
|
|
|
|
2020-10-31 23:00:45 +00:00
|
|
|
if test -n "$_flag_g"
|
|
|
|
set_color normal
|
2020-11-15 05:23:44 +00:00
|
|
|
log 'Sync git config'
|
|
|
|
sync_git_config
|
2020-10-31 23:00:45 +00:00
|
|
|
set_color grey
|
|
|
|
end
|
2020-08-15 22:36:58 +00:00
|
|
|
|
2020-11-06 00:51:51 +00:00
|
|
|
clean_up_tmp_space $cwd $start_dir $tmp_dir
|
2021-12-16 21:51:31 +00:00
|
|
|
or return $status
|
2020-08-11 16:14:46 +00:00
|
|
|
|
2020-10-31 23:00:45 +00:00
|
|
|
set_color normal
|
2020-08-15 23:20:08 +00:00
|
|
|
echo -s \n 'Done syncing.'
|
2019-08-17 16:19:04 +00:00
|
|
|
end
|
|
|
|
|
2020-11-06 00:51:51 +00:00
|
|
|
function setup_tmp_space -a cwd tmp_dir
|
2024-06-30 22:41:49 +00:00
|
|
|
if test ! "$cwd" = dotfiles
|
2020-11-06 00:51:51 +00:00
|
|
|
git clone --recurse-submodules https://github.com/mitchell/dotfiles.git $tmp_dir
|
2021-12-16 21:51:31 +00:00
|
|
|
and cd $tmp_dir
|
2020-08-15 23:20:08 +00:00
|
|
|
end
|
2020-08-11 16:14:46 +00:00
|
|
|
end
|
2019-08-15 06:20:46 +00:00
|
|
|
|
2020-09-29 07:02:28 +00:00
|
|
|
function sync_terminal_env
|
2020-10-13 17:48:43 +00:00
|
|
|
if ! test -e ~/.config
|
|
|
|
mkdir ~/.config
|
|
|
|
end
|
2020-08-15 23:20:08 +00:00
|
|
|
|
2022-02-28 08:13:49 +00:00
|
|
|
if ! test -e ~/code/scripts
|
|
|
|
mkdir -p ~/code/scripts
|
|
|
|
end
|
|
|
|
|
2020-08-15 23:20:08 +00:00
|
|
|
rsync -aP ./.config/fish ~/.config/
|
2021-12-16 21:51:31 +00:00
|
|
|
and rsync -aP ./.config/nvim ~/.config/
|
|
|
|
and rsync -aP ./.tmux-line.conf ~/
|
|
|
|
and rsync -aP ./.tmux.conf ~/
|
|
|
|
and rsync -aP ./.vim ~/
|
|
|
|
and rsync -aP ./.vimrc ~/
|
2022-02-28 08:13:49 +00:00
|
|
|
and rsync -aP ./scripts/ ~/code/scripts/
|
2024-06-30 23:33:35 +00:00
|
|
|
and rsync -aP ./.config/starship.toml ~/.config/
|
2020-08-11 16:14:46 +00:00
|
|
|
end
|
|
|
|
|
2020-11-15 05:23:44 +00:00
|
|
|
function sync_desktop_env -a uname
|
2024-06-30 23:33:35 +00:00
|
|
|
rsync -aP ./.wezterm.lua ~/
|
2021-12-16 21:51:31 +00:00
|
|
|
and rsync -aP ./.ideavimrc ~/
|
|
|
|
or return 1
|
2020-11-15 05:23:44 +00:00
|
|
|
|
|
|
|
switch $uname
|
|
|
|
case Darwin
|
|
|
|
rsync -aP ./.yabairc ~/
|
2021-12-16 21:51:31 +00:00
|
|
|
and rsync -aP ./.skhdrc ~/
|
2020-11-15 05:23:44 +00:00
|
|
|
|
|
|
|
case Linux
|
|
|
|
rsync -aP ./.config/bspwm ~/.config/
|
2021-12-16 21:51:31 +00:00
|
|
|
and rsync -aP ./.config/sxhkd ~/.config/
|
|
|
|
and rsync -aP ./.config/picom ~/.config/
|
|
|
|
and rsync -aP ./.config/polybar ~/.config/
|
2020-11-15 05:23:44 +00:00
|
|
|
end
|
2020-09-29 07:02:28 +00:00
|
|
|
end
|
|
|
|
|
2020-08-11 16:14:46 +00:00
|
|
|
function install_fisher_packages
|
2020-08-15 23:20:08 +00:00
|
|
|
eval fisher
|
2020-08-11 16:14:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function install_nvim_plugins
|
2024-06-30 22:41:49 +00:00
|
|
|
command -q nvim; and nvim +PlugUpgrade +PlugUpdate +UpdateRemotePlugins +qa
|
2020-08-11 16:14:46 +00:00
|
|
|
end
|
2019-08-17 06:12:45 +00:00
|
|
|
|
2020-11-15 05:23:44 +00:00
|
|
|
function sync_git_config
|
|
|
|
rsync -aP ./.gitconfig ~/
|
|
|
|
|
2020-10-31 23:00:45 +00:00
|
|
|
echo 'Please set your git user:'
|
|
|
|
read -P 'name: ' name
|
|
|
|
read -P 'email: ' email
|
2019-08-17 06:12:45 +00:00
|
|
|
|
2020-10-31 23:00:45 +00:00
|
|
|
git config --global user.name $name
|
|
|
|
git config --global user.email $email
|
2019-08-17 06:12:45 +00:00
|
|
|
end
|
|
|
|
|
2020-08-15 22:36:58 +00:00
|
|
|
function set_fish_universal_vars
|
2020-08-15 23:20:08 +00:00
|
|
|
source ./fish_universal_vars.fish
|
2020-08-15 22:36:58 +00:00
|
|
|
end
|
|
|
|
|
2020-11-06 00:51:51 +00:00
|
|
|
function clean_up_tmp_space -a cwd start_dir tmp_dir
|
2024-06-30 22:41:49 +00:00
|
|
|
if test ! "$cwd" = dotfiles
|
2020-08-15 23:20:08 +00:00
|
|
|
cd $start_dir
|
2021-12-16 21:51:31 +00:00
|
|
|
and rm -r $tmp_dir
|
2020-08-15 23:20:08 +00:00
|
|
|
end
|
2019-08-17 16:19:04 +00:00
|
|
|
end
|
|
|
|
|
2020-10-31 23:00:45 +00:00
|
|
|
function log -a message
|
2021-12-16 21:51:31 +00:00
|
|
|
echo \n"--- $message ---"\n
|
2020-10-31 23:00:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
main $argv
|