Color rm -i prompt messages Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election Results Why I closed the “Why is Kali so hard” questionCan I configure my shell to print STDERR and STDOUT in different colors?Bash read command and stdin redirectionCannot prompt user using rm bultin prompt option -i with xargs and findUnderstanding redirected if-statement in bashDisowned command with redirected STDOUT/STDERR still sending output to shellchanging prompt color in bash in konsoleIs there a simple test for anything printed on stderr in shell/Bash?display STDOUTs before STDERR?Alternate prompt, command, and output colorbash echo the command line executed at the command line itself (not in a script)Permanently redirect stderr to stdout
Has negative voting ever been officially implemented in elections, or seriously proposed, or even studied?
Why do we bend a book to keep it straight?
Should I use a zero-interest credit card for a large one-time purchase?
Closed form of recurrent arithmetic series summation
Amount of permutations on an NxNxN Rubik's Cube
Generate an RGB colour grid
Is it a good idea to use CNN to classify 1D signal?
Does classifying an integer as a discrete log require it be part of a multiplicative group?
What causes the direction of lightning flashes?
Why are the trig functions versine, haversine, exsecant, etc, rarely used in modern mathematics?
How to find all the available tools in mac terminal?
If my PI received research grants from a company to be able to pay my postdoc salary, did I have a potential conflict interest too?
Would "destroying" Wurmcoil Engine prevent its tokens from being created?
Irreducible of finite Krull dimension implies quasi-compact?
Is it cost-effective to upgrade an old-ish Giant Escape R3 commuter bike with entry-level branded parts (wheels, drivetrain)?
Fantasy story; one type of magic grows in power with use, but the more powerful they are, they more they are drawn to travel to their source
What is the longest distance a player character can jump in one leap?
Is there a kind of relay only consumes power when switching?
Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?
Is there such thing as an Availability Group failover trigger?
Is "Reachable Object" really an NP-complete problem?
Crossing US/Canada Border for less than 24 hours
How to down pick a chord with skipped strings?
When the Haste spell ends on a creature, do attackers have advantage against that creature?
Color rm -i prompt messages
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionCan I configure my shell to print STDERR and STDOUT in different colors?Bash read command and stdin redirectionCannot prompt user using rm bultin prompt option -i with xargs and findUnderstanding redirected if-statement in bashDisowned command with redirected STDOUT/STDERR still sending output to shellchanging prompt color in bash in konsoleIs there a simple test for anything printed on stderr in shell/Bash?display STDOUTs before STDERR?Alternate prompt, command, and output colorbash echo the command line executed at the command line itself (not in a script)Permanently redirect stderr to stdout
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm looking for a way to apply custom colors to messages emitted by the rm -i command:
~ $ rm -i file.txt
rm: remove regular empty file 'file.txt'?
I understand that I need to redirect the stderr as stdin to any command that will apply the ANSI colors to it and redirect the output back to stderr, e.g.
~ $ rm -i file.txt 2> >(sed $'s/^/e[31m/;s/$/e[m/'>&2)
However, this alone doesn't work; the above command doesn't print anything and starts to await the user input immediately. If I enter e.g. n and Enter, I get the colored output printed afterwards:
~ $ rm -i file.txt 2> >(sed $'s/^/e[31m/;s/$/e[m/'>&2)
n
rm: remove regular empty file 'file.txt'? ~ $
I seem to understand what is going wrong here - the stderr was redirected and colored, but not printed since the command started to await user input. Is there a way to print colored message before rm starts listening to the stdin?
bash colors rm stderr
add a comment |
I'm looking for a way to apply custom colors to messages emitted by the rm -i command:
~ $ rm -i file.txt
rm: remove regular empty file 'file.txt'?
I understand that I need to redirect the stderr as stdin to any command that will apply the ANSI colors to it and redirect the output back to stderr, e.g.
~ $ rm -i file.txt 2> >(sed $'s/^/e[31m/;s/$/e[m/'>&2)
However, this alone doesn't work; the above command doesn't print anything and starts to await the user input immediately. If I enter e.g. n and Enter, I get the colored output printed afterwards:
~ $ rm -i file.txt 2> >(sed $'s/^/e[31m/;s/$/e[m/'>&2)
n
rm: remove regular empty file 'file.txt'? ~ $
I seem to understand what is going wrong here - the stderr was redirected and colored, but not printed since the command started to await user input. Is there a way to print colored message before rm starts listening to the stdin?
bash colors rm stderr
2
Since rm outputs its messages to stderr, the answers to Can I configure my shell to print STDERR and STDOUT in different colors? may help.
– Mark Plotnick
9 hours ago
The reason that it gets coloured, is becausesedoutputs the colour codes. Thenrmruns. Howeversedis not receiving the stream. Tryecho >(ls)to see some of what is happening.
– ctrl-alt-delor
9 hours ago
add a comment |
I'm looking for a way to apply custom colors to messages emitted by the rm -i command:
~ $ rm -i file.txt
rm: remove regular empty file 'file.txt'?
I understand that I need to redirect the stderr as stdin to any command that will apply the ANSI colors to it and redirect the output back to stderr, e.g.
~ $ rm -i file.txt 2> >(sed $'s/^/e[31m/;s/$/e[m/'>&2)
However, this alone doesn't work; the above command doesn't print anything and starts to await the user input immediately. If I enter e.g. n and Enter, I get the colored output printed afterwards:
~ $ rm -i file.txt 2> >(sed $'s/^/e[31m/;s/$/e[m/'>&2)
n
rm: remove regular empty file 'file.txt'? ~ $
I seem to understand what is going wrong here - the stderr was redirected and colored, but not printed since the command started to await user input. Is there a way to print colored message before rm starts listening to the stdin?
bash colors rm stderr
I'm looking for a way to apply custom colors to messages emitted by the rm -i command:
~ $ rm -i file.txt
rm: remove regular empty file 'file.txt'?
I understand that I need to redirect the stderr as stdin to any command that will apply the ANSI colors to it and redirect the output back to stderr, e.g.
~ $ rm -i file.txt 2> >(sed $'s/^/e[31m/;s/$/e[m/'>&2)
However, this alone doesn't work; the above command doesn't print anything and starts to await the user input immediately. If I enter e.g. n and Enter, I get the colored output printed afterwards:
~ $ rm -i file.txt 2> >(sed $'s/^/e[31m/;s/$/e[m/'>&2)
n
rm: remove regular empty file 'file.txt'? ~ $
I seem to understand what is going wrong here - the stderr was redirected and colored, but not printed since the command started to await user input. Is there a way to print colored message before rm starts listening to the stdin?
bash colors rm stderr
bash colors rm stderr
edited 9 hours ago
Jeff Schaller♦
45.1k1164147
45.1k1164147
asked 10 hours ago
hoeflinghoefling
6211612
6211612
2
Since rm outputs its messages to stderr, the answers to Can I configure my shell to print STDERR and STDOUT in different colors? may help.
– Mark Plotnick
9 hours ago
The reason that it gets coloured, is becausesedoutputs the colour codes. Thenrmruns. Howeversedis not receiving the stream. Tryecho >(ls)to see some of what is happening.
– ctrl-alt-delor
9 hours ago
add a comment |
2
Since rm outputs its messages to stderr, the answers to Can I configure my shell to print STDERR and STDOUT in different colors? may help.
– Mark Plotnick
9 hours ago
The reason that it gets coloured, is becausesedoutputs the colour codes. Thenrmruns. Howeversedis not receiving the stream. Tryecho >(ls)to see some of what is happening.
– ctrl-alt-delor
9 hours ago
2
2
Since rm outputs its messages to stderr, the answers to Can I configure my shell to print STDERR and STDOUT in different colors? may help.
– Mark Plotnick
9 hours ago
Since rm outputs its messages to stderr, the answers to Can I configure my shell to print STDERR and STDOUT in different colors? may help.
– Mark Plotnick
9 hours ago
The reason that it gets coloured, is because
sed outputs the colour codes. Then rm runs. However sed is not receiving the stream. Try echo >(ls) to see some of what is happening.– ctrl-alt-delor
9 hours ago
The reason that it gets coloured, is because
sed outputs the colour codes. Then rm runs. However sed is not receiving the stream. Try echo >(ls) to see some of what is happening.– ctrl-alt-delor
9 hours ago
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%2f513033%2fcolor-rm-i-prompt-messages%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%2f513033%2fcolor-rm-i-prompt-messages%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
-bash, colors, rm, stderr
2
Since rm outputs its messages to stderr, the answers to Can I configure my shell to print STDERR and STDOUT in different colors? may help.
– Mark Plotnick
9 hours ago
The reason that it gets coloured, is because
sedoutputs the colour codes. Thenrmruns. Howeversedis not receiving the stream. Tryecho >(ls)to see some of what is happening.– ctrl-alt-delor
9 hours ago