LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-25-2013, 05:17 PM   #1
CrackerPunk
LQ Newbie
 
Registered: Aug 2013
Location: New Jersey
Distribution: FreeBSD 9.1 | Slackware 13
Posts: 17

Rep: Reputation: Disabled
Do you customize your shell prompt


hi

Do you customize your shell prompt or do you keep the default setup. I personally like to keep the shell prompt very simple looking.

I use the \W and the percent symbol % to simulate an old style unix terminal. Below is how my shell prompt looks.

[~] %
 
Old 08-25-2013, 05:40 PM   #2
ozar
Member
 
Registered: May 2004
Location: USA
Distribution: Arch Linux
Posts: 415

Rep: Reputation: 85
Hello

I do customize it after installing a couple of distros, CRUX being one example. Otherwise, I generally go with the default prompt for most distros.
 
Old 08-25-2013, 05:54 PM   #3
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
I do. Usually it shows my username, the current directory and a green smiley (or red sad smiley, dependent if the last command returned an error code). When I SSH into one of my other machines it also shows the hostname.
 
Old 08-25-2013, 08:09 PM   #4
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,324
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
I like to see the current directory in my prompt.
 
Old 08-25-2013, 08:21 PM   #5
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,264
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
I too, like to see the current directory in my prompt.

I also color the prompt for remote logins, different colors for each host, and always make root prompt red.
 
Old 08-25-2013, 08:38 PM   #6
fogpipe
Member
 
Registered: Mar 2011
Distribution: Slackware 64 -current,
Posts: 550

Rep: Reputation: 196Reputation: 196
Code:
PS1="[\[\033[1;32m\]\u\[\033[1;31m\]@\[\033[1;34m\]\h\[\033[1;31m\]\[\033[0;32m\]\[\033[1;35m\]:\W\[\033[0m\]]\[\033[0;31m\]$\[\033[0m\]"

Thats what i have been using for a few years. Shows the working dir and i adjust for different colors for different machines and have "root" appear in red. I never use the default prompt.

I also echo the host and working dir in term window title bars.
 
Old 08-26-2013, 06:10 AM   #7
kooru
Senior Member
 
Registered: Sep 2012
Posts: 1,385

Rep: Reputation: 275Reputation: 275Reputation: 275
Quote:
Originally Posted by frankbell View Post
I like to see the current directory in my prompt.
i too
 
Old 08-26-2013, 06:33 AM   #8
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
I use the default as long as it is short. Using the current directory is useful if your terminal doesn't already tell you, however it's too long for me.
 
Old 08-26-2013, 06:40 AM   #9
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Yep, prompt is blue for normal users and red for root.

Prompt shows the following info: [hostname] username path $ (or # if root)
 
Old 08-26-2013, 06:44 AM   #10
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by H_TeXMeX_H View Post
I use the default as long as it is short. Using the current directory is useful if your terminal doesn't already tell you, however it's too long for me.
I have configured it in that way that the full path is only displayed if it is not more than 3 subdirectories long, if it is longer only the name of the current directory is displayed.
 
Old 08-26-2013, 10:05 AM   #11
CrackerPunk
LQ Newbie
 
Registered: Aug 2013
Location: New Jersey
Distribution: FreeBSD 9.1 | Slackware 13
Posts: 17

Original Poster
Rep: Reputation: Disabled
My PS1 only shows the current working directory because I hate long paths. However you can control how deep into the directory you want display using the system variable PROMPT_DIRTRIM. I will demonstrate with a example

Code:
export PROMPT_DIRTRIM=3

cd TEST/dir1/dir2/dir3/dir4/dir5

[~/.../dir3/dir4/dir5] %
As you can see, it trim the path to just 3 directories. If you want two directories, then

Code:
export PROMPT_DIRTRIM=2
[~/.../dir4/dir5] %
This is not permanentm it will expire when you close the terminal. To make it permanent add it to your .bashrc file

Last edited by CrackerPunk; 08-26-2013 at 10:08 AM.
 
Old 08-26-2013, 10:24 AM   #12
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
I like mine a bit Fancy.

Code:
PS1='\e[0;31m(\e[1;31m\u\e[0;37m@\e[1;37m\h\e[0;31m)-(\e[0;37m\@ \e[1;37m\d\e[0;31m)-(\e[0;31m\w\e[0;31m)\e[0;31m\n\e[1;37m\$ \e[1;31m>\e[0;37m'
Which gives me this:



There is never any doubt as to which server I am on, who i am logged in as, and what directory i am in.
 
Old 08-26-2013, 10:37 AM   #13
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by CrackerPunk View Post
My PS1 only shows the current working directory because I hate long paths. However you can control how deep into the directory you want display using the system variable PROMPT_DIRTRIM. I will demonstrate with a example

Code:
export PROMPT_DIRTRIM=3

cd TEST/dir1/dir2/dir3/dir4/dir5

[~/.../dir3/dir4/dir5] %
As you can see, it trim the path to just 3 directories. If you want two directories, then

Code:
export PROMPT_DIRTRIM=2
[~/.../dir4/dir5] %
This is not permanentm it will expire when you close the terminal. To make it permanent add it to your .bashrc file
Does not work on Zsh. Keep in mind that not all people use Bash.
 
Old 08-26-2013, 11:31 AM   #14
CrackerPunk
LQ Newbie
 
Registered: Aug 2013
Location: New Jersey
Distribution: FreeBSD 9.1 | Slackware 13
Posts: 17

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TobiSGD View Post
Does not work on Zsh. Keep in mind that not all people use Bash.
Didn't know that. But the majority of linux users do use bash

I think zsh or other shells can do something similar I presumed
 
Old 08-26-2013, 01:41 PM   #15
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
DOS='C:${PWD//\//\\\}>'
PS1="\[\033[00m\]\[\033[00m\]\[\033[01;39m\]$DOS\[\033[00m\]"
C:\home\jj>
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
passing parameters from a unix shell prompt into a windows cmd.exe prompt nano2 Programming 1 09-01-2009 11:26 AM
LXer: Shell tip: Set the shell prompt and themes in Linux Terminal LXer Syndicated Linux News 0 06-12-2007 03:02 AM
LXer: Customize Your Shell LXer Syndicated Linux News 0 05-31-2007 01:16 AM
Different name at shell prompt XJNick Linux - General 3 08-25-2005 10:20 AM
Customize BASH Prompt kleptos Linux - Newbie 15 01-02-2003 12:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration