-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more parameter-variables to more commands (like %s
for shell
)
#456
Comments
I'm cool with breaking changes if it means better UX and maintainability moving forward |
Hi, However, I did some experimental implementations around Christmas and I came to the conclusion that a generic variable solution I had in mind won't work well with the current way Joshuto parses the command line input. To get such a solution straight, it would require a complete refactoring of Joshuto's command handling. The problem is mostly with escaping and quoting (I don't even remember all the details). I thought of introducing some CLI parser library (like I then re-thought to just introduce new variables the same way we already have My latest idea now is to leave all commands just as they are but to introduce one new command, which I currently call This
So, instead of using variables with the Just dumping my thoughts here. If somebody has ideas or opinions, feel free.... 😉 |
Hi,
to get on with #241 (comment), I would maybe try to add more variables to more commands soon.
Currently, only
spawn
andshell
support the variable%s
, which is substituted by a list of names of the selected files.The idea is...
d
for the current directory, ort
for a list of directories of all tabs )stdout
of the lastshell
sub-processPoint 1. would allow to hand over more information to external scripts, like the list of tabs, the highlighted file, or the current directory.
With 2. and 3. and the command-chains, introduced in 31beaab, it would be possible to process the output of scripts in joshuto, like opening a new tab in a directory that was calculated by a script, or to select certain files (would require a new command to select multiple files by index or name).
As we would have to format dynamic strings with a potentially growing number of named variables, this would require some kind of dynamic string formatting library or a template engine that is able to substitute sub-strings by name, not only by position. Because we don't want some complex HTML-template engine for this, I see only two options at hand in Rust-land:
{}
for variables, which increases the chances for bad surprises for users)If somebody knows a better alternative, please let me know.
However, all these solutions would require a breaking change in Joshuto:
%s
would change to something else, for example{{s}}
. @kamiyaa: Would that be acceptable?I would probably implement the variable substitution in
src/key_command/impl_from_str.rs
, either for some dedicated commands or for the complete command-line string as it comes in. Have to think about it.Input welcome. Maybe I would take this up in the next weeks.
The text was updated successfully, but these errors were encountered: