-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Simple :sh command substitutions #3134
Comments
It's a bit of a nit but I'd prefer more explicit names like |
Indeed, whole words as tokens is indeed nicer, especially when combined with completion to speed up the typing. Also it occurred to me the
|
I imagine this would be implemented by setting environment variables for the shell command and then the shell command would interpret them - so |
Ah, yes, of course we have full control over the env space at execution time. Still would like to have some help typing the longer vars though ;) |
I think longer variable names also follows Helix' way of doing things. I imagine that aliases would be implemented in the future with more configuration options. Instead of environment variables, configuration variables could be used as well, for the |
Revised table:
|
I think we should start small: we probably only need file, line and column. The others can be derived in the shell with |
I would suggest keeping $HX_PATH as this is a known fact of the editor, not having it would add unneeded clutter to constructing an arbitrary command line. |
🕵️♂️ No clue either, haven't used it in a long time.. but I certainly hope command.com got improved upon. 🤔 Is Cygwin still around? |
Windows has the capacity to derive the same values and Cygwin, or similar programs, are available. I'd recommend WSL if you need Linux capabilities, though, compared to Cygwin or other alternatives. |
I kind of like the way Kakoune does it. They have interpolations like On that note I'd love to be able to access the regex captures that way too - registers 0-9 in Kakoune are used for the capture groups. So you can |
@devyn Ah, that's an interesting take on it. Looks pretty nice. I wonder if there's a common Rust library that essentially does the same thing. Kakoune Commands (Prompt) The only expansions I can think of with Vim is |
The percent register comes from vim. I have a habit of constantly in vim using adhoc shell commands like eg. Bonus points for keeping it simple to type. |
it would be great to define custom variables like these as part of my config as well - I'm currently using kitty remote to trigger tests, file browser, etc. however, every command I build has to begin with 40 characters of setup before I get to my 6 character's command and e.g.
vs
|
It could potentially be useful to also provide context information like the class / function path names relative to the current cursor position e.g. to trigger single tests for some test runners. See also #5014 (comment). |
I would love something like this to be able to make a copy of the current file I am working on in the same directory. e.g. Given I have
|
This is the exact use case I came here looking for. It would be nice to support a multiline selection (like I'm assuming that the LINE/COLUMN vars refer only to the primary selection, and other cursors are ignored, right? Or do we run the command separately on each selection? |
Not being able to have commands parameterized by either context variables like the current file or the output of a shell command is blocking so many workflow integration tasks for me (stuff like I think simple and well-designed shell-integration features like this, the existing |
This is a really important feature for using helix. |
Is there a way to copy |
This one is the only issue that is keeping me from switching to helix. The thing is that helix has great built in features however there are few things which are non standard that I heavily rely on. Unfortunately helix is not giving us any way to integrate custom stuff. Adding a way to pass information about current selection (or current cursor positions) to a shell script would solve 90% of the issues. |
The PR that has been open for a while to implement this appears to be stuck on some tricky parsing issues. I wonder if we can sidestep the need to figure out the ideal variable expansion implementation by having
Compared to the command parsing issues of #6979, it would be both simpler as well as not introducing any changes that would be broken when that PR eventually merges. |
@finalclass: Have you tried yank_main_selection_to_clipboard then pipe it to a shell script by using :sh, :insert-output, ...: [keys.select.";"]
q = ["yank_main_selection_to_clipboard", "delete_selection", ":insert-output echo `pbpaste` | quicktype -l go"]
WezTerm has a feature to get the content of a pane. In the mean time, would you like to give it a try? status_line=$(wezterm cli get-text | rg -e "(?:NORMAL|INSERT|SELECT)\s+[\x{2800}-\x{28FF}]*\s+(\S*)\s[^│]* (\d+):*.*" -o --replace '$1 $2')
filename=$(echo $status_line | awk '{ print $1}')
line_number=$(echo $status_line | awk '{ print $2}') https://quantonganh.com/2023/08/19/turn-helix-into-ide.md#running-code |
@quantonganh I'm not sure how this is different from |
Sorry for breaking up the @finalclass's question into two smaller questions. @rcorre I meant that:
"open")
remote_url=$(git config remote.origin.url)
if [[ $remote_url == *"github.com"* ]]; then
gh browse $filename:$line_number
else
current_branch=$(git rev-parse --abbrev-ref HEAD)
open $(echo $remote_url | sed -e 's|:|/|' -e 's|\.git||' -e 's|git@|https://|')/-/blob/${current_branch}/${filename}#L${line_number}
fi
;; |
My bad @quantonganh, I didn't read closely enough. It would still be great to have a non-terminal specific solution, but that's a neat workaround! |
In your example, how can you reference the file currently opened in helix active buffer? Let's say you don't want to do "pnpm test" over all the files but just current one. |
It would be nice to be able to reference editor information on the
:sh
line.Things like for example:
to be able to execute things like:
:sh gh browse $fn:$ln
Of course above example is just a starting point to get the idea across.
The text was updated successfully, but these errors were encountered: