FedoraForum.org - Fedora Support Forums and Community
Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    533

    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.

  2. #2
    Join Date
    Nov 2008
    Posts
    327

    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.

  3. #3
    Join Date
    Oct 2011
    Posts
    1,616

    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"

  4. #4
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    533

    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"

  5. #5
    Join Date
    Nov 2008
    Posts
    327

    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.

  6. #6
    Join Date
    Oct 2011
    Posts
    1,616

    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.

  7. #7
    Join Date
    Nov 2006
    Location
    Detroit
    Posts
    6,661

    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 27 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

  8. #8
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    533

    Re: lxterminal --title preventing PROMPT_COMMAND or PS1 etc

    Quote Originally Posted by RupertPupkin
    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.

  9. #9
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    533

    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

Similar Threads

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •