-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync
More file actions
executable file
·124 lines (97 loc) · 2.8 KB
/
sync
File metadata and controls
executable file
·124 lines (97 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env fish
function main
argparse d/desktop g/git i/install -- $argv
set -l start_dir (pwd)
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
log 'Syncing shell environment configurations'
set_color grey
setup_tmp_space $cwd $tmp_dir
and sync_terminal_env
and set_fish_universal_vars
and if test -n "$_flag_i"
set_color normal
log 'Installing Neovim plugins'
set_color grey
install_nvim_plugins
end
and if test -n "$_flag_d"
set_color normal
log 'Syncing desktop environment configurations'
set_color grey
sync_desktop_env $uname
end
and if test -n "$_flag_g"
set_color normal
log 'Sync git config'
sync_git_config
set_color grey
end
clean_up_tmp_space $cwd $start_dir $tmp_dir
or return $status
set_color normal
echo -s \n 'Done syncing.'
end
function setup_tmp_space -a cwd tmp_dir
if test ! "$cwd" = dotfiles
git clone --recurse-submodules https://github.com/mitchell/dotfiles.git $tmp_dir
and cd $tmp_dir
end
end
function sync_terminal_env
if ! test -e ~/.config
mkdir ~/.config
end
if ! test -e ~/code/scripts
mkdir -p ~/code/scripts
end
rsync -aP ./.config/fish ~/.config/
and rsync -aP ./.config/nvim ~/.config/
and rsync -aP ./.tmux-line.conf ~/
and rsync -aP ./.tmux.conf ~/
and rsync -aP ./scripts/ ~/code/scripts/
and rsync -aP ./.config/starship.toml ~/.config/
end
function sync_desktop_env -a uname
rsync -aP ./.wezterm.lua ~/
or return 1
switch $uname
case Darwin
rsync -aP ./.yabairc ~/
and rsync -aP ./.skhdrc ~/
case Linux
rsync -aP ./.config/bspwm ~/.config/
and rsync -aP ./.config/sxhkd ~/.config/
and rsync -aP ./.config/picom ~/.config/
and rsync -aP ./.config/polybar ~/.config/
and rsync -aP ./.config/rofi ~/.config/
end
end
function install_nvim_plugins
command -q nvim
and nvim +PlugUpgrade +PlugUpdate +UpdateRemotePlugins +qa
and nvim +COQdeps +bnext +bdelete
end
function sync_git_config
rsync -aP ./.gitconfig ~/
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
function set_fish_universal_vars
source ./fish_universal_vars.fish
end
function clean_up_tmp_space -a cwd start_dir tmp_dir
if test ! "$cwd" = dotfiles
cd $start_dir
and rm -r $tmp_dir
end
end
function log -a message
echo \n"--- $message ---"\n
end
main $argv