06-23-2005
My Bash Prompt
In bash there are several shortcuts you can use. My prompt looks like this:
PS1="[\u@\h \w]\$ "
which produces
[username@server workingdir]$
You can add color to them as well. There are a number of variables you may use in bash.
\a Alarm (Bell)
\d Date in fomat "Wed Jun 21"
\h Hostname
\j Jobs (Number of Background jobs)
\l Current Terminal Name
\n Newline inserted into prompt. (Usefull for 2-line prompts)
\r Carriage return in prompt
\s Current Shell
\t Time in 24 hour format, 16:25:00
\T Time in 12 hour format, 04:25:00
\u User's account name
\v Version and release of bash
\w Current working directory (full path /home/bill/.mozilla)
\W Last element of Working directory (.mozilla)
\V Version, release and patch level of bash
\\ single backslash inserted into prompt
\! Number of current command in command history
\# Number of current command where numbers start at 1 when shell starts
\A Time in 24 hour format without seconds 16:25
\@ Time in 12 hour format without seconds, 04:25 p.m.
\$ indicates root. display $ when not root and # when root.
\[ starts a sequence of non printing characters ending with \] (explanation to follow)
\nnn the character in ascii set coresponding to the octal number nnn
The last two commands can add color to the prompt. For example,
\[\033[1;36m\] changes the color to a light blue. \[\033[0m\] changes it to back to off-white. On a standard black background, white letters I use
PS1="[\[\033[1;36m\]\u\[\033[0m\]@\[\033[1;35m\]\h \[\033[1;32m\]\w\[\033[0m\]]\$ "
which gives me
[bill@server /usr/local/bin]$
The color changes are confusing, I know, but I like it.
;
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I'm trying to use unison from bash on windows with cygwin. I don't know if this is a cygwin question, bash question or unison question. Since I always get reprimanded by the cygwin mailing list for assuming it is a cygwin problem, I'll assume it is a bash question.
The following commands work... (7 Replies)
Discussion started by: siegfried
7 Replies
2. Shell Programming and Scripting
It looks like,
user@hostname:/auto/home3/user$
Desired,
user@hostname$
I added following line in .bashrc, but still its same.
export PS1=" $ "
Please help me :confused: (13 Replies)
Discussion started by: admax
13 Replies
3. UNIX for Advanced & Expert Users
Hi,
Does anyone know any way of making bash prompt extended with conditional content?
Example:
export PS1="] && echo '#' || echo '\$'" # This won't work - prompt is not executed
# export PS1="\$" # This is an existing but also working equivalent
I would like to use more complex... (8 Replies)
Discussion started by: adderek
8 Replies
4. OS X (Apple)
I'm using a custom prompt with PS1 in my .profile. It is
PS1="\\u@\e\:\W\ \\$\ \"
and it works well, as you can see,
http://content.screencast.com/users/killer54291/folders/Jing/media/2b3db52a-ebf7-43e2-95cc-f45dadbc2b98/00000023.png
but, when i type more than the width of the window, it... (0 Replies)
Discussion started by: killer54291
0 Replies
5. Shell Programming and Scripting
This is an instance of "if it's not one thing, it's another."
I recently fell victim to my own stupidity in trashing, by accident, my long-running and very highly-customized .bash_profile and .bashrc files for Cygwin & Cygwin/X. I had backups from a previous "go" with this, and decided to use... (0 Replies)
Discussion started by: SilversleevesX
0 Replies
6. Emergency UNIX and Linux Support
I am working with a script to simplyfy some operations where I work, but one of the programs needs me to enter a password.
It will as me "Please enter the administrator password:"
Is there a way to make a bash script to automatically answer the question with the needed password?
I am looking... (3 Replies)
Discussion started by: noratx
3 Replies
7. Shell Programming and Scripting
I remember there was a gnome only command that we could insert in a bash script to mount a Linux disk that would pop up a little window to grab a password.
I know there are bash commands to read a string but they are not GUIs and they echo the characters typed. This gnome command popped up a... (1 Reply)
Discussion started by: siegfried
1 Replies
8. Shell Programming and Scripting
Hi,
I'm trying to run a program from the bash prompt and I don't understand why it is returning with an error.
Dig is my C program, and it takes in parameters J4, detect, 3 and 0182F98E
var1="cygdrive/c/2i/test fixture/software/mccdaqtest/debug/Dig J4 detect 3 0182F98E"
when I do
... (6 Replies)
Discussion started by: oahmad
6 Replies
9. UNIX for Dummies Questions & Answers
Hello Guys,
I have facing problem with linux shell prompt .Am expecting my Bash prompt to be like below
but its showing like
~]$ ot@Servername and while typing the commands the prompt looks like below:
~]$ echo $PS1
$
~]$ ot@ServernameChecked the .bash_profile and also changed... (9 Replies)
Discussion started by: kapil514
9 Replies
10. Shell Programming and Scripting
I use the .bashrc file from this thread.
Direct link to the archive containing the ultimate bashrc
I am trying to use autojump, but it will not autoload the directories to the autojump list as the custom prompt is not compatible.
Here is the thread on the issue from other users.
apt -... (2 Replies)
Discussion started by: genehunter
2 Replies
MSH(1) [nmh-1.5] MSH(1)
NAME
msh - nmh shell (and BBoard reader)
SYNOPSIS
msh [-prompt string] [-scan | -noscan] [-topcur | -notopcur] [file] [-version] [-help]
DESCRIPTION
msh is an interactive program that implements a subset of the normal nmh commands operating on a single file in packf'dformat. That is,
msh is used to read a file that contains a number of messages, as opposed to the standard nmh style of reading a number of files, each file
being a separate message in a folder. msh's chief advantage is that the normal nmh style does not allow a file to have more than one mes-
sage in it. Hence, msh is ideal for reading BBoards, as these files are delivered by the transport system in this format. In addition,
msh can be used on other files, such as message archives which have been packed (see packf(1)). Finally, msh is an excellent nmh tutor.
As the only commands available to the user are nmh commands, this allows nmh beginners to concentrate on how commands to nmh are formed and
(more or less) what they mean.
When invoked, msh reads the named file, and enters a command loop. The user may type most of the normal nmh commands. The syntax and
semantics of these commands typed to msh are identical to their nmh counterparts. In cases where the nature of msh would be inconsistent
(e.g., specifying a +folder with some commands), msh will duly inform the user. The commands that msh currently supports (in some slightly
modified or restricted forms) are:
ali
burst
comp
dist
folder
forw
inc
mark
mhmail
mhn
msgchk
next
packf
pick
prev
refile
repl
rmm
scan
send
show
sortm
whatnow
whom
In addition, msh has a help command which gives a brief overview. To terminate msh, type CTRL-D, or use the quit command.
If the file is writable and has been modified, then using quit will query the user if the file should be updated.
The -prompt string switch sets the prompting string for msh.
You may wish to use an alternate nmh profile for the commands that msh executes; see mh-profile(5) for details about the $MH environment
variable.
The exit command is identical to the quit command in msh.
msh supports an output redirection facility. Commands may be followed by one of
^> file~^write output to file
^>> file~^append output to file
^| command~^pipe output to UNIX command
If file starts with a " " (tilde), then a csh-like expansion takes place. Note that command is interpreted by sh. Also note that msh does
NOT support history substitutions, variable substitutions, or alias substitutions.
When parsing commands to the left of any redirection symbol, msh will honor `' (back-slash) as the quote next-character symbol, and `"'
(double-quote) as quote-word delimiters. All other input tokens are separated by whitespace (spaces and tabs).
FILES
$HOME/.mh_profile The user profile
/etc/nmh/mts.conf nmh mts configuration file
PROFILE COMPONENTS
Path: To determine the user's nmh directory
Msg-Protect: To set mode when creating a new `file'
fileproc: Program to file messages
showproc: Program to show messages
SEE ALSO
packf(1)
DEFAULTS
`file' defaults to "./msgbox"
`-prompt (msh) '
`-noscan'
`-notopcur'
CONTEXT
None
BUGS
The argument to the -prompt switch must be interpreted as a single token by the shell that invokes msh. Therefore, one must usually place
the argument to this switch inside double-quotes.
There is a strict limit of messages per file in packf'd format which msh can handle. Usually, this limit is 1000 messages.
Please remember that msh is not the C-Shell, and that a lot of the nice facilities provided by the latter are not present in the former.
In particular, msh does not understand back-quoting, so the only effective way to use pick inside msh is to always use the -seq select
switch. Clever users of nmh will put the line
pick: -seq select -list
in their .mh_profile file so that pick works equally well from both the shell and msh.
sortm always uses -noverbose and if -textfield field is used, -limit 0.
The msh program inherits most (if not all) of the bugs from the nmh commands it implements.
MH.6.8 11 June 2012 MSH(1)