BASH: Getting titlebar and prompt to 'sync up'


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting BASH: Getting titlebar and prompt to 'sync up'
# 1  
Old 09-08-2010
BASH: Getting titlebar and prompt to 'sync up'

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 them again as a starting point. Now I'm attempting to restore the prompt and titlebar customization that I had working in my more-recent set of config files.

Just as an FYI and to make sure we're all on the same page here: I use rxvt for Cygwin; for a long while, my preference has been to display the basename of the current working directory in the titlebar, and the full path in the prompt, "where there's more space to waste." Up to this moment, I've been able to set the titlebar to dynamically change on every cd command, but the prompt still shows whatever path the session began with, such as the home folder or the directory pointed to by a "Bash Here" contextual menu command or, otherwise, one custom batch script I retained from the config-trashing debacle.

The code in my .bash_profile looks like this:
Code:
case "$TERM" in
xterm*|rxvt*|rxvt-unicode*)
	export PS1="\e]2;\W - Cygwin\a\n${PWD}\n$TERM-cygwin>> "
        ;;
*)
       PROMPT_COMMAND='echo -e "\033]0;$TERM: ${PWD}\007"'
        ;;
esac

where everything (on the EXPORT line) before the \a sets the titlebar as I want it. However the same line's ${PWD}, for reasons I'm sure I know but have (for the time being at least) forgotten, isn't getting updated on execution of a cd command. I also am quite aware that all of this should be in discrete lines, for instance a PROMPT_COMMAND and a TITLEBAR variable in a function, rather than part of an export PS1="". However, trying the same syntax in the former has only resulted in a hanging cursor and no prompt whatsoever on starting a session.

And I'd like to have them 'sync-up.' I know it's possible because I had it working before the 'accident.'

Hope someone can help.

BZT

---------- Post updated at 20:02 ---------- Previous update was at 19:20 ----------

I saw, just now, where I was going wrong.
The EXPORT line (okay as it was) was off by one detail. The way to get the prompt to update 'on-the-fly' was not to use $PWD or any variation of it, but rather to use the character sequence \W. I typed that into my .bash_profile, source'd it from an open rxvt session and got the 'right look.' To make absolutely sure, I cd'd to another folder and watched both prompt and titlebar change.

It's usually the simple stuff, innit?

BZT
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Bash prompt is over lapping

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

2. Shell Programming and Scripting

Running an executable from bash prompt

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

3. Shell Programming and Scripting

How to (GUI) prompt for password from bash?

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

4. UNIX for Dummies Questions & Answers

Renaming terminal window titlebar

Could someone please inform me of how to permanently change the titlebar name in terminal windows on solaris. I know how to do the xterm and all that but I need it so anytime anyone opens the terminal window it says something i want it too instead of "terminal". Thanks for any help. (1 Reply)
Discussion started by: amason0508
1 Replies

5. Emergency UNIX and Linux Support

Bash answer prompt

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

6. OS X (Apple)

Bash prompt wraparound

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

7. UNIX for Advanced & Expert Users

Bash conditional prompt?

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

8. Shell Programming and Scripting

How can i change my bash prompt ?

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

9. UNIX for Dummies Questions & Answers

Terminal titlebar

I find website that give solution about changing terminal titlebar: 32) How can I change the titlebar of my terminal window? but I use SCO Unix openserver 5.0.5, I can't find xterm or maybe I don't know where xterm locate. Anyone knows how to change terminal titlebar for my unix terminal. (2 Replies)
Discussion started by: wendyz
2 Replies

10. UNIX for Dummies Questions & Answers

customize my prompt in bash

in csh I was using: set prompt=""$HOSTNAME".tk.\!> " to customize the look of my prompt. I have seen the light after reading the perils of csh scripting and wish to switch to bash. How do I customize my bash prompt??? I've tried many variation of the above w/no success, and searching this... (2 Replies)
Discussion started by: yankee428
2 Replies
Login or Register to Ask a Question