Jump to content


Custom Bash Prompts


  • Please log in to reply
35 replies to this topic

#1 ONLINE   V.T. Eric Layton

V.T. Eric Layton

    Nocturnal Slacker

  • Forum Admins
  • 17,156 posts

Posted 28 November 2009 - 01:21 AM

I got bored earlier today and tweaked the prompt on all my distros to look like these...

In Slackware:

vtel57_Slackware~:$
root_Slackware~:#

In Debian:

vtel57_Debian~:$
root_Debian~:#

In CentOS:

vtel57_CentOS:~$
root_CentOS:~#

Et cetera... you get the idea.

The ~ signifies the /home directory for the user. If I move to say /etc/X11, it would look like this:

vtel57_Slackware/etc/X11:$
root_Slackware/etc/X11:#

Cool, huh?  :rolleyes:

I used a combination of Bruno's Tweaking the Prompt tip and another script found elsewhere to colorize the root prompt. I had to tweak the .bashrc in /home/vtel57 and the .bashrc in /(root) to achieve this. Here are the mods I used:

/home/vtel57/.bashrc

Quote

# /home/vtel57/.bashrc# custom promptPS1="\u_<OS>\w:$ "

/(root).bashrc

Quote

# ~/.bashrc: executed by bash(1) for non-login shells.export PS1='\u_<OS>\w\:$ '# root prompt = redTERM_USER_HOST_COLOR='0;31m'TERM_PATH_COLOR='0;31m'TERM_PROMPT_COLOR='0;31m'TERM_USER_HOST='\u_<OS>'TERM_PATH='\w'TERM_PROMPT='\$'export PS1=\'\[\e['${TERM_USER_HOST_COLOR}'\]'${TERM_USER_HOST}'\[\e[m\]'\'\[\e['${TERM_PATH_COLOR}'\]'${TERM_PATH}'\[\e[m\]'\'\[\e['${TERM_PROMPT_COLOR}'\]:#\[\e[m\] '

Where you see "<OS>", I inserted my distribution name.

:rolleyes:  Yup... bored.
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image

#2 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 14,382 posts

Posted 28 November 2009 - 01:41 AM

Very cool!!!  I imagine that helps with all the distros you run on your machine. So you added that to the ~/.bashrc in all your partitions for user and root?Thanks
Posted ImagePosted Image Posted Image
Comhack.com/CNI Radio/G+ Profile/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#3 ONLINE   V.T. Eric Layton

V.T. Eric Layton

    Nocturnal Slacker

  • Forum Admins
  • 17,156 posts

Posted 28 November 2009 - 01:57 AM

Yup... and yes, it does help. Sometimes, I boot into a distro to tweak/update or whatever and forget where I'm at after a while. The red root prompt also alerts me that I'm root. It's a hard-to-miss visual reminder.
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image

#4 OFFLINE   jimg

jimg

    Post Master

  • Members
  • PipPipPipPip
  • 172 posts

Posted 28 November 2009 - 01:12 PM

You can also title your terminal windows.For instance, try
echo -ne "\033]0;Free Space\007";watch df
and you should get a terminal window titled Free Space.You can also put this into a function for use in a script:
title() {	echo -ne "\033]0;${1}\007"}
and then when your script can set the title as needed like this:title "Pass 1"(commands for pass 1)title "Pass 2"(commands for pass 2)I use this when I encode video so that I know generally where it is in the process.Tested on Ubuntu 64 bit - I assume that this should work on most of the others as well.

Edited by jimg, 28 November 2009 - 01:13 PM.


#5 ONLINE   V.T. Eric Layton

V.T. Eric Layton

    Nocturnal Slacker

  • Forum Admins
  • 17,156 posts

Posted 28 November 2009 - 03:56 PM

Pretty cool, Jim. Yeah, there's all kinds of neat stuff you can do with Linux. Ain't it wonderful?! ;)
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image

#6 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 14,382 posts

Posted 28 November 2009 - 08:07 PM

Thats pretty cool Jim. If I used window titles on my terminal, I would definitely use these scripts. Saved in Documents for future use. Thanks
Posted ImagePosted Image Posted Image
Comhack.com/CNI Radio/G+ Profile/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#7 ONLINE   V.T. Eric Layton

V.T. Eric Layton

    Nocturnal Slacker

  • Forum Admins
  • 17,156 posts

Posted 28 July 2012 - 02:26 PM

View Postsecuritybreach, on 28 November 2009 - 01:41 AM, said:

Very cool!!!  I imagine that helps with all the distros you run on your machine. So you added that to the ~/.bashrc in all your partitions for user and root?Thanks

By the way, custom user prompts and custom-colored root prompts that state the operating system are VERY handy when sshing. For example, if I'm on my shop system in Slackware and I ssh into my main system that is booted to Arch, my user prompt will change from vtel57_slackware~:$ to vtel57_arch~:$. It's even better with the red root prompt because you don't want to be making changes as root in an ssh environment only to realize later that you edited the file in your primary booted OS by accident.
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image

#8 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 14,382 posts

Posted 28 July 2012 - 02:36 PM

I do the same except I have my prompt showing different hostnames since I use the same username on most of my machines.
Posted ImagePosted Image Posted Image
Comhack.com/CNI Radio/G+ Profile/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#9 ONLINE   V.T. Eric Layton

V.T. Eric Layton

    Nocturnal Slacker

  • Forum Admins
  • 17,156 posts

Posted 28 July 2012 - 02:54 PM

That would work even gooder, actually. All my systems have unique host names also. Hmmmm... something to think about. :yes:
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image

#10 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 14,382 posts

Posted 28 July 2012 - 02:57 PM

Ex:
╔═ comhack@Cerberus 01:13 PM
╚═══ ~/ 

[comhack@DarkStar ~]$

Posted ImagePosted Image Posted Image
Comhack.com/CNI Radio/G+ Profile/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#11 ONLINE   V.T. Eric Layton

V.T. Eric Layton

    Nocturnal Slacker

  • Forum Admins
  • 17,156 posts

Posted 28 July 2012 - 02:58 PM

Is DarkStar a Slackware machine? ;)
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image

#12 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 14,382 posts

Posted 28 July 2012 - 03:04 PM

View PostV.T. Eric Layton, on 28 July 2012 - 02:58 PM, said:

Is DarkStar a Slackware machine? ;)

No but that is where I originally got the name. The hostname used to be a Slackware machine years ago but now it is my Arch machine on Linode VPS. I mostly use planet names for my other machines:

Cerbrus (main rig)
Neptune (Laptop)
Pluto (eeepc)
MiniMe (HP Mini)
Nitro (phone)
Mars (N810)
Baphomet (router/server)

The only ones I have not named yet are my HP Touchpad and my Nexus 7.

Oh, I forgot about my other laptop: Saturn
Posted ImagePosted Image Posted Image
Comhack.com/CNI Radio/G+ Profile/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#13 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 14,382 posts

Posted 28 July 2012 - 03:09 PM

It is pretty useful when you ssh in and ssh out from them all.
Posted ImagePosted Image Posted Image
Comhack.com/CNI Radio/G+ Profile/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#14 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 14,382 posts

Posted 28 July 2012 - 03:22 PM

Just gave my Nexus 7 a hostname:

Athena:

Quote

The goddess of wisdom, warfare, battle strategy, heroic endeavour, handicrafts and reason. According to most traditions, she was born from Zeus's head fully formed and armored. She was depicted crowned with a crested helm, armed with shield and a spear. Her symbol is the olive tree. She is commonly shown accompanied by her sacred animal, the owl.

http://en.wikipedia.org/wiki/Athena
Sorry to (sorta) get off topic...
Posted ImagePosted Image Posted Image
Comhack.com/CNI Radio/G+ Profile/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#15 ONLINE   V.T. Eric Layton

V.T. Eric Layton

    Nocturnal Slacker

  • Forum Admins
  • 17,156 posts

Posted 28 July 2012 - 04:00 PM

Cool! I have such unimaginative host names:

ericsbane05 - my main system
ericsshop02 - my shop system
ericslaptop01 - my Dell Inspiron 1521 home office laptop (the one you gave me :) )
jennieslaptop - the Dell Latitude D410 that my niece gave me
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image

#16 ONLINE   V.T. Eric Layton

V.T. Eric Layton

    Nocturnal Slacker

  • Forum Admins
  • 17,156 posts

Posted 30 July 2012 - 11:15 AM

Inspired by Josh's suggestion about using hostnames...

My new prompts:

vtel57@ericsbane05|Slackware~:$
root@ericsbane05|Slackware~:#

vtel57@ericsbane05|Arch~:$
root@ericsbane05|Arch~:#

vtel57@ericsslaptop01|Slackware~:$
root@ericslaptop01|Slackware~:#

vtel57@ericsshop02|Slackware~:$
root@ericsshop02|Slackware~:#

:)
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image

#17 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 14,382 posts

Posted 30 July 2012 - 11:26 AM

View PostV.T. Eric Layton, on 30 July 2012 - 11:15 AM, said:

Inspired by Josh's suggestion about using hostnames...

My new prompts:

vtel57@ericsbane05|Slackware~:$
root@ericsbane05|Slackware~:#

vtel57@ericsbane05|Arch~:$
root@ericsbane05|Arch~:#

vtel57@ericsslaptop01|Slackware~:$
root@ericslaptop01|Slackware~:#

vtel57@ericsshop02|Slackware~:$
root@ericsshop02|Slackware~:#

:)

Looks good but a bit long. If I were you, I would use something like:

vtel57@laptop|Slack~:$
vtel57@laptop|Arch~:$

vtel57@shop1(2)|Slack~:$
vtel57@shop1(2)|Arch~:$

No point in the Eric part as you already know who's machines they are :hysterical:
Posted ImagePosted Image Posted Image
Comhack.com/CNI Radio/G+ Profile/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#18 ONLINE   V.T. Eric Layton

V.T. Eric Layton

    Nocturnal Slacker

  • Forum Admins
  • 17,156 posts

Posted 30 July 2012 - 11:29 AM

It so the hackers know who's machines they are. ;)

You'll love my wifi network name: nocturnal.net :yes:
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image

#19 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 14,382 posts

Posted 30 July 2012 - 02:11 PM

Very cool, mine is 'Baphomet'.
Posted ImagePosted Image Posted Image
Comhack.com/CNI Radio/G+ Profile/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#20 ONLINE   V.T. Eric Layton

V.T. Eric Layton

    Nocturnal Slacker

  • Forum Admins
  • 17,156 posts

Posted 30 July 2012 - 02:42 PM

Ol' Bapho was an interesting fellow...

https://en.wikipedia.org/wiki/Baphomet
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image

#21 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 14,382 posts

Posted 30 July 2012 - 06:27 PM

View PostV.T. Eric Layton, on 30 July 2012 - 02:42 PM, said:

Ol' Bapho was an interesting fellow...

https://en.wikipedia.org/wiki/Baphomet

Indeed!! :thumbup:
Posted ImagePosted Image Posted Image
Comhack.com/CNI Radio/G+ Profile/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#22 OFFLINE   amenditman

amenditman

    Posting Prodigy

  • Members
  • PipPipPipPipPipPipPipPipPipPip
  • 2,186 posts

Posted 01 August 2012 - 06:02 PM

On all my systems I "fix" my bash prompt to be blue for normal user and red for root. Nothing fancy, but an effective visual clue to remind me not to do something stupid. When I see red, I stop and think before issuing a command.
Tweak it 'til it breaks, then learn how to fix it.  L.I.F.E. (Linux Is For Everyone)
Registered Linux User # 474004 (06/16/2008)

The HeliOS Project  -  B.O.D.
A Child's Exposure to Technology Should Never Be
  Predicated On The Ability To Afford It

#23 ONLINE   V.T. Eric Layton

V.T. Eric Layton

    Nocturnal Slacker

  • Forum Admins
  • 17,156 posts

Posted 01 August 2012 - 09:28 PM

Yup. Don't wanna' do stupid stuff.
Posted ImagePosted ImagePosted ImagePosted ImagePosted Image

#24 OFFLINE   securitybreach

securitybreach

    CLI Phreak

  • Forum Admins
  • 14,382 posts

Posted 01 August 2012 - 10:17 PM

Eh, I dunno. I have learned quite a lot from making mistakes. ;) B)
Posted ImagePosted Image Posted Image
Comhack.com/CNI Radio/G+ Profile/Configs/PGP Key π

"Do you begin to see, then, what kind of world we are creating? It is the exact opposite of the stupid hedonistic Utopias that the old reformers imagined. A world of fear and treachery and torment, a world of trampling and being trampled upon, a world which will grow not less but more merciless as it refines itself. Progress in our world will be progress toward more pain." -George Orwell, 1984

#25 OFFLINE   amenditman

amenditman

    Posting Prodigy

  • Members
  • PipPipPipPipPipPipPipPipPipPip
  • 2,186 posts

Posted 01 August 2012 - 10:56 PM

View Postsecuritybreach, on 01 August 2012 - 10:17 PM, said:

Eh, I dunno. I have learned quite a lot from making mistakes. ;) B)
Me too. (See my sig) o:)
Tweak it 'til it breaks, then learn how to fix it.  L.I.F.E. (Linux Is For Everyone)
Registered Linux User # 474004 (06/16/2008)

The HeliOS Project  -  B.O.D.
A Child's Exposure to Technology Should Never Be
  Predicated On The Ability To Afford It




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users