How to make Zsh not store failed command
Problem
I'm using oh-my-zsh and Antigen to manage my Zsh.
Sometimes I will accidentally enter a wrong/failed command into Zsh and it is very annoying when the zsh-autosuggestions plugin throws up these commands.
For e.g., say I typed
gut status
rather than git status
.
Now, as I attempt to type the correct command again, once I typed g
, the autosuggestion plugin will throw up gut status
as that is the closest match in recent history. But that is a failed command!
What I want to do is to keep these failed commands from "polluting" my history so the autosuggestion plugin will not suggest them.
What I have done
I've searched for this and the closest match to keeping out entries from the history are that of setting HIST_IGNORE_SPACE, or methods to ignore specific commands, or to delete commands manually after entering them. See this and this. But as @Adaephon 52 noted, this takes place after the deed is done.
What I'm considering doing
What I have in mind right now is to write a function that gets triggered every time a failed command is entered into Zsh to delete the latest entry from history. However, I'm not familiar enough with Zsh to know whether this sort of trigger exists or how to go about doing it.
Note on the accepted solution
For those who are interested in this problem, the accepted solution works in the sense that failed commands are not stored in the history file. fc -l
or history
confirms this.
However, it seems that the zsh-autosuggestions plugin is doing its own local caching of sorts (or is generating suggestions using other mechanism), so it will still suggest the failed commands, but only if the session is not over. When the user starts a new instance of the shell, when presumably the plugin has to load the cached history, it no longer suggests the failed commands (unless you enter them again, of course).
The proposed solution is technically correct as I (mistakenly) framed my question in such a way that it only requires an answer that stops Zsh from storing the failed commands and the accepted solution does that (albeit in a limited way; See link in solution for details).
Anyone who is familiar with shell scripting (I'm not) and motivated enough can check the zsh-autosuggestions script.
linux command-line shell zsh oh-my-zsh
add a comment |
Problem
I'm using oh-my-zsh and Antigen to manage my Zsh.
Sometimes I will accidentally enter a wrong/failed command into Zsh and it is very annoying when the zsh-autosuggestions plugin throws up these commands.
For e.g., say I typed
gut status
rather than git status
.
Now, as I attempt to type the correct command again, once I typed g
, the autosuggestion plugin will throw up gut status
as that is the closest match in recent history. But that is a failed command!
What I want to do is to keep these failed commands from "polluting" my history so the autosuggestion plugin will not suggest them.
What I have done
I've searched for this and the closest match to keeping out entries from the history are that of setting HIST_IGNORE_SPACE, or methods to ignore specific commands, or to delete commands manually after entering them. See this and this. But as @Adaephon 52 noted, this takes place after the deed is done.
What I'm considering doing
What I have in mind right now is to write a function that gets triggered every time a failed command is entered into Zsh to delete the latest entry from history. However, I'm not familiar enough with Zsh to know whether this sort of trigger exists or how to go about doing it.
Note on the accepted solution
For those who are interested in this problem, the accepted solution works in the sense that failed commands are not stored in the history file. fc -l
or history
confirms this.
However, it seems that the zsh-autosuggestions plugin is doing its own local caching of sorts (or is generating suggestions using other mechanism), so it will still suggest the failed commands, but only if the session is not over. When the user starts a new instance of the shell, when presumably the plugin has to load the cached history, it no longer suggests the failed commands (unless you enter them again, of course).
The proposed solution is technically correct as I (mistakenly) framed my question in such a way that it only requires an answer that stops Zsh from storing the failed commands and the accepted solution does that (albeit in a limited way; See link in solution for details).
Anyone who is familiar with shell scripting (I'm not) and motivated enough can check the zsh-autosuggestions script.
linux command-line shell zsh oh-my-zsh
add a comment |
Problem
I'm using oh-my-zsh and Antigen to manage my Zsh.
Sometimes I will accidentally enter a wrong/failed command into Zsh and it is very annoying when the zsh-autosuggestions plugin throws up these commands.
For e.g., say I typed
gut status
rather than git status
.
Now, as I attempt to type the correct command again, once I typed g
, the autosuggestion plugin will throw up gut status
as that is the closest match in recent history. But that is a failed command!
What I want to do is to keep these failed commands from "polluting" my history so the autosuggestion plugin will not suggest them.
What I have done
I've searched for this and the closest match to keeping out entries from the history are that of setting HIST_IGNORE_SPACE, or methods to ignore specific commands, or to delete commands manually after entering them. See this and this. But as @Adaephon 52 noted, this takes place after the deed is done.
What I'm considering doing
What I have in mind right now is to write a function that gets triggered every time a failed command is entered into Zsh to delete the latest entry from history. However, I'm not familiar enough with Zsh to know whether this sort of trigger exists or how to go about doing it.
Note on the accepted solution
For those who are interested in this problem, the accepted solution works in the sense that failed commands are not stored in the history file. fc -l
or history
confirms this.
However, it seems that the zsh-autosuggestions plugin is doing its own local caching of sorts (or is generating suggestions using other mechanism), so it will still suggest the failed commands, but only if the session is not over. When the user starts a new instance of the shell, when presumably the plugin has to load the cached history, it no longer suggests the failed commands (unless you enter them again, of course).
The proposed solution is technically correct as I (mistakenly) framed my question in such a way that it only requires an answer that stops Zsh from storing the failed commands and the accepted solution does that (albeit in a limited way; See link in solution for details).
Anyone who is familiar with shell scripting (I'm not) and motivated enough can check the zsh-autosuggestions script.
linux command-line shell zsh oh-my-zsh
Problem
I'm using oh-my-zsh and Antigen to manage my Zsh.
Sometimes I will accidentally enter a wrong/failed command into Zsh and it is very annoying when the zsh-autosuggestions plugin throws up these commands.
For e.g., say I typed
gut status
rather than git status
.
Now, as I attempt to type the correct command again, once I typed g
, the autosuggestion plugin will throw up gut status
as that is the closest match in recent history. But that is a failed command!
What I want to do is to keep these failed commands from "polluting" my history so the autosuggestion plugin will not suggest them.
What I have done
I've searched for this and the closest match to keeping out entries from the history are that of setting HIST_IGNORE_SPACE, or methods to ignore specific commands, or to delete commands manually after entering them. See this and this. But as @Adaephon 52 noted, this takes place after the deed is done.
What I'm considering doing
What I have in mind right now is to write a function that gets triggered every time a failed command is entered into Zsh to delete the latest entry from history. However, I'm not familiar enough with Zsh to know whether this sort of trigger exists or how to go about doing it.
Note on the accepted solution
For those who are interested in this problem, the accepted solution works in the sense that failed commands are not stored in the history file. fc -l
or history
confirms this.
However, it seems that the zsh-autosuggestions plugin is doing its own local caching of sorts (or is generating suggestions using other mechanism), so it will still suggest the failed commands, but only if the session is not over. When the user starts a new instance of the shell, when presumably the plugin has to load the cached history, it no longer suggests the failed commands (unless you enter them again, of course).
The proposed solution is technically correct as I (mistakenly) framed my question in such a way that it only requires an answer that stops Zsh from storing the failed commands and the accepted solution does that (albeit in a limited way; See link in solution for details).
Anyone who is familiar with shell scripting (I'm not) and motivated enough can check the zsh-autosuggestions script.
linux command-line shell zsh oh-my-zsh
linux command-line shell zsh oh-my-zsh
edited Apr 13 '17 at 12:37
Community♦
1
1
asked Apr 16 '15 at 8:05
lightalchemistlightalchemist
1386
1386
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Bart Schaefer proposed the following approach to the same question on the zsh users mailing list:
zshaddhistory() { whence ${${(z)1}[1]} >| /dev/null || return 1 }
This function is executed before the command line is written to history. If it does return 1, the current command line is neither appended to the history file nor to the local history stack. However, the check if the command will trigger a command not found error covers only simple cases. E.g. this line will be on the history:
echo foo; echooo bar
But it works fine for your example
gut status
Please be aware, that the wrong command will show up upon UP-ARROW
(so that you can correct it!), but is not in the history stack; check with fc -l
.
This does stops the caching of failed commands. But it seems that the zsh-autosuggestions plugin is doing its own local caching of recent entries so it still throws up these suggestions as long as the session is not over. Once I open a new shell, when presumably it has to load the cached history, it no longer suggests them. This solved part of the problem and I guess I have to check with the zsh-autosuggestions plugin's maintainer to resolve the remaining issue. Still, thanks!
– lightalchemist
Apr 17 '15 at 2:21
add a comment |
The built-in fc
command supports editing your history. In case you mistyped e.g. the previous command you can enter the following:
$ fc -e nano -1
You can replace nano
with the command of your preferred editor. Also you can set the EDITOR
variable (parameter) in your zsh config. (See referring SO page)
You need to save the file (the one, created in a system temp. folder, by fc). After it you will end up with the line(s) edited. Enter
will run it or you can press Ctrl+C
to finish your editing.
For further details see zsh documentation: Zsh: editing history
In case you want to edit the entire history
$ fc -W; nano "$HISTFILE"; fc -R
...again replace nano if you wish
It simply writes out the history -including the cache- then opens the file with an editor.
Please note that zsh knows three types of history:
Internal: commands you entered since log-in
Local: the one available within the active shell - [HISTFILE + Internal]
"Global": it depens but let say it's the file set in HISTFILE
Please bear in mind that in case your history file is shared (SHARE_HISTORY
) and you have more than one zsh shell opened with the user in question then you better run the fc -W
command in those shells first. Once you finished with the edit then run fc -R
. Otherwise the commands entered within those shells won't be stored and then recognized your manual edit of the HISTFILE
.
2
The question says that the OP has found ‘‘methods … to delete commands manually after entering them.’’, and asks for a way to do this automatically when a command fails with ‘‘command not found’’ or some other error.
– Scott
Jan 29 at 19:37
add a comment |
not sure how omz runs it but in both bash and regular zsh prefixing with a space keeps it out of .history and henceforth also out of auto complete/suggest
i.e.
<space>ll -ahZ /home/%USER
3
The OP wants to keep wrong/failed commands from the history. And as he only knows that the command was wrong after running it, adding a space before running it does not solve the problem.
– Adaephon
Apr 16 '15 at 14:02
@Adaephon Exactly. I know that it is possible to have ZSH ignore commands starting with spaces. Perhaps I should have mentioned this in my post.
– lightalchemist
Apr 16 '15 at 14:43
personally i don't keep any history (by doing this ) another solution --- get off the crappily maintained Oh-my-zsh for pure zsh or prestzo (more more well maintained and sane up to date configurations... this lack of functionality has been in the "issues" for some time
– linuxdev2013
Apr 16 '15 at 16:21
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fsuperuser.com%2fquestions%2f902241%2fhow-to-make-zsh-not-store-failed-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Bart Schaefer proposed the following approach to the same question on the zsh users mailing list:
zshaddhistory() { whence ${${(z)1}[1]} >| /dev/null || return 1 }
This function is executed before the command line is written to history. If it does return 1, the current command line is neither appended to the history file nor to the local history stack. However, the check if the command will trigger a command not found error covers only simple cases. E.g. this line will be on the history:
echo foo; echooo bar
But it works fine for your example
gut status
Please be aware, that the wrong command will show up upon UP-ARROW
(so that you can correct it!), but is not in the history stack; check with fc -l
.
This does stops the caching of failed commands. But it seems that the zsh-autosuggestions plugin is doing its own local caching of recent entries so it still throws up these suggestions as long as the session is not over. Once I open a new shell, when presumably it has to load the cached history, it no longer suggests them. This solved part of the problem and I guess I have to check with the zsh-autosuggestions plugin's maintainer to resolve the remaining issue. Still, thanks!
– lightalchemist
Apr 17 '15 at 2:21
add a comment |
Bart Schaefer proposed the following approach to the same question on the zsh users mailing list:
zshaddhistory() { whence ${${(z)1}[1]} >| /dev/null || return 1 }
This function is executed before the command line is written to history. If it does return 1, the current command line is neither appended to the history file nor to the local history stack. However, the check if the command will trigger a command not found error covers only simple cases. E.g. this line will be on the history:
echo foo; echooo bar
But it works fine for your example
gut status
Please be aware, that the wrong command will show up upon UP-ARROW
(so that you can correct it!), but is not in the history stack; check with fc -l
.
This does stops the caching of failed commands. But it seems that the zsh-autosuggestions plugin is doing its own local caching of recent entries so it still throws up these suggestions as long as the session is not over. Once I open a new shell, when presumably it has to load the cached history, it no longer suggests them. This solved part of the problem and I guess I have to check with the zsh-autosuggestions plugin's maintainer to resolve the remaining issue. Still, thanks!
– lightalchemist
Apr 17 '15 at 2:21
add a comment |
Bart Schaefer proposed the following approach to the same question on the zsh users mailing list:
zshaddhistory() { whence ${${(z)1}[1]} >| /dev/null || return 1 }
This function is executed before the command line is written to history. If it does return 1, the current command line is neither appended to the history file nor to the local history stack. However, the check if the command will trigger a command not found error covers only simple cases. E.g. this line will be on the history:
echo foo; echooo bar
But it works fine for your example
gut status
Please be aware, that the wrong command will show up upon UP-ARROW
(so that you can correct it!), but is not in the history stack; check with fc -l
.
Bart Schaefer proposed the following approach to the same question on the zsh users mailing list:
zshaddhistory() { whence ${${(z)1}[1]} >| /dev/null || return 1 }
This function is executed before the command line is written to history. If it does return 1, the current command line is neither appended to the history file nor to the local history stack. However, the check if the command will trigger a command not found error covers only simple cases. E.g. this line will be on the history:
echo foo; echooo bar
But it works fine for your example
gut status
Please be aware, that the wrong command will show up upon UP-ARROW
(so that you can correct it!), but is not in the history stack; check with fc -l
.
answered Apr 16 '15 at 19:55
mpympy
18.3k45472
18.3k45472
This does stops the caching of failed commands. But it seems that the zsh-autosuggestions plugin is doing its own local caching of recent entries so it still throws up these suggestions as long as the session is not over. Once I open a new shell, when presumably it has to load the cached history, it no longer suggests them. This solved part of the problem and I guess I have to check with the zsh-autosuggestions plugin's maintainer to resolve the remaining issue. Still, thanks!
– lightalchemist
Apr 17 '15 at 2:21
add a comment |
This does stops the caching of failed commands. But it seems that the zsh-autosuggestions plugin is doing its own local caching of recent entries so it still throws up these suggestions as long as the session is not over. Once I open a new shell, when presumably it has to load the cached history, it no longer suggests them. This solved part of the problem and I guess I have to check with the zsh-autosuggestions plugin's maintainer to resolve the remaining issue. Still, thanks!
– lightalchemist
Apr 17 '15 at 2:21
This does stops the caching of failed commands. But it seems that the zsh-autosuggestions plugin is doing its own local caching of recent entries so it still throws up these suggestions as long as the session is not over. Once I open a new shell, when presumably it has to load the cached history, it no longer suggests them. This solved part of the problem and I guess I have to check with the zsh-autosuggestions plugin's maintainer to resolve the remaining issue. Still, thanks!
– lightalchemist
Apr 17 '15 at 2:21
This does stops the caching of failed commands. But it seems that the zsh-autosuggestions plugin is doing its own local caching of recent entries so it still throws up these suggestions as long as the session is not over. Once I open a new shell, when presumably it has to load the cached history, it no longer suggests them. This solved part of the problem and I guess I have to check with the zsh-autosuggestions plugin's maintainer to resolve the remaining issue. Still, thanks!
– lightalchemist
Apr 17 '15 at 2:21
add a comment |
The built-in fc
command supports editing your history. In case you mistyped e.g. the previous command you can enter the following:
$ fc -e nano -1
You can replace nano
with the command of your preferred editor. Also you can set the EDITOR
variable (parameter) in your zsh config. (See referring SO page)
You need to save the file (the one, created in a system temp. folder, by fc). After it you will end up with the line(s) edited. Enter
will run it or you can press Ctrl+C
to finish your editing.
For further details see zsh documentation: Zsh: editing history
In case you want to edit the entire history
$ fc -W; nano "$HISTFILE"; fc -R
...again replace nano if you wish
It simply writes out the history -including the cache- then opens the file with an editor.
Please note that zsh knows three types of history:
Internal: commands you entered since log-in
Local: the one available within the active shell - [HISTFILE + Internal]
"Global": it depens but let say it's the file set in HISTFILE
Please bear in mind that in case your history file is shared (SHARE_HISTORY
) and you have more than one zsh shell opened with the user in question then you better run the fc -W
command in those shells first. Once you finished with the edit then run fc -R
. Otherwise the commands entered within those shells won't be stored and then recognized your manual edit of the HISTFILE
.
2
The question says that the OP has found ‘‘methods … to delete commands manually after entering them.’’, and asks for a way to do this automatically when a command fails with ‘‘command not found’’ or some other error.
– Scott
Jan 29 at 19:37
add a comment |
The built-in fc
command supports editing your history. In case you mistyped e.g. the previous command you can enter the following:
$ fc -e nano -1
You can replace nano
with the command of your preferred editor. Also you can set the EDITOR
variable (parameter) in your zsh config. (See referring SO page)
You need to save the file (the one, created in a system temp. folder, by fc). After it you will end up with the line(s) edited. Enter
will run it or you can press Ctrl+C
to finish your editing.
For further details see zsh documentation: Zsh: editing history
In case you want to edit the entire history
$ fc -W; nano "$HISTFILE"; fc -R
...again replace nano if you wish
It simply writes out the history -including the cache- then opens the file with an editor.
Please note that zsh knows three types of history:
Internal: commands you entered since log-in
Local: the one available within the active shell - [HISTFILE + Internal]
"Global": it depens but let say it's the file set in HISTFILE
Please bear in mind that in case your history file is shared (SHARE_HISTORY
) and you have more than one zsh shell opened with the user in question then you better run the fc -W
command in those shells first. Once you finished with the edit then run fc -R
. Otherwise the commands entered within those shells won't be stored and then recognized your manual edit of the HISTFILE
.
2
The question says that the OP has found ‘‘methods … to delete commands manually after entering them.’’, and asks for a way to do this automatically when a command fails with ‘‘command not found’’ or some other error.
– Scott
Jan 29 at 19:37
add a comment |
The built-in fc
command supports editing your history. In case you mistyped e.g. the previous command you can enter the following:
$ fc -e nano -1
You can replace nano
with the command of your preferred editor. Also you can set the EDITOR
variable (parameter) in your zsh config. (See referring SO page)
You need to save the file (the one, created in a system temp. folder, by fc). After it you will end up with the line(s) edited. Enter
will run it or you can press Ctrl+C
to finish your editing.
For further details see zsh documentation: Zsh: editing history
In case you want to edit the entire history
$ fc -W; nano "$HISTFILE"; fc -R
...again replace nano if you wish
It simply writes out the history -including the cache- then opens the file with an editor.
Please note that zsh knows three types of history:
Internal: commands you entered since log-in
Local: the one available within the active shell - [HISTFILE + Internal]
"Global": it depens but let say it's the file set in HISTFILE
Please bear in mind that in case your history file is shared (SHARE_HISTORY
) and you have more than one zsh shell opened with the user in question then you better run the fc -W
command in those shells first. Once you finished with the edit then run fc -R
. Otherwise the commands entered within those shells won't be stored and then recognized your manual edit of the HISTFILE
.
The built-in fc
command supports editing your history. In case you mistyped e.g. the previous command you can enter the following:
$ fc -e nano -1
You can replace nano
with the command of your preferred editor. Also you can set the EDITOR
variable (parameter) in your zsh config. (See referring SO page)
You need to save the file (the one, created in a system temp. folder, by fc). After it you will end up with the line(s) edited. Enter
will run it or you can press Ctrl+C
to finish your editing.
For further details see zsh documentation: Zsh: editing history
In case you want to edit the entire history
$ fc -W; nano "$HISTFILE"; fc -R
...again replace nano if you wish
It simply writes out the history -including the cache- then opens the file with an editor.
Please note that zsh knows three types of history:
Internal: commands you entered since log-in
Local: the one available within the active shell - [HISTFILE + Internal]
"Global": it depens but let say it's the file set in HISTFILE
Please bear in mind that in case your history file is shared (SHARE_HISTORY
) and you have more than one zsh shell opened with the user in question then you better run the fc -W
command in those shells first. Once you finished with the edit then run fc -R
. Otherwise the commands entered within those shells won't be stored and then recognized your manual edit of the HISTFILE
.
answered Jan 29 at 18:41
Geck0Geck0
1
1
2
The question says that the OP has found ‘‘methods … to delete commands manually after entering them.’’, and asks for a way to do this automatically when a command fails with ‘‘command not found’’ or some other error.
– Scott
Jan 29 at 19:37
add a comment |
2
The question says that the OP has found ‘‘methods … to delete commands manually after entering them.’’, and asks for a way to do this automatically when a command fails with ‘‘command not found’’ or some other error.
– Scott
Jan 29 at 19:37
2
2
The question says that the OP has found ‘‘methods … to delete commands manually after entering them.’’, and asks for a way to do this automatically when a command fails with ‘‘command not found’’ or some other error.
– Scott
Jan 29 at 19:37
The question says that the OP has found ‘‘methods … to delete commands manually after entering them.’’, and asks for a way to do this automatically when a command fails with ‘‘command not found’’ or some other error.
– Scott
Jan 29 at 19:37
add a comment |
not sure how omz runs it but in both bash and regular zsh prefixing with a space keeps it out of .history and henceforth also out of auto complete/suggest
i.e.
<space>ll -ahZ /home/%USER
3
The OP wants to keep wrong/failed commands from the history. And as he only knows that the command was wrong after running it, adding a space before running it does not solve the problem.
– Adaephon
Apr 16 '15 at 14:02
@Adaephon Exactly. I know that it is possible to have ZSH ignore commands starting with spaces. Perhaps I should have mentioned this in my post.
– lightalchemist
Apr 16 '15 at 14:43
personally i don't keep any history (by doing this ) another solution --- get off the crappily maintained Oh-my-zsh for pure zsh or prestzo (more more well maintained and sane up to date configurations... this lack of functionality has been in the "issues" for some time
– linuxdev2013
Apr 16 '15 at 16:21
add a comment |
not sure how omz runs it but in both bash and regular zsh prefixing with a space keeps it out of .history and henceforth also out of auto complete/suggest
i.e.
<space>ll -ahZ /home/%USER
3
The OP wants to keep wrong/failed commands from the history. And as he only knows that the command was wrong after running it, adding a space before running it does not solve the problem.
– Adaephon
Apr 16 '15 at 14:02
@Adaephon Exactly. I know that it is possible to have ZSH ignore commands starting with spaces. Perhaps I should have mentioned this in my post.
– lightalchemist
Apr 16 '15 at 14:43
personally i don't keep any history (by doing this ) another solution --- get off the crappily maintained Oh-my-zsh for pure zsh or prestzo (more more well maintained and sane up to date configurations... this lack of functionality has been in the "issues" for some time
– linuxdev2013
Apr 16 '15 at 16:21
add a comment |
not sure how omz runs it but in both bash and regular zsh prefixing with a space keeps it out of .history and henceforth also out of auto complete/suggest
i.e.
<space>ll -ahZ /home/%USER
not sure how omz runs it but in both bash and regular zsh prefixing with a space keeps it out of .history and henceforth also out of auto complete/suggest
i.e.
<space>ll -ahZ /home/%USER
answered Apr 16 '15 at 11:25
linuxdev2013linuxdev2013
976819
976819
3
The OP wants to keep wrong/failed commands from the history. And as he only knows that the command was wrong after running it, adding a space before running it does not solve the problem.
– Adaephon
Apr 16 '15 at 14:02
@Adaephon Exactly. I know that it is possible to have ZSH ignore commands starting with spaces. Perhaps I should have mentioned this in my post.
– lightalchemist
Apr 16 '15 at 14:43
personally i don't keep any history (by doing this ) another solution --- get off the crappily maintained Oh-my-zsh for pure zsh or prestzo (more more well maintained and sane up to date configurations... this lack of functionality has been in the "issues" for some time
– linuxdev2013
Apr 16 '15 at 16:21
add a comment |
3
The OP wants to keep wrong/failed commands from the history. And as he only knows that the command was wrong after running it, adding a space before running it does not solve the problem.
– Adaephon
Apr 16 '15 at 14:02
@Adaephon Exactly. I know that it is possible to have ZSH ignore commands starting with spaces. Perhaps I should have mentioned this in my post.
– lightalchemist
Apr 16 '15 at 14:43
personally i don't keep any history (by doing this ) another solution --- get off the crappily maintained Oh-my-zsh for pure zsh or prestzo (more more well maintained and sane up to date configurations... this lack of functionality has been in the "issues" for some time
– linuxdev2013
Apr 16 '15 at 16:21
3
3
The OP wants to keep wrong/failed commands from the history. And as he only knows that the command was wrong after running it, adding a space before running it does not solve the problem.
– Adaephon
Apr 16 '15 at 14:02
The OP wants to keep wrong/failed commands from the history. And as he only knows that the command was wrong after running it, adding a space before running it does not solve the problem.
– Adaephon
Apr 16 '15 at 14:02
@Adaephon Exactly. I know that it is possible to have ZSH ignore commands starting with spaces. Perhaps I should have mentioned this in my post.
– lightalchemist
Apr 16 '15 at 14:43
@Adaephon Exactly. I know that it is possible to have ZSH ignore commands starting with spaces. Perhaps I should have mentioned this in my post.
– lightalchemist
Apr 16 '15 at 14:43
personally i don't keep any history (by doing this ) another solution --- get off the crappily maintained Oh-my-zsh for pure zsh or prestzo (more more well maintained and sane up to date configurations... this lack of functionality has been in the "issues" for some time
– linuxdev2013
Apr 16 '15 at 16:21
personally i don't keep any history (by doing this ) another solution --- get off the crappily maintained Oh-my-zsh for pure zsh or prestzo (more more well maintained and sane up to date configurations... this lack of functionality has been in the "issues" for some time
– linuxdev2013
Apr 16 '15 at 16:21
add a comment |
Thanks for contributing an answer to Super User!
- 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%2fsuperuser.com%2fquestions%2f902241%2fhow-to-make-zsh-not-store-failed-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