Can I configure bash/readline to automatically convert NBSP to normal space?cannot insert backslash with bash, python, works fine with csh, idleHow can I fix my keyboard layout?Layout change with Alt+Shift in Ubuntu 14.04 using Gnome 3.10How to gracefully change keyboard layout from command line (setxkbmap breaks all shortcuts)Annoying switching from a keyboard layout to anotherHow to make the double quote behave as a dead key except when it is used in combination with itselfWhere are the files for the language indicator in Ubuntu 16.04.6 LTS stored?How to implement a custom dead-key based keyboard layout?sed “$” not acting as end of line character
Is the EU Settlement Scheme legal?
What happened to SEV?
Problem with a commutative diagram
How to get previous command without arrow key
Is Heraclitus really a Mobilist?
Is encrypted e-mail sent over TLS 1.3 a form of "forward secrecy" (similar to something like Signal)?
Why would shrinking TEMPDB log lead to slowness?
Adding more space to a plot
Length-terminated sequences
How to exaggerate the elevation in QGIS 3.6?
Python: write 2**n - 1 as a recursive function
Flatten an array
What's the origin of the trope that dragons used to be common but aren't any more?
Showing a homeless person that you care about their well-being
Why does Ubuntu resolve the name `_gateway` to the default gateway instead of `gateway`?
What (if any) replacement parts have been 3D printed on the ISS and then installed?
What papers are suitable for markers?
What is Noita downloading every time I quit the game?
How to delete music as it's being played
Articles at the beginning of sentences in scientific writing
What is the purpose of polls published by the organization that they are asking about which have leading/confusing questions?
Endless disc brake issues
What adaptations would be advantageous given a regular, but extreme variation in climate?
What would you do? Different results than what is reported
Can I configure bash/readline to automatically convert NBSP to normal space?
cannot insert backslash with bash, python, works fine with csh, idleHow can I fix my keyboard layout?Layout change with Alt+Shift in Ubuntu 14.04 using Gnome 3.10How to gracefully change keyboard layout from command line (setxkbmap breaks all shortcuts)Annoying switching from a keyboard layout to anotherHow to make the double quote behave as a dead key except when it is used in combination with itselfWhere are the files for the language indicator in Ubuntu 16.04.6 LTS stored?How to implement a custom dead-key based keyboard layout?sed “$” not acting as end of line character
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I'm using Finnish keyboard layout which maps AltGr+Space to non-breaking space (NBSP, U+00A0). I'm happy with this in general but I find that I often accidentally write NBSP instead of normal space after pipe "|
" symbol (written with AltGr+< with Finnish keyboard layout) while using bash command line. I guess this is caused by the fact that I need to hold AltGr while typing the pipe and release it before hitting space. And when I have bad timing for the release of AltGr I end up with invisible typo on the command line and error messages such as
grep: command not found
which looks pretty similar to
grep: command not found
which makes this issue a bit hard to notice on the first time.
I know that I can disable NBSP but I would prefer disabling it (having AltGr+Space to produce regular space) only after pipe character, or if that's not possible, always on the bash command line or readline
level. Is there any simple way to do this without modifying source code of bash, readline
or my terminal emulator (gnome-terminal
)?
Another good solution would be to configure NBSP to be somehow visible on the command line, e.g. replaced with another character (say U+2423 ␣
) for rendering only.
command-line bash keyboard-layout unicode-entry readline
|
show 7 more comments
I'm using Finnish keyboard layout which maps AltGr+Space to non-breaking space (NBSP, U+00A0). I'm happy with this in general but I find that I often accidentally write NBSP instead of normal space after pipe "|
" symbol (written with AltGr+< with Finnish keyboard layout) while using bash command line. I guess this is caused by the fact that I need to hold AltGr while typing the pipe and release it before hitting space. And when I have bad timing for the release of AltGr I end up with invisible typo on the command line and error messages such as
grep: command not found
which looks pretty similar to
grep: command not found
which makes this issue a bit hard to notice on the first time.
I know that I can disable NBSP but I would prefer disabling it (having AltGr+Space to produce regular space) only after pipe character, or if that's not possible, always on the bash command line or readline
level. Is there any simple way to do this without modifying source code of bash, readline
or my terminal emulator (gnome-terminal
)?
Another good solution would be to configure NBSP to be somehow visible on the command line, e.g. replaced with another character (say U+2423 ␣
) for rendering only.
command-line bash keyboard-layout unicode-entry readline
@dessert no need for a bounty, really. I just hit the problem and wrote a question about it. Later I found close enough config via Google Search to figure out the answer below. I'm still looking for an answer to make NBSP visible instead of disabling the character for all cases. I think I would like to have visible NBSP on readline level so that all terminal output is not messed up if I have NBSP in data strings.
– Mikko Rantalainen
Jun 2 at 10:41
@MikkoRantalainen could you explain what you're still missing more clearly? Since you found the way to map characters, why isn't" ":␣
enough? What else do you need?
– terdon♦
Jun 2 at 13:43
@dessert I would love to have a feature where I could write NBSP on the command line and getecho a␣b
but the resulting output line wereecho a b
with real NBSP in the output. As such, I think it must be done on the readline level (that is, command line editor always displays visible character but terminal emulator cannot know the difference between editor display and output display and therefore the terminal emulator cannot do the visual replacement for the rendering).
– Mikko Rantalainen
Jun 3 at 9:12
1
Solving it on readline level is indeed nice, but you might hit the same problem while writing a shell script in vim/emacs/etc in the terminal. See bugzilla.gnome.org/show_bug.cgi?id=788673 for a working proof of concept patch for gnome-terminal to highlight string matches, including perhaps the single NBSP character. (Yeah I know you said you didn't want to modify any source code…)
– egmont
Jun 16 at 22:11
1
Another approach is to address it on the font level, via a special font where NBSP's glyph is not empty, along with some fontconfig configuration. This would also work for graphical editors, not just the terminal. Yet another approach is to modify the keyboard layout to emit regular space, and use some other method to enter NBSP in the rare case when that's what you need.
– egmont
Jun 16 at 22:14
|
show 7 more comments
I'm using Finnish keyboard layout which maps AltGr+Space to non-breaking space (NBSP, U+00A0). I'm happy with this in general but I find that I often accidentally write NBSP instead of normal space after pipe "|
" symbol (written with AltGr+< with Finnish keyboard layout) while using bash command line. I guess this is caused by the fact that I need to hold AltGr while typing the pipe and release it before hitting space. And when I have bad timing for the release of AltGr I end up with invisible typo on the command line and error messages such as
grep: command not found
which looks pretty similar to
grep: command not found
which makes this issue a bit hard to notice on the first time.
I know that I can disable NBSP but I would prefer disabling it (having AltGr+Space to produce regular space) only after pipe character, or if that's not possible, always on the bash command line or readline
level. Is there any simple way to do this without modifying source code of bash, readline
or my terminal emulator (gnome-terminal
)?
Another good solution would be to configure NBSP to be somehow visible on the command line, e.g. replaced with another character (say U+2423 ␣
) for rendering only.
command-line bash keyboard-layout unicode-entry readline
I'm using Finnish keyboard layout which maps AltGr+Space to non-breaking space (NBSP, U+00A0). I'm happy with this in general but I find that I often accidentally write NBSP instead of normal space after pipe "|
" symbol (written with AltGr+< with Finnish keyboard layout) while using bash command line. I guess this is caused by the fact that I need to hold AltGr while typing the pipe and release it before hitting space. And when I have bad timing for the release of AltGr I end up with invisible typo on the command line and error messages such as
grep: command not found
which looks pretty similar to
grep: command not found
which makes this issue a bit hard to notice on the first time.
I know that I can disable NBSP but I would prefer disabling it (having AltGr+Space to produce regular space) only after pipe character, or if that's not possible, always on the bash command line or readline
level. Is there any simple way to do this without modifying source code of bash, readline
or my terminal emulator (gnome-terminal
)?
Another good solution would be to configure NBSP to be somehow visible on the command line, e.g. replaced with another character (say U+2423 ␣
) for rendering only.
command-line bash keyboard-layout unicode-entry readline
command-line bash keyboard-layout unicode-entry readline
edited May 29 at 7:17
dessert
29.3k7 gold badges88 silver badges121 bronze badges
29.3k7 gold badges88 silver badges121 bronze badges
asked May 29 at 6:28
Mikko RantalainenMikko Rantalainen
1,26613 silver badges20 bronze badges
1,26613 silver badges20 bronze badges
@dessert no need for a bounty, really. I just hit the problem and wrote a question about it. Later I found close enough config via Google Search to figure out the answer below. I'm still looking for an answer to make NBSP visible instead of disabling the character for all cases. I think I would like to have visible NBSP on readline level so that all terminal output is not messed up if I have NBSP in data strings.
– Mikko Rantalainen
Jun 2 at 10:41
@MikkoRantalainen could you explain what you're still missing more clearly? Since you found the way to map characters, why isn't" ":␣
enough? What else do you need?
– terdon♦
Jun 2 at 13:43
@dessert I would love to have a feature where I could write NBSP on the command line and getecho a␣b
but the resulting output line wereecho a b
with real NBSP in the output. As such, I think it must be done on the readline level (that is, command line editor always displays visible character but terminal emulator cannot know the difference between editor display and output display and therefore the terminal emulator cannot do the visual replacement for the rendering).
– Mikko Rantalainen
Jun 3 at 9:12
1
Solving it on readline level is indeed nice, but you might hit the same problem while writing a shell script in vim/emacs/etc in the terminal. See bugzilla.gnome.org/show_bug.cgi?id=788673 for a working proof of concept patch for gnome-terminal to highlight string matches, including perhaps the single NBSP character. (Yeah I know you said you didn't want to modify any source code…)
– egmont
Jun 16 at 22:11
1
Another approach is to address it on the font level, via a special font where NBSP's glyph is not empty, along with some fontconfig configuration. This would also work for graphical editors, not just the terminal. Yet another approach is to modify the keyboard layout to emit regular space, and use some other method to enter NBSP in the rare case when that's what you need.
– egmont
Jun 16 at 22:14
|
show 7 more comments
@dessert no need for a bounty, really. I just hit the problem and wrote a question about it. Later I found close enough config via Google Search to figure out the answer below. I'm still looking for an answer to make NBSP visible instead of disabling the character for all cases. I think I would like to have visible NBSP on readline level so that all terminal output is not messed up if I have NBSP in data strings.
– Mikko Rantalainen
Jun 2 at 10:41
@MikkoRantalainen could you explain what you're still missing more clearly? Since you found the way to map characters, why isn't" ":␣
enough? What else do you need?
– terdon♦
Jun 2 at 13:43
@dessert I would love to have a feature where I could write NBSP on the command line and getecho a␣b
but the resulting output line wereecho a b
with real NBSP in the output. As such, I think it must be done on the readline level (that is, command line editor always displays visible character but terminal emulator cannot know the difference between editor display and output display and therefore the terminal emulator cannot do the visual replacement for the rendering).
– Mikko Rantalainen
Jun 3 at 9:12
1
Solving it on readline level is indeed nice, but you might hit the same problem while writing a shell script in vim/emacs/etc in the terminal. See bugzilla.gnome.org/show_bug.cgi?id=788673 for a working proof of concept patch for gnome-terminal to highlight string matches, including perhaps the single NBSP character. (Yeah I know you said you didn't want to modify any source code…)
– egmont
Jun 16 at 22:11
1
Another approach is to address it on the font level, via a special font where NBSP's glyph is not empty, along with some fontconfig configuration. This would also work for graphical editors, not just the terminal. Yet another approach is to modify the keyboard layout to emit regular space, and use some other method to enter NBSP in the rare case when that's what you need.
– egmont
Jun 16 at 22:14
@dessert no need for a bounty, really. I just hit the problem and wrote a question about it. Later I found close enough config via Google Search to figure out the answer below. I'm still looking for an answer to make NBSP visible instead of disabling the character for all cases. I think I would like to have visible NBSP on readline level so that all terminal output is not messed up if I have NBSP in data strings.
– Mikko Rantalainen
Jun 2 at 10:41
@dessert no need for a bounty, really. I just hit the problem and wrote a question about it. Later I found close enough config via Google Search to figure out the answer below. I'm still looking for an answer to make NBSP visible instead of disabling the character for all cases. I think I would like to have visible NBSP on readline level so that all terminal output is not messed up if I have NBSP in data strings.
– Mikko Rantalainen
Jun 2 at 10:41
@MikkoRantalainen could you explain what you're still missing more clearly? Since you found the way to map characters, why isn't
" ":␣
enough? What else do you need?– terdon♦
Jun 2 at 13:43
@MikkoRantalainen could you explain what you're still missing more clearly? Since you found the way to map characters, why isn't
" ":␣
enough? What else do you need?– terdon♦
Jun 2 at 13:43
@dessert I would love to have a feature where I could write NBSP on the command line and get
echo a␣b
but the resulting output line were echo a b
with real NBSP in the output. As such, I think it must be done on the readline level (that is, command line editor always displays visible character but terminal emulator cannot know the difference between editor display and output display and therefore the terminal emulator cannot do the visual replacement for the rendering).– Mikko Rantalainen
Jun 3 at 9:12
@dessert I would love to have a feature where I could write NBSP on the command line and get
echo a␣b
but the resulting output line were echo a b
with real NBSP in the output. As such, I think it must be done on the readline level (that is, command line editor always displays visible character but terminal emulator cannot know the difference between editor display and output display and therefore the terminal emulator cannot do the visual replacement for the rendering).– Mikko Rantalainen
Jun 3 at 9:12
1
1
Solving it on readline level is indeed nice, but you might hit the same problem while writing a shell script in vim/emacs/etc in the terminal. See bugzilla.gnome.org/show_bug.cgi?id=788673 for a working proof of concept patch for gnome-terminal to highlight string matches, including perhaps the single NBSP character. (Yeah I know you said you didn't want to modify any source code…)
– egmont
Jun 16 at 22:11
Solving it on readline level is indeed nice, but you might hit the same problem while writing a shell script in vim/emacs/etc in the terminal. See bugzilla.gnome.org/show_bug.cgi?id=788673 for a working proof of concept patch for gnome-terminal to highlight string matches, including perhaps the single NBSP character. (Yeah I know you said you didn't want to modify any source code…)
– egmont
Jun 16 at 22:11
1
1
Another approach is to address it on the font level, via a special font where NBSP's glyph is not empty, along with some fontconfig configuration. This would also work for graphical editors, not just the terminal. Yet another approach is to modify the keyboard layout to emit regular space, and use some other method to enter NBSP in the rare case when that's what you need.
– egmont
Jun 16 at 22:14
Another approach is to address it on the font level, via a special font where NBSP's glyph is not empty, along with some fontconfig configuration. This would also work for graphical editors, not just the terminal. Yet another approach is to modify the keyboard layout to emit regular space, and use some other method to enter NBSP in the rare case when that's what you need.
– egmont
Jun 16 at 22:14
|
show 7 more comments
2 Answers
2
active
oldest
votes
This can be done on the readline
level two different ways.
Method 1
Put following in .inputrc
(the configuration file for readline
):
# include default system config because ~/.inputrc overrides system config
$include /etc/inputrc
# map NBSP to regular space (left part has NBSP in quotes, right part has space)
" ":" "
If markdown messes up the above, you have to put NBSP in quotes on the left side of colon as explained in the comment. This will map any occurrence of NBSP on input stream with a regular space.
Method 2
Put following in .inputrc
:
# include default system config because ~/.inputrc overrides system config
$include /etc/inputrc
# map "pipe + NBSP" to "pipe + regular space" (left part has NBSP in quotes)
"| ":"| "
set keyseq-timeout 250
The idea is to map key sequence pipe followed by NBSP to pipe followed by space. This works if you type the sequence within 250 ms (configurable above). However, until the timeout is gone, typing pipe symbol alone will not output anything. And if you type the sequence too slow, the fix will not be applied. Also note that the timeout is global so if you intend to use any other sequences, you have to set timeout long enough to be able to type the longest sequence. (The readline library is not clever enough to allow typing the characters and later replace already visible characters after the character sequence matches the configuration.)
add a comment
|
There's an excellent article dealing with this problem:
- How to deal with NBSPs in a terminal
I've been attempting to address the primary concern with grep
error messages and changing NBSP to something more visible using exec
command. I haven't got the syntax down pat yet though:
exec 2> >(tr $'xa0' $'x43' >&2)
The idea is to have this command in ~/.bashrc
so it automatically loads with gnome-terminal
opening. But as I said it's not working yet...
1
That would only deal with the error messages. I would prefer to catch the problem while I'm editing the command line because I might be writing something likeperl -i -npe 's/MARKER/4 KB/'
and I accidentally slip a NBSP between the4
andK
. Oops, the problem gets stored into a file but I don't get any error and the command line I wrote looks perfect.
– Mikko Rantalainen
Jun 5 at 6:33
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
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/4.0/"u003ecc by-sa 4.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%2faskubuntu.com%2fquestions%2f1147026%2fcan-i-configure-bash-readline-to-automatically-convert-nbsp-to-normal-space%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
This can be done on the readline
level two different ways.
Method 1
Put following in .inputrc
(the configuration file for readline
):
# include default system config because ~/.inputrc overrides system config
$include /etc/inputrc
# map NBSP to regular space (left part has NBSP in quotes, right part has space)
" ":" "
If markdown messes up the above, you have to put NBSP in quotes on the left side of colon as explained in the comment. This will map any occurrence of NBSP on input stream with a regular space.
Method 2
Put following in .inputrc
:
# include default system config because ~/.inputrc overrides system config
$include /etc/inputrc
# map "pipe + NBSP" to "pipe + regular space" (left part has NBSP in quotes)
"| ":"| "
set keyseq-timeout 250
The idea is to map key sequence pipe followed by NBSP to pipe followed by space. This works if you type the sequence within 250 ms (configurable above). However, until the timeout is gone, typing pipe symbol alone will not output anything. And if you type the sequence too slow, the fix will not be applied. Also note that the timeout is global so if you intend to use any other sequences, you have to set timeout long enough to be able to type the longest sequence. (The readline library is not clever enough to allow typing the characters and later replace already visible characters after the character sequence matches the configuration.)
add a comment
|
This can be done on the readline
level two different ways.
Method 1
Put following in .inputrc
(the configuration file for readline
):
# include default system config because ~/.inputrc overrides system config
$include /etc/inputrc
# map NBSP to regular space (left part has NBSP in quotes, right part has space)
" ":" "
If markdown messes up the above, you have to put NBSP in quotes on the left side of colon as explained in the comment. This will map any occurrence of NBSP on input stream with a regular space.
Method 2
Put following in .inputrc
:
# include default system config because ~/.inputrc overrides system config
$include /etc/inputrc
# map "pipe + NBSP" to "pipe + regular space" (left part has NBSP in quotes)
"| ":"| "
set keyseq-timeout 250
The idea is to map key sequence pipe followed by NBSP to pipe followed by space. This works if you type the sequence within 250 ms (configurable above). However, until the timeout is gone, typing pipe symbol alone will not output anything. And if you type the sequence too slow, the fix will not be applied. Also note that the timeout is global so if you intend to use any other sequences, you have to set timeout long enough to be able to type the longest sequence. (The readline library is not clever enough to allow typing the characters and later replace already visible characters after the character sequence matches the configuration.)
add a comment
|
This can be done on the readline
level two different ways.
Method 1
Put following in .inputrc
(the configuration file for readline
):
# include default system config because ~/.inputrc overrides system config
$include /etc/inputrc
# map NBSP to regular space (left part has NBSP in quotes, right part has space)
" ":" "
If markdown messes up the above, you have to put NBSP in quotes on the left side of colon as explained in the comment. This will map any occurrence of NBSP on input stream with a regular space.
Method 2
Put following in .inputrc
:
# include default system config because ~/.inputrc overrides system config
$include /etc/inputrc
# map "pipe + NBSP" to "pipe + regular space" (left part has NBSP in quotes)
"| ":"| "
set keyseq-timeout 250
The idea is to map key sequence pipe followed by NBSP to pipe followed by space. This works if you type the sequence within 250 ms (configurable above). However, until the timeout is gone, typing pipe symbol alone will not output anything. And if you type the sequence too slow, the fix will not be applied. Also note that the timeout is global so if you intend to use any other sequences, you have to set timeout long enough to be able to type the longest sequence. (The readline library is not clever enough to allow typing the characters and later replace already visible characters after the character sequence matches the configuration.)
This can be done on the readline
level two different ways.
Method 1
Put following in .inputrc
(the configuration file for readline
):
# include default system config because ~/.inputrc overrides system config
$include /etc/inputrc
# map NBSP to regular space (left part has NBSP in quotes, right part has space)
" ":" "
If markdown messes up the above, you have to put NBSP in quotes on the left side of colon as explained in the comment. This will map any occurrence of NBSP on input stream with a regular space.
Method 2
Put following in .inputrc
:
# include default system config because ~/.inputrc overrides system config
$include /etc/inputrc
# map "pipe + NBSP" to "pipe + regular space" (left part has NBSP in quotes)
"| ":"| "
set keyseq-timeout 250
The idea is to map key sequence pipe followed by NBSP to pipe followed by space. This works if you type the sequence within 250 ms (configurable above). However, until the timeout is gone, typing pipe symbol alone will not output anything. And if you type the sequence too slow, the fix will not be applied. Also note that the timeout is global so if you intend to use any other sequences, you have to set timeout long enough to be able to type the longest sequence. (The readline library is not clever enough to allow typing the characters and later replace already visible characters after the character sequence matches the configuration.)
edited May 29 at 8:51
answered May 29 at 7:19
Mikko RantalainenMikko Rantalainen
1,26613 silver badges20 bronze badges
1,26613 silver badges20 bronze badges
add a comment
|
add a comment
|
There's an excellent article dealing with this problem:
- How to deal with NBSPs in a terminal
I've been attempting to address the primary concern with grep
error messages and changing NBSP to something more visible using exec
command. I haven't got the syntax down pat yet though:
exec 2> >(tr $'xa0' $'x43' >&2)
The idea is to have this command in ~/.bashrc
so it automatically loads with gnome-terminal
opening. But as I said it's not working yet...
1
That would only deal with the error messages. I would prefer to catch the problem while I'm editing the command line because I might be writing something likeperl -i -npe 's/MARKER/4 KB/'
and I accidentally slip a NBSP between the4
andK
. Oops, the problem gets stored into a file but I don't get any error and the command line I wrote looks perfect.
– Mikko Rantalainen
Jun 5 at 6:33
add a comment
|
There's an excellent article dealing with this problem:
- How to deal with NBSPs in a terminal
I've been attempting to address the primary concern with grep
error messages and changing NBSP to something more visible using exec
command. I haven't got the syntax down pat yet though:
exec 2> >(tr $'xa0' $'x43' >&2)
The idea is to have this command in ~/.bashrc
so it automatically loads with gnome-terminal
opening. But as I said it's not working yet...
1
That would only deal with the error messages. I would prefer to catch the problem while I'm editing the command line because I might be writing something likeperl -i -npe 's/MARKER/4 KB/'
and I accidentally slip a NBSP between the4
andK
. Oops, the problem gets stored into a file but I don't get any error and the command line I wrote looks perfect.
– Mikko Rantalainen
Jun 5 at 6:33
add a comment
|
There's an excellent article dealing with this problem:
- How to deal with NBSPs in a terminal
I've been attempting to address the primary concern with grep
error messages and changing NBSP to something more visible using exec
command. I haven't got the syntax down pat yet though:
exec 2> >(tr $'xa0' $'x43' >&2)
The idea is to have this command in ~/.bashrc
so it automatically loads with gnome-terminal
opening. But as I said it's not working yet...
There's an excellent article dealing with this problem:
- How to deal with NBSPs in a terminal
I've been attempting to address the primary concern with grep
error messages and changing NBSP to something more visible using exec
command. I haven't got the syntax down pat yet though:
exec 2> >(tr $'xa0' $'x43' >&2)
The idea is to have this command in ~/.bashrc
so it automatically loads with gnome-terminal
opening. But as I said it's not working yet...
answered Jun 3 at 11:37
WinEunuuchs2UnixWinEunuuchs2Unix
59.1k18 gold badges119 silver badges233 bronze badges
59.1k18 gold badges119 silver badges233 bronze badges
1
That would only deal with the error messages. I would prefer to catch the problem while I'm editing the command line because I might be writing something likeperl -i -npe 's/MARKER/4 KB/'
and I accidentally slip a NBSP between the4
andK
. Oops, the problem gets stored into a file but I don't get any error and the command line I wrote looks perfect.
– Mikko Rantalainen
Jun 5 at 6:33
add a comment
|
1
That would only deal with the error messages. I would prefer to catch the problem while I'm editing the command line because I might be writing something likeperl -i -npe 's/MARKER/4 KB/'
and I accidentally slip a NBSP between the4
andK
. Oops, the problem gets stored into a file but I don't get any error and the command line I wrote looks perfect.
– Mikko Rantalainen
Jun 5 at 6:33
1
1
That would only deal with the error messages. I would prefer to catch the problem while I'm editing the command line because I might be writing something like
perl -i -npe 's/MARKER/4 KB/'
and I accidentally slip a NBSP between the 4
and K
. Oops, the problem gets stored into a file but I don't get any error and the command line I wrote looks perfect.– Mikko Rantalainen
Jun 5 at 6:33
That would only deal with the error messages. I would prefer to catch the problem while I'm editing the command line because I might be writing something like
perl -i -npe 's/MARKER/4 KB/'
and I accidentally slip a NBSP between the 4
and K
. Oops, the problem gets stored into a file but I don't get any error and the command line I wrote looks perfect.– Mikko Rantalainen
Jun 5 at 6:33
add a comment
|
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f1147026%2fcan-i-configure-bash-readline-to-automatically-convert-nbsp-to-normal-space%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
@dessert no need for a bounty, really. I just hit the problem and wrote a question about it. Later I found close enough config via Google Search to figure out the answer below. I'm still looking for an answer to make NBSP visible instead of disabling the character for all cases. I think I would like to have visible NBSP on readline level so that all terminal output is not messed up if I have NBSP in data strings.
– Mikko Rantalainen
Jun 2 at 10:41
@MikkoRantalainen could you explain what you're still missing more clearly? Since you found the way to map characters, why isn't
" ":␣
enough? What else do you need?– terdon♦
Jun 2 at 13:43
@dessert I would love to have a feature where I could write NBSP on the command line and get
echo a␣b
but the resulting output line wereecho a b
with real NBSP in the output. As such, I think it must be done on the readline level (that is, command line editor always displays visible character but terminal emulator cannot know the difference between editor display and output display and therefore the terminal emulator cannot do the visual replacement for the rendering).– Mikko Rantalainen
Jun 3 at 9:12
1
Solving it on readline level is indeed nice, but you might hit the same problem while writing a shell script in vim/emacs/etc in the terminal. See bugzilla.gnome.org/show_bug.cgi?id=788673 for a working proof of concept patch for gnome-terminal to highlight string matches, including perhaps the single NBSP character. (Yeah I know you said you didn't want to modify any source code…)
– egmont
Jun 16 at 22:11
1
Another approach is to address it on the font level, via a special font where NBSP's glyph is not empty, along with some fontconfig configuration. This would also work for graphical editors, not just the terminal. Yet another approach is to modify the keyboard layout to emit regular space, and use some other method to enter NBSP in the rare case when that's what you need.
– egmont
Jun 16 at 22:14