How can I regex match-and-replace _all_ on-screen text?
Clash Royale CLAN TAG#URR8PPP
I need a way to replace an on-screen pattern with another string, regardless of what places that text on the screen. Maybe I can live without user input being replaced, but anything that comes from the stdout, stderr of any process - background or foreground, and even prompt strings need to be subject to replacement.
An example of one of the applications (though, this one doesn't affect the prompt, but I have other needs there):
I want to replace all series of digits w/ themselves, selectively underlined, so I turn 1234567890.1234567890 into 1̲2345̲6̲7̲890.1̲2̲3̲4567̲8̲9̲0. I've already aliased ls to do this, as well as a number of other commands that display long numbers, but I've come to like it so much that I want it global.
bash text-processing regular-expression text-formatting
add a comment |
I need a way to replace an on-screen pattern with another string, regardless of what places that text on the screen. Maybe I can live without user input being replaced, but anything that comes from the stdout, stderr of any process - background or foreground, and even prompt strings need to be subject to replacement.
An example of one of the applications (though, this one doesn't affect the prompt, but I have other needs there):
I want to replace all series of digits w/ themselves, selectively underlined, so I turn 1234567890.1234567890 into 1̲2345̲6̲7̲890.1̲2̲3̲4567̲8̲9̲0. I've already aliased ls to do this, as well as a number of other commands that display long numbers, but I've come to like it so much that I want it global.
bash text-processing regular-expression text-formatting
Related: unix.stackexchange.com/a/53587/117549
– Jeff Schaller
Jan 16 at 18:17
But... why? It does not make sense to replace output from a command.
– Tommiie
Jan 16 at 20:16
One reason is given in the original question: When you see n-digit numbers on screen, underlining triplets makes instantly clear what the order of magnitude is. Another, more subtle reason, is that I want something in my prompt that takes about a second to generate (I'm interfacing custom hardware) but I don't want to delay the prompt for the response. I'd like to print a prompt with a placeholder that is replaced when the data are available. I didn't put this in the original question because it's very much the Level 2 version. I have some other needs, too, but not worth getting into.
– Sniggerfardimungus
Jan 16 at 21:01
add a comment |
I need a way to replace an on-screen pattern with another string, regardless of what places that text on the screen. Maybe I can live without user input being replaced, but anything that comes from the stdout, stderr of any process - background or foreground, and even prompt strings need to be subject to replacement.
An example of one of the applications (though, this one doesn't affect the prompt, but I have other needs there):
I want to replace all series of digits w/ themselves, selectively underlined, so I turn 1234567890.1234567890 into 1̲2345̲6̲7̲890.1̲2̲3̲4567̲8̲9̲0. I've already aliased ls to do this, as well as a number of other commands that display long numbers, but I've come to like it so much that I want it global.
bash text-processing regular-expression text-formatting
I need a way to replace an on-screen pattern with another string, regardless of what places that text on the screen. Maybe I can live without user input being replaced, but anything that comes from the stdout, stderr of any process - background or foreground, and even prompt strings need to be subject to replacement.
An example of one of the applications (though, this one doesn't affect the prompt, but I have other needs there):
I want to replace all series of digits w/ themselves, selectively underlined, so I turn 1234567890.1234567890 into 1̲2345̲6̲7̲890.1̲2̲3̲4567̲8̲9̲0. I've already aliased ls to do this, as well as a number of other commands that display long numbers, but I've come to like it so much that I want it global.
bash text-processing regular-expression text-formatting
bash text-processing regular-expression text-formatting
asked Jan 16 at 17:51
SniggerfardimungusSniggerfardimungus
1143
1143
Related: unix.stackexchange.com/a/53587/117549
– Jeff Schaller
Jan 16 at 18:17
But... why? It does not make sense to replace output from a command.
– Tommiie
Jan 16 at 20:16
One reason is given in the original question: When you see n-digit numbers on screen, underlining triplets makes instantly clear what the order of magnitude is. Another, more subtle reason, is that I want something in my prompt that takes about a second to generate (I'm interfacing custom hardware) but I don't want to delay the prompt for the response. I'd like to print a prompt with a placeholder that is replaced when the data are available. I didn't put this in the original question because it's very much the Level 2 version. I have some other needs, too, but not worth getting into.
– Sniggerfardimungus
Jan 16 at 21:01
add a comment |
Related: unix.stackexchange.com/a/53587/117549
– Jeff Schaller
Jan 16 at 18:17
But... why? It does not make sense to replace output from a command.
– Tommiie
Jan 16 at 20:16
One reason is given in the original question: When you see n-digit numbers on screen, underlining triplets makes instantly clear what the order of magnitude is. Another, more subtle reason, is that I want something in my prompt that takes about a second to generate (I'm interfacing custom hardware) but I don't want to delay the prompt for the response. I'd like to print a prompt with a placeholder that is replaced when the data are available. I didn't put this in the original question because it's very much the Level 2 version. I have some other needs, too, but not worth getting into.
– Sniggerfardimungus
Jan 16 at 21:01
Related: unix.stackexchange.com/a/53587/117549
– Jeff Schaller
Jan 16 at 18:17
Related: unix.stackexchange.com/a/53587/117549
– Jeff Schaller
Jan 16 at 18:17
But... why? It does not make sense to replace output from a command.
– Tommiie
Jan 16 at 20:16
But... why? It does not make sense to replace output from a command.
– Tommiie
Jan 16 at 20:16
One reason is given in the original question: When you see n-digit numbers on screen, underlining triplets makes instantly clear what the order of magnitude is. Another, more subtle reason, is that I want something in my prompt that takes about a second to generate (I'm interfacing custom hardware) but I don't want to delay the prompt for the response. I'd like to print a prompt with a placeholder that is replaced when the data are available. I didn't put this in the original question because it's very much the Level 2 version. I have some other needs, too, but not worth getting into.
– Sniggerfardimungus
Jan 16 at 21:01
One reason is given in the original question: When you see n-digit numbers on screen, underlining triplets makes instantly clear what the order of magnitude is. Another, more subtle reason, is that I want something in my prompt that takes about a second to generate (I'm interfacing custom hardware) but I don't want to delay the prompt for the response. I'd like to print a prompt with a placeholder that is replaced when the data are available. I didn't put this in the original question because it's very much the Level 2 version. I have some other needs, too, but not worth getting into.
– Sniggerfardimungus
Jan 16 at 21:01
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%2f494895%2fhow-can-i-regex-match-and-replace-all-on-screen-text%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%2f494895%2fhow-can-i-regex-match-and-replace-all-on-screen-text%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
Related: unix.stackexchange.com/a/53587/117549
– Jeff Schaller
Jan 16 at 18:17
But... why? It does not make sense to replace output from a command.
– Tommiie
Jan 16 at 20:16
One reason is given in the original question: When you see n-digit numbers on screen, underlining triplets makes instantly clear what the order of magnitude is. Another, more subtle reason, is that I want something in my prompt that takes about a second to generate (I'm interfacing custom hardware) but I don't want to delay the prompt for the response. I'd like to print a prompt with a placeholder that is replaced when the data are available. I didn't put this in the original question because it's very much the Level 2 version. I have some other needs, too, but not worth getting into.
– Sniggerfardimungus
Jan 16 at 21:01