[opensuse] Work from the cli? Your prompt should help.
Listmates, Here is a stray though for your prompt. If you do any amount of work from the command line in konsole, x-term, etc..., then your prompt should help you get work done. Why prompts tonight?? Who knows, but... Where virtually everything requires a copy, move, ssh, rsync, scp, etc.. why not have 1/2 the work already done by your prompt? The simple prompt I consider indispensable looks like this: As user: 20:42 alchemy:~/linux/scripts/config/zypp> As root: [20:44 alchemy:/home/david/linux/scripts/config/zypp] # The first element in both is just the time and can be ignored for purposes of this discussion. What you also can't see -- is the user prompt time is lightgray and the text of the prompt is lightblue, for root, time is lightred, host is lightblue and text of the prompt is red. The colors work fine on light or dark backgrounds. [1.] Small png of both prompts: http://www.3111skyline.com/images/prompt.png The beauty of the prompt is the format of: hostname:/path/to/pwd. Which is also the format required by rsyc and scp and the path information works with every other bash command. This really makes life easier in tabbed consoles like 'konsole' in KDE when working between a local and remote system or between 2 remote systems where switching between hosts (tabs) is as simple at [shift]+[left/right]. rsync or scp then becomes the simple matter of (a) copy current host:/path from prompt (b) [shift]+[left/right] to change consoles, (c) type 'rsync -options' [middle-click] paste of host:/path information, (d) type or copy 'filename .', and your done (without typos) Of couse where there is no path information, simply typing is faster, but when you need to do a rsync pull from 21:47 nirvana:/srv/www/download/linux/scripts/utils/filename.ext, I prefer the [select]+[middle-mouse-paste] method any day. Setting the prompts are simple enough. From the command line, the user prompt is: PS1="\[\e[0;37m\]\A\[\e[1;34m\] \[\e[1;34m\]\h:\w> \[\e[0m\]" Root prompt is: PS1="\[\e[1;34m\][\[\e[1;31m\]\A \[\e[1;34m\]\h\[\e[0;31m\]:\w\[\e[1;34m\]] # \[\e[0m\]" In your .bashrc to set the prompt so it is your default, just add export in front of it like this: export PS1="\[\e[0;37m\]\A\[\e[1;34m\] \[\e[1;34m\]\h:\w> \[\e[0m\]" (**Note: you will rarely find the /A prompt option documented for whatever reason. It is just the time for the record) You can also set the secondary prompt PS2 in the same manner, but I have never found a use for this. The default '>' is just fine for all purposes. Additionally, what I've found is that the over-use of colors or other fancyness quickly becomes more annoying than useful. But, if you want to experiment, then: It's possible to add special codes to your prompt that will cause the title bar of your X terminal (such as rxvt or aterm) to be dynamically updated. All you need to do is add the following sequence to your PS1 prompt: "\e]2;titlebar\a" Simply replace the substring "titlebar" with the text that you'd like to have appear in your xterm's title bar. For example, to put the time, host and path information in the konsole titlebar as well as in your prompt, use: PS1="\[\e]2;\A \h:\w\a\[\e[0;37m\]\A\[\e[1;34m\] \[\e[1;34m\]\h:\w> \[\e[0m\]" And... yes, the time and path information will update dynamically. (neat trick. Usefulness??) For additional information and a quick reference to the color codes and prompt codes, I cobbled together a simple page at: http://www.3111skyline.com/linux/bash-prompt.php ========== [1.] You can use any color you like, but I want something that works on a light or dark background. I generally work in a dark semi-transparent konsole schema with "linux-colors" like layout. -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Hello, On Sun, 29 Mar 2009, David C. Rankin wrote: [..]
export PS1="\[\e[0;37m\]\A\[\e[1;34m\] \[\e[1;34m\]\h:\w> \[\e[0m\]"
(**Note: you will rarely find the /A prompt option documented for whatever reason. It is just the time for the record)
man bash (2.03) documents \t, \T and \@, man bash (3.2) documents \A and \D{format} as well, both in Section "PROMPTING". And there's also the Bash-Prompt-HOWTO and man console_codes. -dnh -- Good day to avoid cops. Crawl to school. -- BSD fortune file -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
David Haller wrote:
Hello,
On Sun, 29 Mar 2009, David C. Rankin wrote: [..]
export PS1="\[\e[0;37m\]\A\[\e[1;34m\] \[\e[1;34m\]\h:\w> \[\e[0m\]"
(**Note: you will rarely find the /A prompt option documented for whatever reason. It is just the time for the record)
man bash (2.03) documents \t, \T and \@, man bash (3.2) documents \A and \D{format} as well, both in Section "PROMPTING".
And there's also the Bash-Prompt-HOWTO and man console_codes.
-dnh
Yep David, I got the reference to the \A from man bash (1891 lines down) Few dare to go there, it's just not safe;-) -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (3)
-
David C. Rankin
-
David Haller
-
Michael S. Dunsavage