You are not logged in.

#1 2025-01-27 18:32:52

Erwin Iosef
Member
Registered: 2024-05-22
Posts: 68

[SOLVED]tty cursor color bash color resetting on new command

So, my linux tty theme is a cyan foreground on black background, the problems I'm facing right now is agetty having the cursor to grey on login while everything else is cyan and bash prompt resetting to the default grey on black colour whenever you use commands like vim or pacman -Syu.
Any way to change the cursor color to blue on login as well as prompt? and making the foreground color persistent across commands or setting it as default?

Things I tried: setterm didn't help, passing -I "\e]12;cyan\a" on aggety@.service.d/config.conf didn't help. Any help is appreciated, thanks!

Last edited by Erwin Iosef (2025-01-28 18:23:19)

Offline

#2 2025-01-28 09:10:10

seth
Member
Registered: 2012-09-03
Posts: 61,581

Re: [SOLVED]tty cursor color bash color resetting on new command

How do you set the color scheme? Sth. like

#!/bin/sh
if [ "$TERM" = "linux" ]; then
  /bin/echo -e "
  \e]P0282a2e
  \e]P1a54242
  \e]P28c9440
  \e]P3de935f
  \e]P45f819d
  \e]P585678f
  \e]P65e8d87
  \e]P7707880
  \e]P8373b41
  \e]P9cc6666
  \e]PAb5bd68
  \e]PBf0c674
  \e]PC81a2be
  \e]PDb294bb
  \e]PE8abeb7
  \e]PFc5c8c6
  "
  # get rid of artifacts
  clear
fi

https://terminal.sexy/

Offline

#3 2025-01-28 10:29:56

Erwin Iosef
Member
Registered: 2024-05-22
Posts: 68

Re: [SOLVED]tty cursor color bash color resetting on new command

seth wrote:

How do you set the color scheme?

I just wrote PS1='\e]12;cyan\a[\u@\h \W]\$ ' in bash.bashrc.

Offline

#4 2025-01-28 13:30:39

seth
Member
Registered: 2012-09-03
Posts: 61,581

Re: [SOLVED]tty cursor color bash color resetting on new command

That just sets the current color code and (as you figured) is not going to work - the moment anything runs "\e[0m" (your line looks wrong btw?) this is lost.
If you want to change the terminal colors and make white cyan, see the posted approach and terminal.sexy to easily generate yourself a colorscheme you like.

Offline

#5 2025-01-28 14:00:16

Erwin Iosef
Member
Registered: 2024-05-22
Posts: 68

Re: [SOLVED]tty cursor color bash color resetting on new command

That just sets the current color code and (as you figured) is not going to work - the moment anything runs "\e[0m" (your line looks wrong btw?) this is lost

I noticed how the wiki doesn't make any mention of this issue in its bash color prompting article for some reason and didn't provide any alternatives unless I'm wrong. I'll check the link out meantime, thank you very much.

(your line looks wrong btw?)

I made the line up from scratch because I was away from my machine to copy, the line that is correct works on my machine, don't worry about it.

Offline

#6 2025-01-28 14:12:11

seth
Member
Registered: 2012-09-03
Posts: 61,581

Re: [SOLVED]tty cursor color bash color resetting on new command

Yeah, but that's about making the priompt look fancy - not change the global textcolor.
It's to do stuff like this:
image_e2447ddd-416e-4036-9584-e728455e6d9d.png

Offline

#7 2025-01-28 14:24:01

Erwin Iosef
Member
Registered: 2024-05-22
Posts: 68

Re: [SOLVED]tty cursor color bash color resetting on new command

seth wrote:

How do you set the color scheme? Sth. like

