[SOLVED] Change prompt colour in the terminal

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
Snafu
Level 2
Level 2
Posts: 65
Joined: Tue Mar 13, 2018 7:01 am
Location: Australia

[SOLVED] Change prompt colour in the terminal

Post by Snafu »

The prompt and text in my terminal were all the same colour, green, and I find it easier to read if the prompt and text are different colours. I've been trying to change the prompt colour by following instructions I found on ask ubuntu. I'm very new at fiddling with program files and do so with a great deal of trepidation. Last night I managed to remove the colour from the prompt so it was colourless before I got scared and bailed out, today I'm trying again. When I edit the colour code in line with the instructions I get the following message

Code: Select all

** (xed:19086): WARNING **: 20:39:50.216: Set document metadata failed: Setting attribute metadata::xed-spell-language not supported

** (xed:19086): WARNING **: 20:39:50.216: Set document metadata failed: Setting attribute metadata::xed-encoding not supported

What am I doing wrong?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 3 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
When all else fails follow the instructions
User avatar
Pierre
Level 21
Level 21
Posts: 13182
Joined: Fri Sep 05, 2008 5:33 am
Location: Perth, AU.

Re: Change prompt colour in the terminal

Post by Pierre »

where is the Ubuntu instruction set ?.
Image
Please edit your original post title to include [SOLVED] - when your problem is solved!
and DO LOOK at those Unanswered Topics - - you may be able to answer some!.
User avatar
Snafu
Level 2
Level 2
Posts: 65
Joined: Tue Mar 13, 2018 7:01 am
Location: Australia

Re: Change prompt colour in the terminal

Post by Snafu »

where is the Ubuntu instruction set ?.
https://askubuntu.com/questions/676352/ ... ash-prompt

I've been following answer No. 2
When all else fails follow the instructions
User avatar
Pierre
Level 21
Level 21
Posts: 13182
Joined: Fri Sep 05, 2008 5:33 am
Location: Perth, AU.

Re: Change prompt colour in the terminal

Post by Pierre »

that was something that I've done way back in the Days of Dos
8)

but on a Linux System ?. - - where did you find that ~/.bashrc file ? or did you have to create it ?.
( there doesn't seem to be such a file in my /home directory )
Image
Please edit your original post title to include [SOLVED] - when your problem is solved!
and DO LOOK at those Unanswered Topics - - you may be able to answer some!.
User avatar
Snafu
Level 2
Level 2
Posts: 65
Joined: Tue Mar 13, 2018 7:01 am
Location: Australia

Re: Change prompt colour in the terminal

Post by Snafu »

but on a Linux System ?. - - where did you find that ~/.bashrc file ? or did you have to create it ?.
The file was there, I opened it and successfully uncommented the

Code: Select all

#force_color_prompt=yes
line but editing the colour code just wont stick for some reason.

Never mind, doing the exact same thing for a tenth time seems to have worked. I now have the coloured prompt I was after. So far as I can tell the solution was to swear and strike the keys with vigor. :shock:
Last edited by Snafu on Tue Jun 19, 2018 8:14 am, edited 1 time in total.
When all else fails follow the instructions
User avatar
Pierre
Level 21
Level 21
Posts: 13182
Joined: Fri Sep 05, 2008 5:33 am
Location: Perth, AU.

Re: [SOLVED] Change prompt colour in the terminal

Post by Pierre »

interestingly - - I'm not able to find that file, however:
- if the changes won't "stick" - - are you editing as /Root ? - - sudo type stuff ?
as that file most probably is a System File - that you can't directly edit . .

EDIT: it's a System File that resides as /etc/skel/./bashrc
Image
Please edit your original post title to include [SOLVED] - when your problem is solved!
and DO LOOK at those Unanswered Topics - - you may be able to answer some!.
User avatar
Snafu
Level 2
Level 2
Posts: 65
Joined: Tue Mar 13, 2018 7:01 am
Location: Australia

Re: [SOLVED] Change prompt colour in the terminal

Post by Snafu »

Yes, I sudo'd to open ~/.bashrc in xed. I'm running mint 19 mate, maybe that file is something new?
When all else fails follow the instructions
User avatar
Pierre
Level 21
Level 21
Posts: 13182
Joined: Fri Sep 05, 2008 5:33 am
Location: Perth, AU.

Re: [SOLVED] Change prompt colour in the terminal

Post by Pierre »

well it did work on this LM18x mate machine & gives some resemblance of using colour fonts - now.
:)
Image
Please edit your original post title to include [SOLVED] - when your problem is solved!
and DO LOOK at those Unanswered Topics - - you may be able to answer some!.
User avatar
Snafu
Level 2
Level 2
Posts: 65
Joined: Tue Mar 13, 2018 7:01 am
Location: Australia

Re: [SOLVED] Change prompt colour in the terminal

Post by Snafu »

/etc/skel is empty on my machine....


Thanks for your efforts Pierre
When all else fails follow the instructions
User avatar
Pierre
Level 21
Level 21
Posts: 13182
Joined: Fri Sep 05, 2008 5:33 am
Location: Perth, AU.

Re: [SOLVED] Change prompt colour in the terminal

Post by Pierre »

except - that I'm now gonna have to fire up my LM19 mate and see if there is any difference
:?
something else to do, . . . .

EDIT: yep - - it's still the same & needs /root access too.
:)
Image
Please edit your original post title to include [SOLVED] - when your problem is solved!
and DO LOOK at those Unanswered Topics - - you may be able to answer some!.
rene
Level 20
Level 20
Posts: 12240
Joined: Sun Mar 27, 2016 6:58 pm

Re: [SOLVED] Change prompt colour in the terminal

Post by rene »

Pierre wrote: Tue Jun 19, 2018 8:08 am EDIT: yep - - it's still the same & needs /root access too.
That should not be the case; ~/.bashrc needs to be user owned. I.e., for both of you, please run sudo chown $(whoami) ~/.bashrc and do not edit it as root.

... and as to /etc/skel being empty: I trust it won't be: try ls -la /etc/skel to also show dot-files: cp /etc/skel/.bashrc ~/ to copy a fresh one to your home directory (make sure you are not overwriting a tweaked one already present as ~/.bashrc).
rene
Level 20
Level 20
Posts: 12240
Joined: Sun Mar 27, 2016 6:58 pm

Re: [SOLVED] Change prompt colour in the terminal

Post by rene »

Believe I was mostly addressing Snafu in the above; you guys having the same identifying "avatar" made things slightly confusing. Just now read a bit closer and the deal here is...

The files in /etc/skel are not themselves system files; are not in fact even used directly. The contents of /etc/skel is copied to a new user's home directory when creating said new user. This provides for a way to customize default per-user settings and, other than being available for you as the system administrator, is in fact already used in that manner as well by Mint: can't check 19 now, but see e.g. /etc/skel/.mozila for 18.

In any case, as such it is expected that the files in /etc/skel are root-owned; their copies in your home directory should still be user-owned. The suggested simple cp /etc/skel/.bashrc ~/ (as your user, of course) arranges for such. Editing the files in /etc/skel has effect only after creating a new user or a manual such copy; the ones to edit to provide for "immediate" effect are in your home directory ("immediate" between quotes since in the case of for example .bashrc you'd of course need to relaunch bash/your terminal).

The fact that you don't have a ~/.bashrc on 18 makes it likely that you upgraded that system from 17 while keeping your home directory. In 17 there wasn't yet a .bashrc; things were arranged directly through .profile IIRC. So as to adhere to Mint 18 standards, you "should" manually copy it to your home directory...
User avatar
Snafu
Level 2
Level 2
Posts: 65
Joined: Tue Mar 13, 2018 7:01 am
Location: Australia

Re: [SOLVED] Change prompt colour in the terminal

Post by Snafu »

/etc/skel is still empty, I just checked it again, but since everything is working I'll just leave it alone. When I fiddle things break...
But thanks for your input rene, if I have an issue adding another user at least I'll know where to look
When all else fails follow the instructions
rene
Level 20
Level 20
Posts: 12240
Joined: Sun Mar 27, 2016 6:58 pm

Re: [SOLVED] Change prompt colour in the terminal

Post by rene »

Snafu wrote: Sun Jun 24, 2018 8:37 am /etc/skel is still empty [ ... ]
Still don't believe that :) If you are checking with a file manager, have you set it to "show hidden files" (through the menus, or Ctrl-H I believe; not at a Mint system now)? If from the command line, did you use ls -la /etc/skel? The "a" option to ls has it show all files.

Other then that, as you say, if all's working, all's well...
User avatar
Snafu
Level 2
Level 2
Posts: 65
Joined: Tue Mar 13, 2018 7:01 am
Location: Australia

Re: [SOLVED] Change prompt colour in the terminal

Post by Snafu »

If you are checking with a file manager, have you set it to "show hidden files" (t
Ah well that would explain it then. I was simply opening the folder and having a look. Cheers
When all else fails follow the instructions
Locked

Return to “Scripts & Bash”