mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Append paths from /etc/manpaths and /etc/manpaths.d/* to MANPATH, for #1092.
* Only append paths if `MANPATH` is already set, to match behavior of macOS `path_helper` utility. * Use the same technique as is used above to set PATH from /etc/paths and /etc/paths.d/*.
This commit is contained in:
parent
574424dc5a
commit
6b536922af
1 changed files with 23 additions and 0 deletions
|
@ -144,6 +144,29 @@ set -xg PATH $__fish_tmp_path
|
||||||
set -e __fish_tmp_path
|
set -e __fish_tmp_path
|
||||||
functions -e __fish_load_path_helper_paths
|
functions -e __fish_load_path_helper_paths
|
||||||
|
|
||||||
|
# OS X-ism: Load the manpath files out of /etc/manpaths and /etc/manpaths.d/*
|
||||||
|
if set -q MANPATH
|
||||||
|
set -g __fish_tmp_manpath $MANPATH
|
||||||
|
function __fish_load_manpath_helper_manpaths
|
||||||
|
# We want to rearrange the manpath to reflect this order. Delete that manpath component if it exists and then prepend it.
|
||||||
|
# Since we are prepending but want to preserve the order of the input file, we reverse the array, append, and then reverse it again
|
||||||
|
set __fish_tmp_manpath $__fish_tmp_manpath[-1..1]
|
||||||
|
while read -l new_manpath_comp
|
||||||
|
if test -d $new_manpath_comp
|
||||||
|
set -l where (contains -i -- $new_manpath_comp $__fish_tmp_manpath)
|
||||||
|
and set -e __fish_tmp_manpath[$where]
|
||||||
|
set __fish_tmp_manpath $new_manpath_comp $__fish_tmp_manpath
|
||||||
|
end
|
||||||
|
end
|
||||||
|
set __fish_tmp_manpath $__fish_tmp_manpath[-1..1]
|
||||||
|
end
|
||||||
|
test -r /etc/manpaths ; and __fish_load_manpath_helper_manpaths < /etc/manpaths
|
||||||
|
for manpathfile in /etc/manpaths.d/* ; __fish_load_manpath_helper_manpaths < $manpathfile ; end
|
||||||
|
set -xg MANPATH $__fish_tmp_manpath
|
||||||
|
set -e __fish_tmp_manpath
|
||||||
|
functions -e __fish_load_manpath_helper_manpaths
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# Add a handler for when fish_user_path changes, so we can apply the same changes to PATH
|
# Add a handler for when fish_user_path changes, so we can apply the same changes to PATH
|
||||||
# Invoke it immediately to apply the current value of fish_user_path
|
# Invoke it immediately to apply the current value of fish_user_path
|
||||||
|
|
Loading…
Reference in a new issue