#!/bin/sh
if [ "$TERM" = "linux" ]; then
  /bin/echo -e "
  \e]P0282a2e
  \e]P1a54242
  \e]P28c9440
  \e]P3de935f
  \e]P45f819d
  \e]P585678f
  \e]P65e8d87
  \e]P7707880
  \e]P8373b41
  \e]P9cc6666
  \e]PAb5bd68
  \e]PBf0c674
  \e]PC81a2be
  \e]PDb294bb
  \e]PE8abeb7
  \e]PFc5c8c6
  "
  # get rid of artifacts
  clear
fi

https://terminal.sexy/


Wait so I just choose the font and color on the site and then export and download right?
How do I implement a Linux console theme then?

Offline

#8 2025-01-28 14:24:50

Erwin Iosef
Member
Registered: 2024-05-22
Posts: 68

Re: [SOLVED]tty cursor color bash color resetting on new command

seth wrote:

Yeah, but that's about making the priompt look fancy - not change the global textcolor.
It's to do stuff like this:
https://images.hanselman.com/blog/Windo … 5e6d9d.png

Ahh I see but still it does mention changing foregorund.

Last edited by Erwin Iosef (2025-01-28 14:25:08)

Offline

#9 2025-01-28 14:26:24

seth
Member
Registered: 2012-09-03
Posts: 61,581

Re: [SOLVED]tty cursor color bash color resetting on new command

You put that into an executable script or your bashrc, executing that echo command will alter the colors likey you'd point-and-click configure them in a GUI.

Please don't bump (edit your previous post if nobody has yet replied) and also avoid bloating the thread with pointless full-quotes.
Thanks.

Offline

#10 2025-01-28 14:30:18

Erwin Iosef
Member
Registered: 2024-05-22
Posts: 68

Re: [SOLVED]tty cursor color bash color resetting on new command

Of course, my bad and got it! Thanks for your help!

Offline

#11 2025-01-28 14:41:33

Erwin Iosef
Member
Registered: 2024-05-22
Posts: 68

Re: [SOLVED]tty cursor color bash color resetting on new command

@seth I put it inside bashrc and tried it in a tty but didn't work after doing `ls -l` command. It went back to a grey.

Last edited by Erwin Iosef (2025-01-28 14:41:42)

Offline

#12 2025-01-28 14:44:48

seth
Member
Registered: 2012-09-03
Posts: 61,581

Re: [SOLVED]tty cursor color bash color resetting on new command

What script did you generate at terminal.sexy?
And what happens if you remove the color code from your prompt?

Offline

#13 2025-01-28 15:42:13

Erwin Iosef
Member
Registered: 2024-05-22
Posts: 68

Re: [SOLVED]tty cursor color bash color resetting on new command

#!/bin/sh
if [ "$TERM" = "linux" ]; then
  /bin/echo -e "
  \e]P0282a2e
  \e]P1a54242
  \e]P28c9440
  \e]P3de935f
  \e]P45f819d
  \e]P585678f
  \e]P65e8d87
  \e]P7707880
  \e]P8373b41
  \e]P9cc6666
  \e]PAb5bd68
  \e]PBf0c674
  \e]PC00ffff
  \e]PDb294bb
  \e]PE8abeb7
  \e]PFc5c8c6
  "
  # get rid of artifacts
  clear
fi

This one.

The background is a lighter black/greyish with the colours looking more modern and not the full contrast ones, if you understand.

Last edited by Erwin Iosef (2025-01-28 16:22:10)

Offline

#14 2025-01-28 15:54:16

seth
Member
Registered: 2012-09-03
Posts: 61,581

Re: [SOLVED]tty cursor color bash color resetting on new command

Please use [code][/code] tags, not "quote" tags. Edit your post in this regard.

That's the sites default scheme and you just changed blue to cyan?
Try changing colors 7 & 15 to what you want to use as standard foreground.

Offline

#15 2025-01-28 16:21:35

Erwin Iosef
Member
Registered: 2024-05-22
Posts: 68

Re: [SOLVED]tty cursor color bash color resetting on new command

