Fedora Linux Support Community & Resources Center
  #1  
Old 14th September 2017, 04:41 PM
HaydnH Offline
Registered User
 
Join Date: Feb 2005
Location: London, UK
Posts: 471
linuxfedorachrome
lxterminal --title preventing PROMPT_COMMAND or PS1 etc

Hi All,

When I'm programming I usually have 3 terminal windows, one on the left half of the screen, and 2 split horizontally on the right side. I thought I'd write a quick script to open the terminals where I want them from a key press, easy enough:

Code:
#!/bin/bash

COLS=130
ROWS=70
XPOS=0
YPOS=0

for i in 1 2 3; do
  lxterminal --title="code$i" --geometry=${COLS}x${ROWS}
  WID=""
  while [ "$WID" == "" ]; do 
    WID=$(xdotool search --name "code$i")
  done

  xdotool windowmove $WID $XPOS $YPOS

  COLS=90
  ROWS=37
  XPOS=1057
  if [ $i -eq 2 ]; then
    YPOS=593
    ROWS=30
  fi
done
However, using --title "foo" with lxterminal seems to break future updates to the window title by the PROMPT_COMMAND env variable. Please would someone check if that's true or if I have some other env variable or similar messing things up? i.e run "lxterminal --title=whatever" and see if it locks the title? Even "echo -ne "\033]0;[$(whoami)@$(hostname):$(pwd)]\007" or whatever doesn't work.
Reply With Quote
  #2  
Old 14th September 2017, 05:17 PM
dswaner Offline
Registered User
 
Join Date: Nov 2008
Posts: 281
linuxfedorafirefox
Re: lxterminal --title preventing PROMPT_COMMAND or PS1 etc

I'm using a gnome desktop and gnome terminal, so this may or may not be useful for you.

If you do a “which __vte_prompt_command”, it lists the __vte_prompt_command function.
Copy this function into .bashrc and modify it as you wish. This function's normal location is in /etc/profile.d/vte.sh, but the one in .bashrc overrides.
Reply With Quote
  #3  
Old 14th September 2017, 05:21 PM
srakitnican Offline
Registered User
 
Join Date: Oct 2011
Posts: 1,540
linuxchrome
Re: lxterminal --title preventing PROMPT_COMMAND or PS1 etc

Following might mess things up.
Code:
$ grep PROMPT_COMMAND /etc/profile.d/vte.sh 
    [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_prompt_command"
Reply With Quote
  #4  
Old 15th September 2017, 11:35 AM
HaydnH Offline
Registered User
 
Join Date: Feb 2005
Location: London, UK
Posts: 471
linuxfedorachrome
Re: lxterminal --title preventing PROMPT_COMMAND or PS1 etc

I already have a PROMPT_COMMAND set in .bashrc which isn't being overwritten, but lxterminal --title=foo seems to prevent it from working... maybe it's "intended"?

Code:
[haydn@darkstar ~]$ echo $PROMPT_COMMAND
echo -ne "\033]0;[$(whoami)@$(hostname):$(pwd)]\007"
Reply With Quote
  #5  
Old 15th September 2017, 12:54 PM
dswaner Offline
Registered User
 
Join Date: Nov 2008
Posts: 281
linuxfedorafirefox
Re: lxterminal --title preventing PROMPT_COMMAND or PS1 etc

When I do an "echo $PROMPT_COMMAND", it returns __vte_prompt_command. I'm not setting PROMPT_COMMAND anywhere. I've modified the printf line in the __vte_prompt_command function in .bashrc, to remove the USER and HOSTNAME specifications, and also the "@" and ":" literals, so that when I open a terminal tab, the title is just the full directory name. I've left root alone, so for root I still get the default titles, with USER and HOSTNAME. That's what is working for me, for gnome-terminal.
Reply With Quote
  #6  
Old 15th September 2017, 01:12 PM
srakitnican Offline
Registered User
 
Join Date: Oct 2011
Posts: 1,540
linuxchrome
Re: lxterminal --title preventing PROMPT_COMMAND or PS1 etc

Hmm maybe lxterminal is not using bash by default. Try typing bash after window appears and see if that fixes it.
Reply With Quote
  #7  
Old 15th September 2017, 11:28 PM
RupertPupkin Offline
Registered User
 
Join Date: Nov 2006
Location: Detroit
Posts: 6,637
linuxfedorafirefox
Re: lxterminal --title preventing PROMPT_COMMAND or PS1 etc

I was able to change the title by going to File -> New Tab, and then issuing the "echo -ne ..." command in one of the tabs (you can close the other tab). Seems like a bug in lxterminal.
__________________
OS: Fedora 26 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 7GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N
Reply With Quote
  #8  
Old 18th September 2017, 09:12 AM
HaydnH Offline
Registered User
 
Join Date: Feb 2005
Location: London, UK
Posts: 471
linuxfedorachrome
Re: lxterminal --title preventing PROMPT_COMMAND or PS1 etc

Quote:
Originally Posted by RupertPupkin View Post
I was able to change the title by going to File -> New Tab, and then issuing the "echo -ne ..." command in one of the tabs (you can close the other tab). Seems like a bug in lxterminal.
Interesting, thanks. At least I can send a new tab/switch tab/close tab key combo with xdotool as a workaround.
Reply With Quote
  #9  
Old 19th September 2017, 01:51 PM
HaydnH Offline
Registered User
 
Join Date: Feb 2005
Location: London, UK
Posts: 471
linuxfedorachrome
Re: lxterminal --title preventing PROMPT_COMMAND or PS1 etc

Well, I don't think I'd use this for anything production related, but for my desktop usage it actually works...

Code:
#!/bin/bash

COLS=130
ROWS=70
XPOS=0
YPOS=0

for i in 1 2 3; do
  lxterminal --title="code$i" --geometry=${COLS}x${ROWS}
  WID=""
  while [ "$WID" == "" ]; do
    WID=$(xdotool search --name "code$i")
  done

  sleep 0.1
  xdotool windowmove $WID $XPOS $YPOS
  sleep 0.1
  xdotool key $WID ctrl+shift+t
  sleep 0.1
  xdotool key $WID ctrl+Page_Up
  sleep 0.1
  xdotool key $WID ctrl+shift+w

  COLS=90
  ROWS=37
  XPOS=1057
  if [ $i -eq 2 ]; then
    YPOS=593
    ROWS=30
  fi
done
Reply With Quote
Reply

Tags
lxterminal, preventing, promptcommand, ps1, title

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Editing files in vi (LXTerminal) sslb lihou Using Fedora 1 27th January 2013 04:57 PM
lxterminal opens without prompt bookman Using Fedora 1 12th January 2013 06:33 PM
lxterminal default geometry staffordj Using Fedora 4 5th August 2012 09:37 PM
[SOLVED] VLC no title bar AlwaysNever Using Fedora 4 4th June 2011 05:28 AM
Prompt_command BLooDMaN Using Fedora 10 3rd May 2007 07:15 AM


Current GMT-time: 08:44 (Sunday, 24-09-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat