improve fish startup speed by generating exportenvs.fish
This commit is contained in:
parent
69cf2c98f8
commit
ab2d8ea07d
|
@ -1,8 +1,9 @@
|
||||||
source ~/.aliases
|
source ~/.aliases
|
||||||
|
|
||||||
# Environment variables
|
# Environment variables
|
||||||
for line in (cat ~/.exportenvs)
|
# ~/.exportenvs.fish is generated by ~/dotscripts/gen/fish-exportenvs
|
||||||
bass $line
|
if test -f ~/.exportenvs.fish
|
||||||
|
source ~/.exportenvs.fish
|
||||||
end
|
end
|
||||||
|
|
||||||
if test -f ~/.config/fish/config_local.fish
|
if test -f ~/.config/fish/config_local.fish
|
||||||
|
|
|
@ -75,7 +75,12 @@ Here are detailed information for each compenent of my dotfiles
|
||||||
I don't track `bashrc` or `bash_profile` because I like to keep it to the system's defaults.
|
I don't track `bashrc` or `bash_profile` because I like to keep it to the system's defaults.
|
||||||
|
|
||||||
The fish shell configuration is at `.config/fish/` and `config.fish` doesn't really anything specific,
|
The fish shell configuration is at `.config/fish/` and `config.fish` doesn't really anything specific,
|
||||||
it just sources the shared environment variable file (`.exportenvs`) and the shared aliases (`.aliases`).
|
it just sources the shared environment variable file (`.exportenvs.fish`) and the shared aliases (`.aliases`).
|
||||||
|
|
||||||
|
The `.exportenvs.fish` file is generated by [`dotscripts/gen/fish-exportenvs`](dotscripts/gen/fish-exportenvs).
|
||||||
|
It takes [`.exportenvs`](.exportenvs) and translates it into fish syntax. Instead of
|
||||||
|
using bass to source `.exportenvs` on the fly during fish's startup, fish can
|
||||||
|
source the generated `.exportenvs.fish` directly which improves performance signifanctly.
|
||||||
|
|
||||||
I have a symlink `.bash_aliases` pointing to `.aliases` because bash likes to look for that file.
|
I have a symlink `.bash_aliases` pointing to `.aliases` because bash likes to look for that file.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/env fish
|
||||||
|
|
||||||
|
# Stubbornly translates ~/.exportenvs to ~/.exportenvs.fish
|
||||||
|
|
||||||
|
echo "" > ~/.exportenvs.fish # clear the file
|
||||||
|
|
||||||
|
for fileline in (cat ~/.exportenvs | sed 's/#!.\+$/#!\/usr\/bin\/env fish/')
|
||||||
|
set line (echo "$fileline" | sed 's/export //' | sed 's/#.\+//')
|
||||||
|
if test -z "$line"
|
||||||
|
echo "Adding '$fileline' as-is"
|
||||||
|
echo "$fileline" >> ~/.exportenvs.fish
|
||||||
|
continue
|
||||||
|
end
|
||||||
|
set name (echo "$line" | sed 's/=.\+$//' | sed 's/^$//')
|
||||||
|
set content (echo "$line" | sed 's/^.\+=//' | sed 's/\$(/(/')
|
||||||
|
echo "Adding $name with $content"
|
||||||
|
echo set -x "$name" $content >> ~/.exportenvs.fish
|
||||||
|
end
|
|
@ -25,6 +25,12 @@ fi
|
||||||
|
|
||||||
echo Maybe add ~/local/share/man to manpath but I forgot how as of writing
|
echo Maybe add ~/local/share/man to manpath but I forgot how as of writing
|
||||||
|
|
||||||
|
# env
|
||||||
|
if ! [ -f ~/.exportenvs.fish ]; then
|
||||||
|
echo "Generating ~/.exportenvs.fish"
|
||||||
|
~/dotscripts/gen/fish-exportenvs
|
||||||
|
fi
|
||||||
|
|
||||||
# TODO have a better check for omf existence (command -v doesnt work)
|
# TODO have a better check for omf existence (command -v doesnt work)
|
||||||
# Although omf does this same check lol
|
# Although omf does this same check lol
|
||||||
if [ ! -d ~/.local/share/omf ]; then
|
if [ ! -d ~/.local/share/omf ]; then
|
||||||
|
|
Loading…
Reference in New Issue