-
Notifications
You must be signed in to change notification settings - Fork 2
/
pluginrc.fish
40 lines (34 loc) · 1.33 KB
/
pluginrc.fish
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
#!/usr/bin/env fish
# Next line for testing.
#set fish_trace true
set_color blue
set CURRENT_DIR (dirname (realpath (status current-filename)))
cd $CURRENT_DIR
# Set the base directory that we want directories and files copied into on the remote server.
# Normally this will be into $XDG_CONFIG_HOME which is set by default by xxh to:
# $HOME/.xxh/.config
set basedirectorytocopyfilesto $XDG_CONFIG_HOME
# Makes a directory if it is not found.
function mkdirifnotfound
mkdir -p "$basedirectorytocopyfilesto/$founddirectory"
end
# Compare and check to see if the Fisher configuration files already exists or not and copy if not.
diff "$basedirectorytocopyfilesto/fish/conf.d/fisher.fish" "fish/conf.d/fisher.fish" &>/dev/null
set fisherfishdiff $status
if test \( ! -e "$basedirectorytocopyfilesto/fish/functions/fisher.fish" \) -o \( ! $fisherfishdiff -eq 0 \)
# Set files then copy them. By default is this the files in the "fish" directory,
# that would normally be found in ~/.config/fish
set filestocopy "fish"
for found in (find "$filestocopy" -depth -print)
if test -f "$found"
set founddirectory (dirname "$found")
mkdirifnotfound
cp "$found" "$basedirectorytocopyfilesto/$founddirectory/"
else
mkdirifnotfound
end
end
end
set_color normal
# For testing, ends trace.
#set -e fish_trace