-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap
executable file
·108 lines (92 loc) · 3.36 KB
/
bootstrap
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
#!/usr/bin/env fish
function header_banner -a title
set title_length (math (string length $title) + 4)
set stars (string repeat -n $title_length '*')
set_color brblue
echo
echo $stars
echo "* $title *"
echo $stars
set_color normal
end
function setup_fish_vendor
# fish plugins I use are included verbatim in .config/fish/vendor
# they must be copied to .config/fish to become usable
header_banner "Setting up fish vendored plugins"
# disable fzf plugin on slow systems
if test "$disable_fzf" = true
echo "Disabling fzf-fish plugin"
rm -rf $HOME/.config/fish/conf.d/fzf.fish $HOME/.config/fish/vendor/fzf-fish
end
set vendor_src $HOME/.config/fish/vendor
set vendor_tgt $HOME/.config/fish/
cp -prf $vendor_src/* $vendor_tgt
or exit 2
echo "Copied fish vendored plugins from $vendor_src to $vendor_tgt"
end
function set_fish_universal_vars
header_banner "Setting fish universal variables"
echo "Unsetting fish_greeting"
set -U fish_greeting
set enabled_features ampersand-nobg-in-token,qmark-noglob,regex-easyesc,stderr-nocaret
echo "Enabling fish_features:" $enabled_features
set -U fish_features $enabled_features
echo "Enabling pure prompt show root prefix"
set -U pure_show_prefix_root_prompt true
echo "Enabling pure prompt show error code in prompt"
set -U pure_separate_prompt_on_error true
end
function set_default_shell
header_banner "Set fish as default shell"
set current_default_shell (getent passwd $LOGNAME | cut -d: -f7)
if test $current_default_shell != /usr/bin/fish
echo "Setting /usr/bin/fish as default shell, enter password to confirm"
chsh -s /usr/bin/fish
else
echo "fish is already the default shell, nothing to do."
end
end
function setup_emacs
header_banner "Set up Emacs configuration"
if type -q emacs
echo Emacs installation found at (which emacs), version (emacs --version)[1]
if test -e $HOME/.emacs.d
echo "Emacs config already found at $HOME/.emacs.d, skipping further configuration"
else
set repo https://github.com/haplo/dotemacs
set target $HOME/.emacs.d
echo "Downloading Emacs config from $repo to $target"
git clone $repo $target
end
else
echo "No Emacs installation detected, skipping Emacs configuration"
end
end
function setup_rustup
header_banner "Set up rustup"
if type -q rustup
echo "Detected rustup at $(which rustup), executing personal setup..."
echo "--- rustup default stable"
rustup default stable
echo "--- rustup component add rust-src"
rustup component add rust-src
echo
echo "--- rustup component add rust-analyzer"
rustup component add rust-analyzer
set local_rust_analyzer $HOME/.local/bin/rust-analyzer
if ! test -e "$local_rust_analyzer"
set rustup_rust_analyzer (rustup which --toolchain stable rust-analyzer)
echo
echo "--- symlinking $rustup_rust_analyzer to $local_rust_analyzer"
mkdir -p (dirname $local_rust_analyzer)
ln -s $rustup_rust_analyzer $local_rust_analyzer
end
else
echo "rustup not found."
end
end
setup_fish_vendor
set_fish_universal_vars
set_default_shell
setup_emacs
setup_rustup