Alright now it works and I understood how the colours work now, I thought it was just a pallet of colours to choose from. I checked with `pacman -Syu` and `ls -l`, it works on both occassions.

I want to keep the background black though, is removing all the colours except for 7 and 15 sufficient or should I change the background(0 and 8 maybe)?

Offline

#16 2025-01-28 16:29:57

Erwin Iosef
Member
Registered: 2024-05-22
Posts: 68

Re: [SOLVED]tty cursor color bash color resetting on new command

Alright changing 0 and 8 worked and the theme looks excellent and as I want it to be, thank you so much @seth.

Last edited by Erwin Iosef (2025-01-28 16:33:34)

Offline

#17 2025-01-28 16:35:44

seth
Member
Registered: 2012-09-03
Posts: 61,581

Re: [SOLVED]tty cursor color bash color resetting on new command

There're just 16 colors, https://wiki.archlinux.org/title/Color_ … _with_tput
They're then invoked by stuff™ by printing special-secret escape sequences to tell the terminal to now please use this kind of color.

More modern/GUI TEs support more colors, so you can have shades of gray and all sorts of nice things.

The colors are arbitrary, but if you set all (but black) to the same value, you end up with a monochromatic display.

Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Offline

#18 2025-01-28 16:48:24

Erwin Iosef
Member
Registered: 2024-05-22
Posts: 68

Re: [SOLVED]tty cursor color bash color resetting on new command

@seth is the `clear` really necessary because I don't want my issue to dissapear but not doing so sends the prompt down some lines after login.

Offline

#19 2025-01-28 16:58:19

seth
Member
Registered: 2012-09-03
Posts: 61,581

Re: [SOLVED]tty cursor color bash color resetting on new command

You'd make sure to run this before the issue but it's not strictly necessary and whether you get any remaining artifacts you'll have to try and see.

Offline

#20 2025-01-28 17:14:46

Erwin Iosef
Member
Registered: 2024-05-22
Posts: 68

Re: [SOLVED]tty cursor color bash color resetting on new command

Adding `> /dev/null` to the echo command solved it. Currently testing things right now.
EDIT: That brought back the issue of the prompt losing color changes after command.

Last edited by Erwin Iosef (2025-01-28 17:37:32)

Offline

#21 2025-01-28 18:04:07

Erwin Iosef
Member
Registered: 2024-05-22
Posts: 68

Re: [SOLVED]tty cursor color bash color resetting on new command

Alright so I used the blank lines produced by the escape characters printing to my advantage and produced something like this:

# /etc/profile

echo -e " \e]P0000000
$(fortune) \e]P700ffff"
  # get rid of artifacts
  #clear

BTW how would you execute code before /etc/issue? Something like rc scripts?

Last edited by Erwin Iosef (2025-01-28 18:13:04)

Offline

#22 2025-01-28 18:21:30

Erwin Iosef
Member
Registered: 2024-05-22
Posts: 68

Re: [SOLVED]tty cursor color bash color resetting on new command

Alright so I think I solved my problems for the bash color change and cursor color, with this summary:

# /etc/profile
echo -e " \e]P0000000 \e]P700ffff" #or you can use above code for profile
  # get rid of artifacts
  #clear

and

# /etc/issue
\e]P0000000 // your issue here//

EDIT: ALSO if you have multiple escape lines and want to avoid the blank lines being created, try joining all of them in a single line separated by spaces, like this:

echo -e "\e]P0000000 \e]P0000001"

Integrates seamlessly with everything almost.
Thank you @seth for your help. Marking as solved.

Last edited by Erwin Iosef (2025-01-28 18:29:27)

Offline

#23 2025-01-28 18:55:43

Erwin Iosef
Member
Registered: 2024-05-22
Posts: 68

Re: [SOLVED]tty cursor color bash color resetting on new command

Note that the systemd log lines will show blue with these configs, don't know a fix yet but post if you(the reader) has one.

Offline

Board footer

Powered by FluxBB