Search code examples
fish

How to execute custom fish scripts in custom path folder


I'm having trouble executing a fish shell script I created. I added it to a custom path I added using fish_add_path. The folder appears just fine in $fish_user_paths and $PATH, and i've CHMOD +x the file, but when I type the name of the file, (which is pickc ath the moment), it can't find the command. How do I add fish scripts to the path and execute them like any other cli command (e.g. pickc)?

The content of the script is:

#!usr/bin/fish

colorpicker --short --one-shot --preview | sed -z 's/\n//g' | xclip -selection c
pkill picom
picom -b

I can execute the script just fine with the fish -c pickc command, but I can't execute with ./pickc, which gives me the error

Failed to execute process './pickc'. Reason: The file './pickc' does not exist or could not be executed.

I have doubly confirmed that the path in the $PATH and $fish_user_variable variable does lead to the folder containing the script.

Edit: I noticed that my paths were all really messed up somehow. The below answer does fix the issue of not being able to execute it, so thanks


Solution

  • You have mistyped your shebang. Switch

    #!usr/bin/fish
    

    to

    #!/usr/bin/fish
    

    or whatever path which fish shows.