leo-arch / clifm

The shell-like, command line terminal file manager: simple, fast, extensible, and lightweight as hell.
https://github.com/leo-arch/clifm/wiki
GNU General Public License v2.0
1.35k stars 39 forks source link

Make translations of shared functions for fish #240

Closed spenserblack closed 1 year ago

spenserblack commented 1 year ago

The one thing I didn't translate was subshell_notice.sh. The way to accomplish changing the prompt would be to edit $HOME/.config/fish/fish_prompt.fish. There are multiple built-in prompts, and even the default is pretty complex, so it's not much of a simple copy-and-paste job. Seemed to me like it would be better to refer fish users to documentation than provide code to copy-and-paste for this one.

But a simple prompt would be like

function fish_prompt
    set --local suffix ">"
    set --query CLIFM; and set --local suffix "(clifm)$suffix"
    echo -n -s "$suffix"
end

Also, I changed file_picker to use $argv instead of passing a CLIFM_OPTIONS variable. I'm not really sure what the purpose was in the original script, but I'm guessing the intent was to allow somebody to pass additional CLI options with that variable? If so, using $argv is more idiomatic for fish IMO, since these functions "wrap" clifm.

One interesting thing about fish is that it reads from a $HOME/.config/fish/functions directory, which means installation is as simple as copying these files to that directory. That opens up the possibility of a script like install-extensions.fish to automatically copy these files.

leo-arch commented 1 year ago

Thanks for your work @spenserblack! I tested both scripts following your instructions and everything seems to work as expected.

Yes, CLIFM_OPTIONS is just a placeholder for default arguments. $@ could be added to add command line parameters (I guess it's the same as the C-like $argv in fish).

An install-extensions.fish script would definitely be nice.

One last thing: please add header information (description, usage, deps, author, license) to both fish functions, just to keep a consistent style among functions/plugins.

Btw, does fish provide some shellcheck-like function for fish scripts?

spenserblack commented 1 year ago

Weird, I could've sworn I responded to this yesterday :confused:


An install-extensions.fish script would definitely be nice.

Sounds good :+1:

One last thing: please add header information (description, usage, deps, author, license) to both fish functions, just to keep a consistent style among functions/plugins.

Sure :+1:

Btw, does fish provide some shellcheck-like function for fish scripts?

Closest I know of is fish -n/--no-execute, which, as the name implies, doesn't execute, just asserts that the syntax is valid.

leo-arch commented 1 year ago

Thanks @spenserblack!

spenserblack commented 1 year ago

Oh, whoops. Should've converted this PR to a draft 😅

https://github.com/spenserblack/clifm/commit/960c89e4f7d4aa4da0ff242a14476d8b16b1574d

leo-arch commented 1 year ago

No problem. Just create a new PR.