It's hacky, but you could read /proc/$PID/cmdline. It's a NUL-delimited
file containing the entire commandline used to start the process. Then you
can use readlink -f to find the absolute path. If the first element
resolves to the path of fish, the second should resolve to the path of the
script.


2013/6/11 Michael Stillwell <m...@beebo.org>

> I can't seem to get $_ to output the name of the script.  Sometimes
> it's blank, and sometimes ".".
>
> For example, "echo $_" in my ~/.config/fish/config.fish outputs a blank
> line.
>
> Some other experiments:
>
>   $ echo $FISH_VERSION
>   2.0.0
>   $ cat foo.fish
>   echo $_
>   $ fish foo.fish
>   [blank line]
>   $ . foo.fish
>   .
>
> Compared to bash:
>
>   $ cat foo.bash
>   echo $0
>   $ bash foo.bash
>   foo.bash
>   $ . foo.bash
>   bash
>
>
>
> Cheers,
> Michael
>
> On Tue, Jun 11, 2013 at 3:56 PM, Alex Boisvert <alex.boisv...@gmail.com>
> wrote:
> > Try $_
> >
> > from http://fishshell.com/docs/2.0/index.html#variables
> >
> >
> > On Tuesday, June 11, 2013, Michael Stillwell wrote:
> >>
> >> Is there a fish equivalent of $0 (the full pathname of the running
> >> script)?  (Or indeed any way to determine what directory a script is
> >> in, from within the script itself?)
> >>
> >>
> >>
> >>
> >> Michael
> >>
> >>
> >>
> ------------------------------------------------------------------------------
> >> This SF.net email is sponsored by Windows:
> >>
> >> Build for Windows Store.
> >>
> >> http://p.sf.net/sfu/windows-dev2dev
> >> _______________________________________________
> >> Fish-users mailing list
> >> Fish-users@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/fish-users
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Windows:
>
> Build for Windows Store.
>
> http://p.sf.net/sfu/windows-dev2dev
> _______________________________________________
> Fish-users mailing list
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users
>
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to