diff options
| author | ruki <[email protected]> | 2023-03-03 22:50:30 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-03-03 22:50:30 +0800 |
| commit | 317910e7d4c19fc5aa461edea90cda0f2b16bc25 (patch) | |
| tree | c4f912b64c4811ba08d85c60e58df63a23fe3b71 | |
| parent | 409fe90b6fa9a58e7bc34471ecbab945399235e7 (diff) | |
improve fish profile
| -rw-r--r-- | xmake/actions/update/main.lua | 9 | ||||
| -rw-r--r-- | xmake/scripts/profile-unix.fish | 23 | ||||
| -rw-r--r-- | xmake/scripts/profile-unix.sh | 12 |
3 files changed, 31 insertions, 13 deletions
diff --git a/xmake/actions/update/main.lua b/xmake/actions/update/main.lua index 0590ab78f..afaed9e18 100644 --- a/xmake/actions/update/main.lua +++ b/xmake/actions/update/main.lua @@ -313,8 +313,13 @@ function _initialize_shell() -- write home profile local profile = "$XMAKE_PROGRAM_DIR/scripts/profile-unix.sh" - local bridge_command = format("export XMAKE_ROOTDIR=\"%s\"\nexport XMAKE_PROGRAM_DIR=\"%s\"\nexport PATH=\"$XMAKE_ROOTDIR:$PATH\"\n", path.directory(os.programfile()), os.programdir()) - bridge_command = bridge_command .. format("test -f \"%s\" && source \"%s\"\n", profile, profile) + local profile_fish = "$XMAKE_PROGRAM_DIR/scripts/profile-unix.fish" + local bridge_command = format([[export XMAKE_ROOTDIR="%s" +export XMAKE_PROGRAM_DIR="%s" +export PATH="$XMAKE_ROOTDIR:$PATH" +test $FISH_VERSION && test -f "%s" && source "%s" && exit 0 +test -f "%s" && source "%s" +]], path.directory(os.programfile()), os.programdir(), profile_fish, profile_fish, profile, profile) io.writefile("~/.xmake/profile", bridge_command) end diff --git a/xmake/scripts/profile-unix.fish b/xmake/scripts/profile-unix.fish new file mode 100644 index 000000000..94c79e271 --- /dev/null +++ b/xmake/scripts/profile-unix.fish @@ -0,0 +1,23 @@ +# A cross-platform build utility based on Lua +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:##www.apache.org#licenses#LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Copyright (C) 2022-present, TBOOX Open Source Group. +# +# @author ruki +# @homepage profile-unix.fish +# + +# register completions +. "$XMAKE_PROGRAM_DIR/scripts/completions/register-completions.fish" + diff --git a/xmake/scripts/profile-unix.sh b/xmake/scripts/profile-unix.sh index 2e1f5b1d2..c3e62a734 100644 --- a/xmake/scripts/profile-unix.sh +++ b/xmake/scripts/profile-unix.sh @@ -18,23 +18,13 @@ # @homepage profile-unix.sh # -# enable bash compatibility for fish -set -U fish_compatibility shell - # register completions if [[ "$SHELL" = */zsh ]]; then . "$XMAKE_PROGRAM_DIR/scripts/completions/register-completions.zsh" elif [[ "$SHELL" = */bash ]]; then . "$XMAKE_PROGRAM_DIR/scripts/completions/register-completions.bash" -elif [[ "$SHELL" = */fish ]]; then - . "$XMAKE_PROGRAM_DIR/scripts/completions/register-completions.fish" fi # register virtualenvs -if [[ "$SHELL" = */fish ]]; then -# TODO -# . "$XMAKE_PROGRAM_DIR/scripts/virtualenvs/register-virtualenvs.fish" -else - . "$XMAKE_PROGRAM_DIR/scripts/virtualenvs/register-virtualenvs.sh" -fi +. "$XMAKE_PROGRAM_DIR/scripts/virtualenvs/register-virtualenvs.sh" |
