-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.fish
executable file
·72 lines (53 loc) · 1.13 KB
/
init.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
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
#!/usr/bin/env fish
if test $INIT_LOADED
exit 0
end
set DOT_PATH $HOME/.dotfiles
if test -f (dirname (status -f))/.dot_path
set DOT_PATH (cat (dirname (status -f))/.dot_path)
end
set CACHE_PATH $DOT_PATH/.cache
function link-file
for f in $argv
if not test $DOT_PATH/$f
continue
end
if not test -d $HOME/(dirname $f)
mkdir -p $HOME/(dirname $f)
end
ln -snfv $DOT_PATH/$f $HOME/$f
end
end
function source-config
source $HOME/.config/fish/config.fish
end
function is-mac
return (test (uname -s) = "Darwin")
end
function is-linux
return (test (uname -s) = "Linux")
end
if is-mac && type -q brew
brew upgrade
end
function brew-install
if is-mac && type -q brew
brew install $argv
end
end
if is-linux && type -q apt
sudo apt update && sudo apt upgrade -y
end
function apt-install
if is-linux && type -q apt
sudo apt install -y $argv
end
end
function get-version
if test -f "$DOT_PATH/.$argv[1]-version"
cat "$DOT_PATH/.$argv[1]-version"
else
echo $argv[2]
end
end
set INIT_LOADED 1