kamiyaa / joshuto

ranger-like terminal file manager written in Rust
https://crates.io/crates/joshuto
GNU Lesser General Public License v3.0
3.34k stars 151 forks source link

Feature Request: add more useful variables for shell/spawn commands #541

Open as3ii opened 1 month ago

as3ii commented 1 month ago

it can be useful to have more variables accessible while composing a command with :shell and :spawn (particularly in keymap.toml. Below is an example that would satisfy one of my use cases:

:spawn alacritty --working-directory "%f" -e joshuto

Or :spawn alacritty -e joshuto "%f" where %f (random letter) is replaced with the path of the current directory.

Other useful variables can be $SHELL and $EDITOR to compose commands without invoking external scripts or hardcoding which is the preferred shell or editor (for example).

Workarounds/suggestions are welcome (shell scripts aside)

as3ii commented 1 month ago

in joshuto 0.9.8 something like this don't work (joshuto crash):

:shell a="%s"; alacritty --working-directory "${a%/*}"

and in the following the string %s is not substituted correctly:

:shell bash -c "a=%s; alacritty --working-directory ${a%/*}"