Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I unset a variable in the fish shell?

Tags:

fish

In bash I can unset a variable with

unset myvar 

In fish I get

fish: Unknown command 'unset' 

What's the equivalent for unset in fish.

like image 529
J0hnG4lt Avatar asked Jun 08 '15 07:06

J0hnG4lt


People also ask

How do you set a variable in a fish shell?

To give a variable to an external command, it needs to be “exported”. Unlike other shells, fish does not have an export command. Instead, a variable is exported via an option to set , either --export or just -x .

How do you unset a PATH variable?

Using the set -n command Alternatively, you can unset environment variables by using the set command with the “-n” flag.

What command do you use to totally remove a variable?

To clear all variables from the current workspace, use clear or clearvars .


1 Answers

Fish uses options on the set command to manipulate shell variables.

Unset a variable with the -e or --erase option.

set -e myvar  

Additionally you can define a function

function unset   set --erase $argv end  funcsave unset 

or an abbreviation

abbr --add unset 'set --erase' 

or an alias in ~/.config/fish/config.fish

alias unset 'set --erase' 
like image 106
J0hnG4lt Avatar answered Oct 14 '22 17:10

J0hnG4lt