How to avoid and recover shell command history from an unwanted incursion of non-printable characters?Keep...
What's the relationship betweeen MS-DOS and XENIX?
Scam? Phone call from "Department of Social Security" asking me to call back
Output the list of musical notes
Are there any cons in using rounded corners for bar graphs?
6502: is BCD *fundamentally* the same performance as non-BCD?
Why should I pay for an SSL certificate?
Is nullptr falsy?
What exactly happened to the 18 crew members who were reported as "missing" in "Q Who"?
If a person claims to know anything could it be disproven by saying 'prove that we are not in a simulation'?
Build a mob of suspiciously happy lenny faces ( ͡° ͜ʖ ͡°)
Will Force.com stop working on salesforce Lightning?
How do ultra-stable oscillators for spacecraft work?
Is there a way, other than having a Diviner friend, for a player to avoid rolling Initiative at the start of a combat?
How can I enter recovery mode (for Mac OS, on an iMac) remotely?
How to train a replacement without them knowing?
Can I use my OWN published papers' images in my thesis without Copyright infringment
Knights and Knaves on a (Not So) Deserted Island
Can a countable set contain uncountably many infinite subsets such that the symmetric difference of any two such distinct subsets is finite?
Does the Haste spell's hasted action allow you to make multiple unarmed strikes? Or none at all?
A Magic Diamond
What should I do if actually I found a serious flaw in someone's PhD thesis and an article derived from that PhD thesis?
Can anyone help me what's wrong here as i can prove 0 = 1?
Unconventional examples of mathematical modelling
Is there any official ruling on how characters go from 0th to 1st level in a class?
How to avoid and recover shell command history from an unwanted incursion of non-printable characters?
Keep only successful commands in BASH historyBash $PROMPT_COMMAND messing up scroll history displayHow to avoid bash from accepting non-printable characters at the prompt?Command-line completion from command historyShell - Deal with multiple command history fileshow to enable command history of shellRe-execute fc command from historyRemoving non printable characters from expect logs?Recover deleted commands from history?How to exclude command from history list, but to keep it in “live” history?Bash prompt - backspace deletes right aligned text (possible to stop?)Delete history from 100 to 150 entries in bash shell
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
$ history
...
242 yum whatprovides */bin/xdotool
243 yum provides */bin/xdotool
244 yum provides xdotool
245 yum whatprovides xdotool
246 yum whatprovides xdotool
At the prompt:
up
[root@localhost Downloads]# yum whatprovides xdotool
up
[root@localhost Downloads]# yum whatprovidesxdotool
up
[root@localhost Downloads]# yumtprovidesxdotool
up
[root@localhost Downloads]# yumtprovides*/bin/xdotool
up
[root@localhost Downloads]# yumwhattprovides*/bin/xdotool
Note that in the first recalled command there is a non-printable character which I am representing with ☐
(unicode box character) which is invisible in my terminal and does not take up a character space. In my terminal I see this:
yum whatprovides xdotool
NOT this:
yum whatprovides ☐xdotool
Using cat -A
:
$ history | cat -A
...
246 yum whatprovides M-BM-^Vxdotool $
I am running Cygwin mintty
on Windows 10 with a shell connection to Fedora 29.
I am using system defaults.
$ echo $PS1
[u@h W]$
I think this is related to:
https://unix.stackexchange.com/a/31643/81989
When it's in PS1, bash counts the number of characters that get
printed so that it can correctly redraw when you scroll through your
history. That's why bash has the [ and ] special characters—they
tell bash that the enclosed characters are not printable, which helps
bash figure out how to redraw the prompt when necessary.
I believe that this non-printable character in my history that is what's causing it to bug out.
I am interested in understanding HOW and WHY this happened but I also want to know:
- What options are available or recovery without purging my history
- Can Bash be configured to discard these characters from the command history to avoid this from happening in the future?
- Is there a way to identify what the offending character is?
As an aside, what are the use cases where preserving these non-printable characters in the command history is advantageous? Whenever I encounter this problem it's always a nuisance.
bash command-history special-characters
add a comment |
$ history
...
242 yum whatprovides */bin/xdotool
243 yum provides */bin/xdotool
244 yum provides xdotool
245 yum whatprovides xdotool
246 yum whatprovides xdotool
At the prompt:
up
[root@localhost Downloads]# yum whatprovides xdotool
up
[root@localhost Downloads]# yum whatprovidesxdotool
up
[root@localhost Downloads]# yumtprovidesxdotool
up
[root@localhost Downloads]# yumtprovides*/bin/xdotool
up
[root@localhost Downloads]# yumwhattprovides*/bin/xdotool
Note that in the first recalled command there is a non-printable character which I am representing with ☐
(unicode box character) which is invisible in my terminal and does not take up a character space. In my terminal I see this:
yum whatprovides xdotool
NOT this:
yum whatprovides ☐xdotool
Using cat -A
:
$ history | cat -A
...
246 yum whatprovides M-BM-^Vxdotool $
I am running Cygwin mintty
on Windows 10 with a shell connection to Fedora 29.
I am using system defaults.
$ echo $PS1
[u@h W]$
I think this is related to:
https://unix.stackexchange.com/a/31643/81989
When it's in PS1, bash counts the number of characters that get
printed so that it can correctly redraw when you scroll through your
history. That's why bash has the [ and ] special characters—they
tell bash that the enclosed characters are not printable, which helps
bash figure out how to redraw the prompt when necessary.
I believe that this non-printable character in my history that is what's causing it to bug out.
I am interested in understanding HOW and WHY this happened but I also want to know:
- What options are available or recovery without purging my history
- Can Bash be configured to discard these characters from the command history to avoid this from happening in the future?
- Is there a way to identify what the offending character is?
As an aside, what are the use cases where preserving these non-printable characters in the command history is advantageous? Whenever I encounter this problem it's always a nuisance.
bash command-history special-characters
possibly this would be of interest? unix.stackexchange.com/questions/41739/…
– Bart
yesterday
This seems very similar to your other question ...?
– Jeff Schaller♦
yesterday
@JeffSchaller This question is specifically about Bash's command history and how to recover from this state. The other question is on how to avoid non-printable characters from being entered at the prompt to avoid reaching this state. I felt that they were unique enough to be split into separate questions.
– Zhro
yesterday
add a comment |
$ history
...
242 yum whatprovides */bin/xdotool
243 yum provides */bin/xdotool
244 yum provides xdotool
245 yum whatprovides xdotool
246 yum whatprovides xdotool
At the prompt:
up
[root@localhost Downloads]# yum whatprovides xdotool
up
[root@localhost Downloads]# yum whatprovidesxdotool
up
[root@localhost Downloads]# yumtprovidesxdotool
up
[root@localhost Downloads]# yumtprovides*/bin/xdotool
up
[root@localhost Downloads]# yumwhattprovides*/bin/xdotool
Note that in the first recalled command there is a non-printable character which I am representing with ☐
(unicode box character) which is invisible in my terminal and does not take up a character space. In my terminal I see this:
yum whatprovides xdotool
NOT this:
yum whatprovides ☐xdotool
Using cat -A
:
$ history | cat -A
...
246 yum whatprovides M-BM-^Vxdotool $
I am running Cygwin mintty
on Windows 10 with a shell connection to Fedora 29.
I am using system defaults.
$ echo $PS1
[u@h W]$
I think this is related to:
https://unix.stackexchange.com/a/31643/81989
When it's in PS1, bash counts the number of characters that get
printed so that it can correctly redraw when you scroll through your
history. That's why bash has the [ and ] special characters—they
tell bash that the enclosed characters are not printable, which helps
bash figure out how to redraw the prompt when necessary.
I believe that this non-printable character in my history that is what's causing it to bug out.
I am interested in understanding HOW and WHY this happened but I also want to know:
- What options are available or recovery without purging my history
- Can Bash be configured to discard these characters from the command history to avoid this from happening in the future?
- Is there a way to identify what the offending character is?
As an aside, what are the use cases where preserving these non-printable characters in the command history is advantageous? Whenever I encounter this problem it's always a nuisance.
bash command-history special-characters
$ history
...
242 yum whatprovides */bin/xdotool
243 yum provides */bin/xdotool
244 yum provides xdotool
245 yum whatprovides xdotool
246 yum whatprovides xdotool
At the prompt:
up
[root@localhost Downloads]# yum whatprovides xdotool
up
[root@localhost Downloads]# yum whatprovidesxdotool
up
[root@localhost Downloads]# yumtprovidesxdotool
up
[root@localhost Downloads]# yumtprovides*/bin/xdotool
up
[root@localhost Downloads]# yumwhattprovides*/bin/xdotool
Note that in the first recalled command there is a non-printable character which I am representing with ☐
(unicode box character) which is invisible in my terminal and does not take up a character space. In my terminal I see this:
yum whatprovides xdotool
NOT this:
yum whatprovides ☐xdotool
Using cat -A
:
$ history | cat -A
...
246 yum whatprovides M-BM-^Vxdotool $
I am running Cygwin mintty
on Windows 10 with a shell connection to Fedora 29.
I am using system defaults.
$ echo $PS1
[u@h W]$
I think this is related to:
https://unix.stackexchange.com/a/31643/81989
When it's in PS1, bash counts the number of characters that get
printed so that it can correctly redraw when you scroll through your
history. That's why bash has the [ and ] special characters—they
tell bash that the enclosed characters are not printable, which helps
bash figure out how to redraw the prompt when necessary.
I believe that this non-printable character in my history that is what's causing it to bug out.
I am interested in understanding HOW and WHY this happened but I also want to know:
- What options are available or recovery without purging my history
- Can Bash be configured to discard these characters from the command history to avoid this from happening in the future?
- Is there a way to identify what the offending character is?
As an aside, what are the use cases where preserving these non-printable characters in the command history is advantageous? Whenever I encounter this problem it's always a nuisance.
bash command-history special-characters
bash command-history special-characters
edited yesterday
Zhro
asked yesterday
ZhroZhro
4005 silver badges16 bronze badges
4005 silver badges16 bronze badges
possibly this would be of interest? unix.stackexchange.com/questions/41739/…
– Bart
yesterday
This seems very similar to your other question ...?
– Jeff Schaller♦
yesterday
@JeffSchaller This question is specifically about Bash's command history and how to recover from this state. The other question is on how to avoid non-printable characters from being entered at the prompt to avoid reaching this state. I felt that they were unique enough to be split into separate questions.
– Zhro
yesterday
add a comment |
possibly this would be of interest? unix.stackexchange.com/questions/41739/…
– Bart
yesterday
This seems very similar to your other question ...?
– Jeff Schaller♦
yesterday
@JeffSchaller This question is specifically about Bash's command history and how to recover from this state. The other question is on how to avoid non-printable characters from being entered at the prompt to avoid reaching this state. I felt that they were unique enough to be split into separate questions.
– Zhro
yesterday
possibly this would be of interest? unix.stackexchange.com/questions/41739/…
– Bart
yesterday
possibly this would be of interest? unix.stackexchange.com/questions/41739/…
– Bart
yesterday
This seems very similar to your other question ...?
– Jeff Schaller♦
yesterday
This seems very similar to your other question ...?
– Jeff Schaller♦
yesterday
@JeffSchaller This question is specifically about Bash's command history and how to recover from this state. The other question is on how to avoid non-printable characters from being entered at the prompt to avoid reaching this state. I felt that they were unique enough to be split into separate questions.
– Zhro
yesterday
@JeffSchaller This question is specifically about Bash's command history and how to recover from this state. The other question is on how to avoid non-printable characters from being entered at the prompt to avoid reaching this state. I felt that they were unique enough to be split into separate questions.
– Zhro
yesterday
add a comment |
0
active
oldest
votes
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%2f535720%2fhow-to-avoid-and-recover-shell-command-history-from-an-unwanted-incursion-of-non%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f535720%2fhow-to-avoid-and-recover-shell-command-history-from-an-unwanted-incursion-of-non%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
possibly this would be of interest? unix.stackexchange.com/questions/41739/…
– Bart
yesterday
This seems very similar to your other question ...?
– Jeff Schaller♦
yesterday
@JeffSchaller This question is specifically about Bash's command history and how to recover from this state. The other question is on how to avoid non-printable characters from being entered at the prompt to avoid reaching this state. I felt that they were unique enough to be split into separate questions.
– Zhro
yesterday