pkill37 / linuxify

🍏🐧 Transparently transform the macOS CLI into a fresh GNU/Linux CLI experience.
MIT License
909 stars 72 forks source link

Add .linuxify.fish for Fish shell? #40

Open krissrex opened 8 months ago

krissrex commented 8 months ago

I tried porting the .linuxify to a script you run once with source .linuxify.fish.

set -l BREW_HOME (brew --prefix)

# Keep default manpath
echo 'set -gx MANPATH $MANPATH (cat /private/etc/manpaths | tr \'\n\' \':\')' >> "$__fish_config_dir/conf.d/linuxify.fish"

# most programs
fish_add_path --prepend "$BREW_HOME/bin"
echo 'set -gx MANPATH "'$BREW_HOME'/share/man" $MANPATH' >> "$__fish_config_dir/conf.d/linuxify.fish"
echo 'set -gx INFOPATH "'$BREW_HOME'/share/info" $INFOPATH' >> "$__fish_config_dir/conf.d/linuxify.fish"

# coreutils
fish_add_path --prepend "$BREW_HOME/opt/coreutils/libexec/gnubin"
echo 'set -gx MANPATH "'$BREW_HOME'/opt/coreutils/libexec/gnuman" $MANPATH' >> "$__fish_config_dir/conf.d/linuxify.fish"

# make
fish_add_path --prepend "$BREW_HOME/opt/make/libexec/gnubin"
echo 'set -gx MANPATH "'$BREW_HOME'/opt/make/libexec/gnuman" $MANPATH' >> "$__fish_config_dir/conf.d/linuxify.fish"

# m4
fish_add_path --prepend "$BREW_HOME/opt/m4/bin"

# file-formula
fish_add_path --prepend "$BREW_HOME/opt/file-formula/bin"

# unzip
fish_add_path --prepend "$BREW_HOME/opt/unzip/bin"

# python
fish_add_path --prepend "$BREW_HOME/opt/python/libexec/bin"

# flex
fish_add_path --prepend "$BREW_HOME/opt/flex/bin"
echo 'set -gx LDFLAGS "-L'$BREW_HOME'/opt/flex/lib"' >> "$__fish_config_dir/conf.d/linuxify.fish"
echo 'set -gx CPPFLAGS "-I'$BREW_HOME'/opt/flex/include"' >> "$__fish_config_dir/conf.d/linuxify.fish"

# bison
fish_add_path --prepend "$BREW_HOME/opt/bison/bin"
echo 'set -gx LDFLAGS "-L'$BREW_HOME'/opt/bison/lib"' >> "$__fish_config_dir/conf.d/linuxify.fish"

# libressl
fish_add_path --prepend "$BREW_HOME/opt/libressl/bin"
echo 'set -gx LDFLAGS "-L'$BREW_HOME'/opt/libressl/lib"' >> "$__fish_config_dir/conf.d/linuxify.fish"
echo 'set -gx CPPFLAGS "-I'$BREW_HOME'/opt/libressl/include"' >> "$__fish_config_dir/conf.d/linuxify.fish"
echo 'set -gx PKG_CONFIG_PATH "'$BREW_HOME'/opt/libressl/lib/pkgconfig"' >> "$__fish_config_dir/conf.d/linuxify.fish"

# ed
fish_add_path --prepend "$BREW_HOME/opt/ed/libexec/gnubin"

# findutils
fish_add_path --prepend "$BREW_HOME/opt/findutils/libexec/gnubin"
set -gx MANPATH "/opt/homebrew/opt/findutils/libexec/gnuman" $MANPATH

# gnu-indent
fish_add_path --prepend "$BREW_HOME/opt/gnu-indent/libexec/gnubin"

# gnu-sed
fish_add_path --prepend "$BREW_HOME/opt/gnu-sed/libexec/gnubin"

# gnu-tar
fish_add_path --prepend "$BREW_HOME/opt/gnu-tar/libexec/gnubin"

# gnu-which
fish_add_path --prepend "$BREW_HOME/opt/gnu-which/libexec/gnubin"

# grep
fish_add_path --prepend "$BREW_HOME/opt/grep/libexec/gnubin"

set -e BREW_HOME
krissrex commented 8 months ago

to uninstall, rm $__fish_config_dir/conf.d/linuxify.fish will remove the set statements.

However, the fish_add_path must be removed some other way. These are added to the $fish_user_paths array env, which is a "universal variable" and persisted to ~/.config/fish/fish_variables.

Alternatively, I could use --path and echo all these to the conf.d/.linxify.fish as well.

krissrex commented 8 months ago

Just realised the set -l BREW_HOME (brew --prefix) will not get baked into echo 'set -gx MANPATH "$BREW_HOME/share/man" ..., so the script will just set /share/man when it runs. Got to fix that.

Edit: fixed

krissrex commented 8 months ago

I also believe /opt/homebrew/opt/findutils/libexec/man is missing. Without it, you get the default manpage for xargs (unless you do man gxargs).

Edit: fixed