Running a subshell from the middle of the current command
I frequently find my self in this scenario. I'm in the middle of typing a command and I need to check something else before I complete it.
Is there a way to open a subshell of some sort with my current input so far being remembered, then when I exit this subshell I'm back to where I was?
$ mylongcommand -n -e <SOME KEY COMBINATION WHICH OPENS A SUBSHELL>
$ date
...
$ exit
$ mylongcommand -n -e <BACK TO WHERE I WAS>
I'm using zsh
zsh
add a comment |
I frequently find my self in this scenario. I'm in the middle of typing a command and I need to check something else before I complete it.
Is there a way to open a subshell of some sort with my current input so far being remembered, then when I exit this subshell I'm back to where I was?
$ mylongcommand -n -e <SOME KEY COMBINATION WHICH OPENS A SUBSHELL>
$ date
...
$ exit
$ mylongcommand -n -e <BACK TO WHERE I WAS>
I'm using zsh
zsh
Why not just open another terminal window?
– Barmar
1 hour ago
add a comment |
I frequently find my self in this scenario. I'm in the middle of typing a command and I need to check something else before I complete it.
Is there a way to open a subshell of some sort with my current input so far being remembered, then when I exit this subshell I'm back to where I was?
$ mylongcommand -n -e <SOME KEY COMBINATION WHICH OPENS A SUBSHELL>
$ date
...
$ exit
$ mylongcommand -n -e <BACK TO WHERE I WAS>
I'm using zsh
zsh
I frequently find my self in this scenario. I'm in the middle of typing a command and I need to check something else before I complete it.
Is there a way to open a subshell of some sort with my current input so far being remembered, then when I exit this subshell I'm back to where I was?
$ mylongcommand -n -e <SOME KEY COMBINATION WHICH OPENS A SUBSHELL>
$ date
...
$ exit
$ mylongcommand -n -e <BACK TO WHERE I WAS>
I'm using zsh
zsh
zsh
asked 6 hours ago
PanayiotisPanayiotis
1503
1503
Why not just open another terminal window?
– Barmar
1 hour ago
add a comment |
Why not just open another terminal window?
– Barmar
1 hour ago
Why not just open another terminal window?
– Barmar
1 hour ago
Why not just open another terminal window?
– Barmar
1 hour ago
add a comment |
2 Answers
2
active
oldest
votes
There is the key combination EscQ which saves the command buffer and allows to enter a new command. After running the command the buffer contains what you typed before. If you have to run another command before finishing this you can type EscQ again.
(I didn't try to open a subshell after pressing EscQ yet.)
See http://zsh.sourceforge.net/Intro/intro_10.html and search for "esc-q"
This exactly what I wanted, thanks a lot! I could make it run a nested shell instead of returning straight away but for my use case returning straight away works perfectly.
– Panayiotis
5 hours ago
add a comment |
I typically use Ctrl+U which erases the current line and saves it into a buffer. From there I do what ever it was I needed to before the mylongcommand. Then when I am ready I use Ctrl+Y to paste mylongcommand back in my prompt.
Remember a half-typed command while I check something
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%2f506070%2frunning-a-subshell-from-the-middle-of-the-current-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
There is the key combination EscQ which saves the command buffer and allows to enter a new command. After running the command the buffer contains what you typed before. If you have to run another command before finishing this you can type EscQ again.
(I didn't try to open a subshell after pressing EscQ yet.)
See http://zsh.sourceforge.net/Intro/intro_10.html and search for "esc-q"
This exactly what I wanted, thanks a lot! I could make it run a nested shell instead of returning straight away but for my use case returning straight away works perfectly.
– Panayiotis
5 hours ago
add a comment |
There is the key combination EscQ which saves the command buffer and allows to enter a new command. After running the command the buffer contains what you typed before. If you have to run another command before finishing this you can type EscQ again.
(I didn't try to open a subshell after pressing EscQ yet.)
See http://zsh.sourceforge.net/Intro/intro_10.html and search for "esc-q"
This exactly what I wanted, thanks a lot! I could make it run a nested shell instead of returning straight away but for my use case returning straight away works perfectly.
– Panayiotis
5 hours ago
add a comment |
There is the key combination EscQ which saves the command buffer and allows to enter a new command. After running the command the buffer contains what you typed before. If you have to run another command before finishing this you can type EscQ again.
(I didn't try to open a subshell after pressing EscQ yet.)
See http://zsh.sourceforge.net/Intro/intro_10.html and search for "esc-q"
There is the key combination EscQ which saves the command buffer and allows to enter a new command. After running the command the buffer contains what you typed before. If you have to run another command before finishing this you can type EscQ again.
(I didn't try to open a subshell after pressing EscQ yet.)
See http://zsh.sourceforge.net/Intro/intro_10.html and search for "esc-q"
answered 5 hours ago
BodoBodo
2,181417
2,181417
This exactly what I wanted, thanks a lot! I could make it run a nested shell instead of returning straight away but for my use case returning straight away works perfectly.
– Panayiotis
5 hours ago
add a comment |
This exactly what I wanted, thanks a lot! I could make it run a nested shell instead of returning straight away but for my use case returning straight away works perfectly.
– Panayiotis
5 hours ago
This exactly what I wanted, thanks a lot! I could make it run a nested shell instead of returning straight away but for my use case returning straight away works perfectly.
– Panayiotis
5 hours ago
This exactly what I wanted, thanks a lot! I could make it run a nested shell instead of returning straight away but for my use case returning straight away works perfectly.
– Panayiotis
5 hours ago
add a comment |
I typically use Ctrl+U which erases the current line and saves it into a buffer. From there I do what ever it was I needed to before the mylongcommand. Then when I am ready I use Ctrl+Y to paste mylongcommand back in my prompt.
Remember a half-typed command while I check something
add a comment |
I typically use Ctrl+U which erases the current line and saves it into a buffer. From there I do what ever it was I needed to before the mylongcommand. Then when I am ready I use Ctrl+Y to paste mylongcommand back in my prompt.
Remember a half-typed command while I check something
add a comment |
I typically use Ctrl+U which erases the current line and saves it into a buffer. From there I do what ever it was I needed to before the mylongcommand. Then when I am ready I use Ctrl+Y to paste mylongcommand back in my prompt.
Remember a half-typed command while I check something
I typically use Ctrl+U which erases the current line and saves it into a buffer. From there I do what ever it was I needed to before the mylongcommand. Then when I am ready I use Ctrl+Y to paste mylongcommand back in my prompt.
Remember a half-typed command while I check something
answered 5 hours ago
Zachary BradyZachary Brady
3,4861033
3,4861033
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%2f506070%2frunning-a-subshell-from-the-middle-of-the-current-command%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
Why not just open another terminal window?
– Barmar
1 hour ago