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;








1















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?










share|improve this question



















  • 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 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

















1















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?










share|improve this question



















  • 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 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













1












1








1








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?










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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












  • 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 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







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










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
);



);













draft saved

draft discarded


















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















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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

Popular posts from this blog

Creating 100m^2 grid automatically using QGIS?Creating grid constrained within polygon in QGIS?Createing polygon layer from point data using QGIS?Creating vector grid using QGIS?Creating grid polygons from coordinates using R or PythonCreating grid from spatio temporal point data?Creating fields in attributes table using other layers using QGISCreate .shp vector grid in QGISQGIS Creating 4km point grid within polygonsCreate a vector grid over a raster layerVector Grid Creates just one grid

What is this called? Old film camera viewer?What makes a good film camera?What to do with an old film camera?What should one look for when buying a used film camera?What is the value and age of this pre-1967 Ricoh 35 mm camera?DSLR recommendation, question about old Canon 35mm film Camera & lensesCan anyone identify the silver rangefinder-style camera in this advertisement?What kind of a Polaroid 600-camera is this?Will an old film camera still work even when not used in a very long time?What is this camera / Can I develop the film?How to fit an action camera into antique (bellows) housing?What to check when buying used and old film bodies?

Why is this plane circling around the Lucknow airport every day?Why do aircraft on Flight Radar 24 jump around randomly sometimes?What airport has this walkway over a taxiway?How does Chicago O'Hare's tower sequence aircraft at peak capacity?Which airport is featured in this Delta commercial?After a crash, for how long is the airport closed?Can a passenger plane stand still in the air, or hover at a fixed location above a ground?What are those trucks towing around, and why?What is this airport outside of Cairo, Egypt?Which US airport has the lowest circling MDH?What is this airport video?