-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathsetup.sh
executable file
·54 lines (45 loc) · 1.51 KB
/
setup.sh
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
#! /usr/bin/env sh
DIR=$(dirname "$0")
cd "$DIR"
. ../scripts/functions.sh
SOURCE="$(realpath -m .)"
DESTINATION="$(realpath -m ~/.config/fish)"
info "Setting up fish shell..."
substep_info "Creating fish config folders..."
mkdir -p "$DESTINATION/functions"
mkdir -p "$DESTINATION/completions"
find * -name "*.fish" -o -name "fishfile" | while read fn; do
symlink "$SOURCE/$fn" "$DESTINATION/$fn"
done
clear_broken_symlinks "$DESTINATION"
set_fish_shell() {
if grep --quiet fish <<< "$SHELL"; then
success "Fish shell is already set up."
else
substep_info "Adding fish executable to /etc/shells"
if grep --fixed-strings --line-regexp --quiet "$(which fish)" /etc/shells; then
substep_success "Fish executable already exists in /etc/shells."
else
if sudo bash -c "echo "$(which fish)" >> /etc/shells"; then
substep_success "Fish executable added to /etc/shells."
else
substep_error "Failed adding Fish executable to /etc/shells."
return 1
fi
fi
substep_info "Changing shell to fish"
if chsh -s "$(which fish)"; then
substep_success "Changed shell to fish"
else
substep_error "Failed changing shell to fish"
return 2
fi
substep_info "Running fish initial setup"
fish -c "setup"
fi
}
if set_fish_shell; then
success "Successfully set up fish shell."
else
error "Failed setting up fish shell."
fi