Skip to content
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

Launching bash script with a keybinding #1541

Closed
fjvico opened this issue Jul 14, 2017 · 11 comments
Closed

Launching bash script with a keybinding #1541

fjvico opened this issue Jul 14, 2017 · 11 comments
Labels

Comments

@fjvico
Copy link

fjvico commented Jul 14, 2017

Hi! Anyone here could tell me how to include a line in keybindings.conf so as to run a bash script when a key is pressed? Say that /.local/bin/toggle must be launched when Tab is pressed.
Not really an issue, the issue is in fact that there's little information on how to do this.

@elextr
Copy link
Member

elextr commented Jul 15, 2017

Well you could try defining one of the custom commands to run your script, and defining Tab as the shortcut, but I suspect Tab is a little too overloaded, its used of a number of things and is context sensitive.

@fjvico
Copy link
Author

fjvico commented Jul 15, 2017

@elextr Could you provide a link to how these commands are defined? Haven't deal with that before and the handbook doesn't seem to make it clear.

@elextr
Copy link
Member

elextr commented Jul 15, 2017

"custom commands" and the next section "context actions" depending if you want to replace the input with the output or not.

@fjvico
Copy link
Author

fjvico commented Jul 20, 2017

@elextr done, but there's a problem with this solution: these custom commands are intended to replace selected text or the current line with the output of the command, so a part of the actual document vanishes after executing it with the assigned shortcut. I tried to add an 'echo $1' to the bash script that is executed, but it doesn't work. Any suggestion to allow a normal execution of the external command without altering the original text document?

@elextr
Copy link
Member

elextr commented Jul 20, 2017

The context action does not modify the selection AFAIK.

@fjvico
Copy link
Author

fjvico commented Jul 20, 2017

@elextr That should work. Any idea about how to keybind to a context command?
An entry like:
custom_commands=/mypath/mycommand;
will do it for a custom command, but what is the prefix for context commands?

@elextr
Copy link
Member

elextr commented Jul 20, 2017

The section of the manual I linked above refers.

@fjvico
Copy link
Author

fjvico commented Jul 20, 2017

Problem is, as I can see while it runs, that you need to select or the cursor sit on a word to make it work, it won't work on empty lines.

@fjvico
Copy link
Author

fjvico commented Jul 21, 2017

@elextr Adding a 'cat "$1"' to the script and calling the custom command seems to do the job. Only thing is that it selects the current line, what is not a desired effect.

@elextr
Copy link
Member

elextr commented Jul 22, 2017

Yes, the command works on the selection, it just helpfully selects the current line if nothing is selected.

@codebrainz
Copy link
Member

This seems basically solved, feel free to re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants