I love fish 🐟 shell because of its convenient auto suggestions and excellent performance.
I had, however, a slightly serious problem on switching from bash.
I didn't know how to use a modified environment in commands.
For example, I was in search for how to change the names of home subdirectories, and found the bash solution like this 🤔:
This means running the
xdg-user-dirs-gtk-update command with setting "C" for the
Running the same command failed in fish shell...🥴
I, however, didn't feel like always using an additional step such as the
bash command or
I wrote this post so as to demonstrate how to solve it.
* Besides: Just today, I found fish prints the great error message. Holy mackerel! :
fish: Unsupported use of '='. To run 'xdg-user-dirs-gtk-update' with a modified environment, please use 'env LANG=C xdg-user-dirs-gtk-update…'
In order to set a modified environment, it's possible in bash by using the
SOME_ENV=value format at the top:
EDITOR=vi git commit
But not about fish!
SOME_VAR=1 commandproduces an error:
Unknown command "SOME_VAR=1".
env SOME_VAR=1 command
You can also declare a local variable in a block:
env SOME_ENV=value format works nicely!!
env SOME_ENV=vi git commit
It's the same about tcsh.
*Note: It seems ignored if
env SOME_ENV=value command
Happy operating 🐈