Skip to main content
Topic: Configuring bash in tty to show cursor and also set default foreground colour. (Read 546 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Configuring bash in tty to show cursor and also set default foreground colour.

How do I make bash in tty and the basic login in tty(probably elogind, I'm not a Linux expert) have cursor. In my tty I don't have one, unless I run some command that either also resets my foreground colours to default white. I want to have a cursor by default like in most systemd distros when you switch to a different tty and face the login text.

On a different note, does anyone know how to set the foreground of a bash in tty after login to default Blue always? Like not be reset after a command to white everytime?



Re: Configuring bash in tty to show cursor and also set default foreground colour.

Reply #3
I have a cursor when I switch to a tty, but never had to put it there myself. The vte-common package seems to provide /etc/profile.d/vte.sh, which looks like it might set up the prompt (well possibly, I haven't tested what happens if it's missing or altered)  and is a dependency of vte3 which is a dependency of mate-terminal, could you somehow be missing this package if you had some other GUI terminal? Although I don't think it would affect this issue, the bash-completion package might also not be installed if you did a base install and cause other oddities compared to other distros.

Re: Configuring bash in tty to show cursor and also set default foreground colour.

Reply #4
@replabrobin @Hitman I'm so sorry for replying late, got stuck with stuff. I tried your suggestions in the bashrc file for PS1 and it didn't work although it did set the colour blue. The screen resets to grey after I use the "ls -l" command. Anyway to really make it permanent regardless of what commands I issue? I mean this feels like just a more complicated alternative to the setterm command.

Also why is my bash command blinking cursor coming back on after using Pacman on the tty but not on any other regular usage, like after I login through tty?

Can anyone help? This feels like default behaviour(I think I've seen it when using the artix ISOs) and I think a cursor is important in a tty to not mess up when correcting commands, not sure why people wouldn't include it.

EDIT: I got cursor working in bash - the escape code is \e[?25h, but not on login prompt.
EDIT 2: So now the questions are, how do you configure the login prompt(I'm not talking about /etc/issue) to add a cursor, and how do you forcibly make the bash prompt not lose color when you use a command that somehow changes it, like "ls -l"?

Re: Configuring bash in tty to show cursor and also set default foreground colour.

Reply #5
I have a prompt at login too. When I get the login prompt or switch to a tty I am running in a "getty" which is set up by OpenRC agetty files in /etc/conf.d and /etc/init.d and if I run $ env it tells me I am using /bin/bash as the shell, so /etc/issue is being run. There's something wrong or missing relating to your getty setup - what init are you using? If you were using OpenRC this should all work out of the box.

Re: Configuring bash in tty to show cursor and also set default foreground colour.

Reply #6
@####### Yeah I know getty is responsible for login and I'm trying to configure it now, I use agetty and dinit.
But so far I don't know what arguments or options to pass for cursor visibility. Also I wish I could disable arrow keys in login because that messes up input if you  press the up and down keys. Thanks for helping.

Re: Configuring bash in tty to show cursor and also set default foreground colour.

Reply #7
I suspect this could be more of a dinit problem then, either the agetty service is not correctly set up, but that seems unlikely as others would probably have noticed, or there is some race condition or other problem specific to your installation or hardware preventing it coming up correctly at login. But not being a dinit user myself, I'm not sure what you should check for this. Do you get a normal working tty if you press ctrl - alt - f2/3/4 etc. after you have booted to the desktop?

Re: Configuring bash in tty to show cursor and also set default foreground colour.

Reply #8
I experimented a bit in the console.

0) the initial cursor is a blinking underline
1) env TERM is 'linux'
2)  tput init and tput reset both appear to work
3) tput cvvis changes the cursor to a blinking block cursor
4) tput civis made the cursor invisble
5) tput cnorm restored the normal cursor ie blinking underline

tput and friends are part of ncurses I think

Re: Configuring bash in tty to show cursor and also set default foreground colour.

Reply #9
@####### Yeah I know getty is responsible for login and I'm trying to configure it now, I use agetty and dinit.
But so far I don't know what arguments or options to pass for cursor visibility. Also I wish I could disable arrow keys in login because that messes up input if you  press the up and down keys. Thanks for helping.


I use dinit, and I have a normal blinking cursor if I switch to a tty. No special config on my part to achieve this. 

This may or may not help you, I'm just confirming normal behaviour with dinit.

Re: Configuring bash in tty to show cursor and also set default foreground colour.

Reply #10
@####### All my ttys, including bash work correctly and the login works except the cursor is not visible and for some reason you can move the cursor(invisible as it is) up and down and right and left, that is, you can literally overwrite the login text presented onscreen if you move the cursor to it left using arrow keys, if that makes sense. I always had this in every artix-dinit install. Feels like a glitch that never got fixed if you ask me. And I installed using the wiki too. And for agetty configuration, my file is as as shown here

I don't really know how to configure it.

Re: Configuring bash in tty to show cursor and also set default foreground colour.

Reply #11
@replabrobin Your suggestions may work for bash but I already resolved that anyway.. My problems are the login prompt cursor and bash colours defaulting to grey after running certain commands. Thanks again for helping.

 

Re: Configuring bash in tty to show cursor and also set default foreground colour.

Reply #12
So, I booted a live iso of the latest LXQT install media of artix and its login has a blinking cursor, now I'm trying to figure out how it has that but mine doesn't for context, I always installed mine through cli and not through an installer.

Editd and revelations,

So, I took a look at the tty configs between mine and artix live iso's and I found this:

This is mine[tty1 in /etc/dinit.d/]
Code: [Select]
type            = process
command         = /usr/lib/dinit/agetty-default tty1
restart         = true
depends-on      = login.target
termsignal      = HUP
smooth-recovery = true
inittab-id      = 1
inittab-line    = tty1

And this is artix iso's:

Code: [Select]
type            = process
command         = /sbin/agetty --noclear tty1 38400 linux
restart         = true
depends-on      = loginready
termsignal      = HUP
smooth-recovery = true
inittab-id      = 1
inittab-line    = tty1

So I copied the artix live iso tty1 script to my own, it didn't work.