dotfiles/sync

116 lines
2.7 KiB
Plaintext
Raw Normal View History

2019-08-15 05:50:59 +00:00
#!/usr/bin/env fish
function main
2020-08-15 23:20:08 +00:00
set start_dir (pwd)
set cwd (string match -r '\w+$' $start_dir)
set uname (uname)
2019-08-15 05:50:59 +00:00
2020-08-15 23:20:08 +00:00
echo 'Syncing configuration files to your home dir...'
set_color grey
2020-08-15 23:20:08 +00:00
setup_tmp_space $cwd
sync_terminal_env
set_fish_universal_vars
2020-08-15 23:20:08 +00:00
set_kitty_font_size $uname
2020-08-15 23:20:08 +00:00
install_fisher_packages
install_nvim_plugins
2020-08-15 23:20:08 +00:00
set_git_user
sync_desktop_env
set_color normal
2020-08-15 23:20:08 +00:00
clean_up_tmp_space $cwd $start_dir
2020-08-15 23:20:08 +00:00
echo -s \n 'Done syncing.'
end
function setup_tmp_space -a cwd
2020-08-15 23:20:08 +00:00
if test ! "$cwd" = 'dotfiles'
cd /var/tmp
git clone --recurse-submodules https://github.com/mitchell/dotfiles.git
cd ./dotfiles
end
end
function sync_terminal_env
if ! test -e ~/.config
mkdir ~/.config
end
2020-08-15 23:20:08 +00:00
rsync -aP ./.config/fish ~/.config/
rsync -aP ./.config/nvim ~/.config/
rsync -aP ./.gitconfig ~/
rsync -aP ./.tmux-line.conf ~/
rsync -aP ./.tmux.conf ~/
rsync -aP ./.vim ~/
rsync -aP ./.vimrc ~/
rsync -aP ./.taskrc ~/
end
function sync_desktop_env
set 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/
rsync -aP ./.config/picom ~/.config/
rsync -aP ./.config/xfce4 ~/.config/
rsync -aP ./.config/qutebrowser ~/.config/
rsync -aP ./.config/keepassxc ~/.config/
rsync -aP ./.ideavimrc ~/
rsync -aP ./.yabairc ~/
rsync -aP ./.skhdrc ~/
end
end
function set_kitty_font_size -a uname
2020-08-15 23:20:08 +00:00
if test "$uname" = 'Darwin'
sed -i '' -e 's/font_size 11\.0/font_size 13\.0/' ~/.config/kitty/kitty.conf
end
end
function install_fisher_packages
2020-08-15 23:20:08 +00:00
eval fisher
end
function install_nvim_plugins
2020-08-15 23:20:08 +00:00
command -q nvim; and nvim +PlugUpgrade +PlugUpdate +qa
end
function set_git_user
2020-08-15 23:20:08 +00:00
set 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'
2020-08-15 23:20:08 +00:00
read -P 'name: ' name
read -P 'email: ' email
2020-08-15 23:20:08 +00:00
git config --global user.name $name
git config --global user.email $email
end
end
function set_fish_universal_vars
2020-08-15 23:20:08 +00:00
source ./fish_universal_vars.fish
end
function clean_up_tmp_space -a cwd start_dir
2020-08-15 23:20:08 +00:00
if test ! "$cwd" = 'dotfiles'
cd ..
rm -rf ./dotfiles
cd $start_dir
end
end
main