mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
[zsh] parse rustup settings with a zsh script instead to further improve performance
This commit is contained in:
parent
27f9b351c1
commit
412015d374
1 changed files with 15 additions and 12 deletions
27
zsh/path.zsh
27
zsh/path.zsh
|
@ -77,25 +77,28 @@ if [[ -f ~/.rustup/settings.toml ]]; then
|
||||||
# use of rustup's CLI. Also a shortcut is taken: strings aren't unescaped
|
# use of rustup's CLI. Also a shortcut is taken: strings aren't unescaped
|
||||||
# because Rust toolchain names don't need escaping in strings.
|
# because Rust toolchain names don't need escaping in strings.
|
||||||
# See also <https://github.com/toml-lang/toml/blob/master/toml.abnf>.
|
# See also <https://github.com/toml-lang/toml/blob/master/toml.abnf>.
|
||||||
if rust_toolchain="$(
|
rust_toolchain=""
|
||||||
awk '
|
< ~/.rustup/settings.toml while IFS= read -r line; do
|
||||||
match($0, /^default_toolchain = "(.+)"$/, matches) {
|
if [[ "$line" =~ '^default_toolchain = "(.+)"$' ]]; then
|
||||||
print matches[1];
|
rust_toolchain="${match[1]}"
|
||||||
exit;
|
break
|
||||||
}
|
elif [[ "$line" == \[*\] ]]; then
|
||||||
/^\[.+\]$/ {
|
break
|
||||||
exit;
|
fi
|
||||||
}
|
done; unset line
|
||||||
' ~/.rustup/settings.toml
|
|
||||||
)" && [[ -n "$rust_toolchain" ]]; then
|
if [[ -n "$rust_toolchain" ]]; then
|
||||||
rust_sysroot=~/.rustup/toolchains/"$rust_toolchain"
|
rust_sysroot=~/.rustup/toolchains/"$rust_toolchain"
|
||||||
path_prepend path "$rust_sysroot"/bin
|
path_prepend path "$rust_sysroot"/bin
|
||||||
path_prepend fpath "$rust_sysroot"/zsh/site-functions
|
path_prepend fpath "$rust_sysroot"/zsh/site-functions
|
||||||
path_prepend manpath "$rust_sysroot"/share/man
|
path_prepend manpath "$rust_sysroot"/share/man
|
||||||
path_prepend ld_library_path "$rust_sysroot"/lib
|
path_prepend ld_library_path "$rust_sysroot"/lib
|
||||||
|
unset rust_sysroot
|
||||||
fi
|
fi
|
||||||
unset rust_toolchain rust_sysroot
|
|
||||||
|
unset rust_toolchain
|
||||||
fi
|
fi
|
||||||
|
|
||||||
path_prepend path ~/.cargo/bin
|
path_prepend path ~/.cargo/bin
|
||||||
|
|
||||||
# add my binaries and completions
|
# add my binaries and completions
|
||||||
|
|
Loading…
Reference in a new issue