Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Directory of running script in Fish shell

Tags:

bash

fish

I'm trying to get SBT running using the Fish shell. Below is the equivalent Bash script of what I'm trying to achieve:

java -Xmx512M -jar `dirname $0`/sbt-launch.jar "$@"

I see in the Fish documentation that $@ in Bash can be replaced with $argv in Fish. But I cannot see what to replace dirname $0 with.

Does anyone know the equivalent script in Fish?

like image 213
BefittingTheorem Avatar asked Jul 27 '10 13:07

BefittingTheorem


People also ask

How do I find the directory of a script?

pwd can be used to find the current working directory, and dirname to find the directory of a particular file (command that was run, is $0 , so dirname $0 should give you the directory of the current script).

How do I run a fish shell script?

To be able to run fish scripts from your terminal, you have to do two things. Add the following shebang line to the top of your script file: #!/usr/bin/env fish . Mark the file as executable using the following command: chmod +x <YOUR_FISH_SCRIPT_FILENAME> .

Where is the fish config file?

The configuration file runs at every login and is located at ~/. config/fish/config. fish . Adding commands or functions to the file will execute/define them when opening a terminal, similar to .


1 Answers

$_ only seems to work directly via the reader/command line, or when the script is sourced, for me.

Maybe this will work for you:

java -Xmx512M -jar (dirname (status -f))/sbt-launch.jar "$argv"      # fish
like image 159
otherchirps Avatar answered Sep 28 '22 06:09

otherchirps