Another possibility might be to store the code in a function instead of a
variable:

Instead of

        set -l TMP "echo -e \"$split[2]\""
        printf "%s" (eval $TMP) | read -gx $split[1]

You would

        alias TMP "echo -e \"$split[2]\""
        printf "%s" (TMP) | read -gx $split[1]
        # and tidy up afterward
        functions -e TMP



On Wed, Jan 9, 2019 at 9:45 PM Simon Lees <sfl...@suse.de> wrote:

> I'm going to resend this with slightly better formatting, some days I
> hate plain text
>
> Hi All,
>
> I do some probably "unusual" things with fish shell scripts, some of
> these have broken in fish 3.0, i'm going to start by describing the
> problem because i'm interested in any solution even if its significantly
> different to what I was doing before.
>
> For my prompt / greeting etc I prefer to use terminal escape sequences
> rather then fish's set_color methods, this is because it properly
> follows changes to my terminals palette which I do regularly depending
> on which machine the terminal session is in. To make this process more
> sane I store each escape sequence in an environment variable, and to
> make that less painful each environment variable is loaded from a file,
> some sample lines are below but you can see the full file here
>
> https://github.com/simotek/tackle/blob/simotek-theme/themes/simotek/simotek_theme_colors.en
> (note I also load a bunch of other env vars from other files)
>
>         smtk_clr_black=\e[0;30m# Black
>         smtk_clr_red=\e[0;31m# Red
>         smtk_clr_green=\e[0;32m# Green
>         smtk_clr_yellow=\e[0;33m# Yellow
>
> To make this more fun I sometimes also load environment variables that
> contain environment variables that need to be expanded such as
>
>         PATH=$PATH $HOME/.local/bin $HOME/src/Scripts /sbin /usr/sbin
>         # Fun test Enlightenment exports the variable PANTS as ON
>         SHIRT=$PANTS# Inline comment test
>
> Taken from
> https://github.com/simotek/tackle/blob/simotek-theme/default.env
>
> The code to load such variables used to look like this (note PATH is
> handled as a special case differently)
>
>         # need to expand $split[2] twice so that any vars stored
>  in the
> file get expanded
>         set -l TMP "echo -e \"$split[2]\""
>         printf "%s" (eval $TMP) | read -gx $split[1]
>
>
> Taken from line 118 of
>
> https://github.com/simotek/tacklebox/blob/feature-env-loader-theme/tacklebox.fish
> the echo -e substitutes in the terminal escape characters and the printf
> expands the environment variables.
>
> This now fails with the following:
>
>         eval $TMP
>         ^
>         in command substitution
>                called on line 223 of file
> ~/src/config/tacklebox/tacklebox.fish
>         in function “__tacklebox_load_env_file”
>                 called on line 334 of file
> ~/src/config/tacklebox/tacklebox.fish
>         in function “__tacklebox_load_env_files_in_dir”
>                 called on line 100 of file
> ~/src/config/tacklebox/tacklebox.fish
>         in function “__tacklebox_load_theme”
>                 called on line 209 of file
> ~/src/config/tacklebox/tacklebox.fish
>                 with parameter list “simotek”
>         from sourcing file ~/src/config/tacklebox/tacklebox.fish
>                 called on line 9 of file ~/.config/fish/config.fish
>         from sourcing file ~/.config/fish/config.fish
>                 called during startup
>
>
> Removing the eval so I have printf "%s ($TMP)" gives the following:
>
>         echo -e "\e[0;40m": command not found
>         ~/src/config/tacklebox/tacklebox.fish (line 1):
>         $TMP
>         ^
>         in command substitution
>                 called on line 223 of file
> ~/src/config/tacklebox/tacklebox.fish
>         in function “__tacklebox_load_env_file”
>                 called on line 12 of file
>         ~/src/config/tackle/themes/simotek/fish_right_prompt.fish
>         in function “fish_right_prompt”
>                 called on standard input
>         in command substitution
>                 called on standard input
>
>
> Thanks for any suggestions that you may have.
>
> --
>
> Simon Lees (Simotek)                            http://simotek.net
>
> Emergency Update Team                           keybase.io/simotek
> SUSE Linux                           Adelaide Australia, UTC+10:30
> GPG Fingerprint: 5B87 DB9D 88DC F606 E489 CEC5 0922 C246 02F0 014B
>
>
>
>
> _______________________________________________
> Fish-users mailing list
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users
>
>
> --
>
> Simon Lees (Simotek)                            http://simotek.net
>
> Emergency Update Team                           keybase.io/simotek
> SUSE Linux                           Adelaide Australia, UTC+10:30
> GPG Fingerprint: 5B87 DB9D 88DC F606 E489 CEC5 0922 C246 02F0 014B
>
>
> _______________________________________________
> Fish-users mailing list
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users
>


-- 
*Glenn Jackman*
Senior Software Developer

*Pythian - Love your data*
jack...@pythian.com
Tel: +1 613 565 8696 Ext. 1478
Mobile: +1 613 808 4984
www.pythian.com

-- 


--





_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to