In bash, we can retrieve the current script's path by $0
variable, so if any script has a dependency resource which is under the same directory as the script directory, we can use it even when we're not executing the script in the script's directory.
How can I retrieve the current script's path in fish shell?
It does this by adding the components either to $fish_user_paths or directly to $PATH (if the --path switch is given). It is (by default) safe to use fish_add_path in config. fish, or it can be used once, interactively, and the paths will stay in future because of universal variables.
At least by default, PATH is a global variable, which means it is per-session. That means to change something from $PATH, either remove it from where it is added (which is likely outside of fish since it inherits it), or put the set -e call in your ~/. config/fish/config. fish so it will be executed on every start.
Pressing Control + S (the pager-toggle-search binding - / in vi-mode) opens up a search menu that you can use to filter the list. Fish provides some general purpose completions: Commands (builtins, functions and regular programs). Shell variable names.
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 .
status --current-filename
is what you're looking for.
Note that this handles both sourced and executed files, while $0 in bash is only for executed files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With