Skip to content

Commit d288968

Browse files
authored
Merge pull request #164 from andrewfung729/master
Fish shell support
2 parents 05dadaf + 380d50f commit d288968

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

install.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,34 @@ export G_MIRROR=https://golang.google.cn/dl/
7474
EOF
7575
fi
7676

77+
if [ -x "$(command -v fish)" ]; then
78+
# Create fish-specific env file
79+
cat >${HOME}/.g/env.fish <<-'EOF_ENV_FISH'
80+
# g shell setup for fish
81+
82+
set -gx GOROOT "$HOME/.g/go"
83+
set -gx G_MIRROR "https://golang.google.cn/dl/"
84+
85+
# Add g, GOROOT/bin, and GOPATH/bin (if set) to PATH using fish_add_path
86+
fish_add_path "$HOME/.g/bin"
87+
fish_add_path "$GOROOT/bin"
88+
89+
set -gx GOPATH "$HOME/go"
90+
91+
if set -q GOPATH;
92+
fish_add_path "$GOPATH/bin"
93+
end
94+
EOF_ENV_FISH
95+
96+
# Configure fish to source env.fish
97+
local fish_conf_d_dir="${HOME}/.config/fish/conf.d"
98+
mkdir -p "${fish_conf_d_dir}"
99+
cat >"${fish_conf_d_dir}/g.fish" <<-'EOF_G_FISH_CONF'
100+
# g shell setup
101+
if test -s "$HOME/.g/env.fish"; and source "$HOME/.g/env.fish"; end
102+
EOF_G_FISH_CONF
103+
fi
104+
77105
echo -e "\nTo configure your current shell, run:\nsource \"$HOME/.g/env\""
78106

79107
exit 0

0 commit comments

Comments
 (0)