Can I make “less” execute arbitrary commands with a single key sequence?
Reading the less
and lesskeys
manpages, I have created a file containing:
^B shell touch ~/testfile
and run it through lesskey
to generate .less-test
, then executed less -k .less-test file
. This all works fine and does what I hope, except that I need to hit enter twice to actually execute the shell command and return to the file
. Changing the command to touch ~/testfilen
removes the need for one of those enter presses, but touch ~/testfilenn
doesn't work to get rid of them both. Is there a way to bypass hitting enter at all here?
As a follow-up question (and to explain why I'm asking in the first place)--I am doing this as a process of file tagging, where I inspect the file using less and want to use these hotkeys to write out to another file with one of two tags (which I plan to bind to two different key sequences). So in addition to not having to press enter twice as above, I'd also like to know if there's a way to immediately move to the next file (as with the next-file
lesskey command) also (that is, press no other keys besides the tagging key sequence).
shell less
add a comment |
Reading the less
and lesskeys
manpages, I have created a file containing:
^B shell touch ~/testfile
and run it through lesskey
to generate .less-test
, then executed less -k .less-test file
. This all works fine and does what I hope, except that I need to hit enter twice to actually execute the shell command and return to the file
. Changing the command to touch ~/testfilen
removes the need for one of those enter presses, but touch ~/testfilenn
doesn't work to get rid of them both. Is there a way to bypass hitting enter at all here?
As a follow-up question (and to explain why I'm asking in the first place)--I am doing this as a process of file tagging, where I inspect the file using less and want to use these hotkeys to write out to another file with one of two tags (which I plan to bind to two different key sequences). So in addition to not having to press enter twice as above, I'd also like to know if there's a way to immediately move to the next file (as with the next-file
lesskey command) also (that is, press no other keys besides the tagging key sequence).
shell less
add a comment |
Reading the less
and lesskeys
manpages, I have created a file containing:
^B shell touch ~/testfile
and run it through lesskey
to generate .less-test
, then executed less -k .less-test file
. This all works fine and does what I hope, except that I need to hit enter twice to actually execute the shell command and return to the file
. Changing the command to touch ~/testfilen
removes the need for one of those enter presses, but touch ~/testfilenn
doesn't work to get rid of them both. Is there a way to bypass hitting enter at all here?
As a follow-up question (and to explain why I'm asking in the first place)--I am doing this as a process of file tagging, where I inspect the file using less and want to use these hotkeys to write out to another file with one of two tags (which I plan to bind to two different key sequences). So in addition to not having to press enter twice as above, I'd also like to know if there's a way to immediately move to the next file (as with the next-file
lesskey command) also (that is, press no other keys besides the tagging key sequence).
shell less
Reading the less
and lesskeys
manpages, I have created a file containing:
^B shell touch ~/testfile
and run it through lesskey
to generate .less-test
, then executed less -k .less-test file
. This all works fine and does what I hope, except that I need to hit enter twice to actually execute the shell command and return to the file
. Changing the command to touch ~/testfilen
removes the need for one of those enter presses, but touch ~/testfilenn
doesn't work to get rid of them both. Is there a way to bypass hitting enter at all here?
As a follow-up question (and to explain why I'm asking in the first place)--I am doing this as a process of file tagging, where I inspect the file using less and want to use these hotkeys to write out to another file with one of two tags (which I plan to bind to two different key sequences). So in addition to not having to press enter twice as above, I'd also like to know if there's a way to immediately move to the next file (as with the next-file
lesskey command) also (that is, press no other keys besides the tagging key sequence).
shell less
shell less
edited 15 mins ago
Rui F Ribeiro
40.1k1479135
40.1k1479135
asked Aug 7 '14 at 20:53
Brandon HumpertBrandon Humpert
1185
1185
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
It will always display the "!done" message.
If you want, you could change "!done" to NULL in command.c (row 272 and 274) to get rid of this behavior.
To get it to execute next-file after the touch command for instance, you could add the following binding:
^B shell touch ~/testfilen:nn
(:n is the default binding for next-file)
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f149094%2fcan-i-make-less-execute-arbitrary-commands-with-a-single-key-sequence%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It will always display the "!done" message.
If you want, you could change "!done" to NULL in command.c (row 272 and 274) to get rid of this behavior.
To get it to execute next-file after the touch command for instance, you could add the following binding:
^B shell touch ~/testfilen:nn
(:n is the default binding for next-file)
add a comment |
It will always display the "!done" message.
If you want, you could change "!done" to NULL in command.c (row 272 and 274) to get rid of this behavior.
To get it to execute next-file after the touch command for instance, you could add the following binding:
^B shell touch ~/testfilen:nn
(:n is the default binding for next-file)
add a comment |
It will always display the "!done" message.
If you want, you could change "!done" to NULL in command.c (row 272 and 274) to get rid of this behavior.
To get it to execute next-file after the touch command for instance, you could add the following binding:
^B shell touch ~/testfilen:nn
(:n is the default binding for next-file)
It will always display the "!done" message.
If you want, you could change "!done" to NULL in command.c (row 272 and 274) to get rid of this behavior.
To get it to execute next-file after the touch command for instance, you could add the following binding:
^B shell touch ~/testfilen:nn
(:n is the default binding for next-file)
answered Aug 7 '14 at 21:15
Victor JerlinVictor Jerlin
24113
24113
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f149094%2fcan-i-make-less-execute-arbitrary-commands-with-a-single-key-sequence%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown