You are not logged in.

#1 2020-04-07 06:05:13

fmash
Member
Registered: 2020-04-06
Posts: 3

[SOLVED] urxvt shows bash prompt twice

I have installed arch yesterday and using urxvt as terminal, which I have been using previously on my debian machine. The default urxvt shows only one prompt as per the PS1 variable like below:
https://imgur.com/WuI5R3C

But after I reload the terminal copying over my .Xresources file from my debian machine to the arch, it shows two bash prompts one after another like the following:
https://imgur.com/jtdyASV

The 2nd prompt follows the PS1 variable, but I cannot figure out where the 1st prompt is coming from. Inside a tmux session, it shows a single prompt correctly though. Any help would be appreciated.
I am using i3-gaps on xorg.

My .bashrc file:

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '

# Custom alias
alias ll='ls -l'
alias la='ls -a'

My .Xresources file:

URxvt*termName:  screen-256color
URxvt*loginShell:  true

! Perl extensions
URxvt.perl-ext-common: eval,default,matcher,resize-font

! Enables copu,paste feature using eval extension that ships with rxvt-unicode
URxvt.keysym.Shift-Control-V: eval:paste_clipboard
URxvt.keysym.Shift-Control-C: eval:selection_to_clipboard

! Open links in firefox
! URxvt.perl-ext-common : default,matcher
URxvt.urlLauncher     : firefox
URxvt.matcher.button  : 1

! Change the font size on the go
! URxvt.perl-ext-common: resize-font

! Disables ISO 14755 mode on pressing C-Shift
URxvt.iso14755: false
URxvt.iso14755_52: false


URxvt*font: xft:Fira Code:style=Medium:pixelsize=14,xft:Font Awesome 5 Free:style=Regular:pixelsize=14,xft:PowerlineSymbols:style=Medium:pixelsize=14
URxvt.letterSpace: -1
Xft*dpi: 98
Xft*antialias: true
Xft*hinting: true
Xft*hintstyle: hintfull
Xft*rgba: rgb

urxvt*scrollBar: false
! foreground/background
URxvt*background: #424242
URxvt*foreground: #ffffff
urxvt.transparent: true
urxvt*shading: 15
URxvt*tintColor: #ffffff

! URxvt*geometry: 85x20
*internalBorder: 5

! special
URxvt.cursorColor: #D8D8D8
*.cursorBlink: true
*.cursorUnderline: false

!black
*color0:#1c1c1c
*color8:#4d4d4d
!red
urxvt.color1:#d17b49
urxvt.color9:#d17b49
!green
urxvt.color2:#ffbf00
urxvt.color10:#ffbf00
!yellow
urxvt.color3:#af865a
urxvt.color11:#af865a
!blue
urxvt.color4:#81f7be
urxvt.color12:#81f7be
!magenta
urxvt.color5:#f7819f
!775759
urxvt.color13:#f7819f
!cyan
urxvt.color6:#6d715e
urxvt.color14:#6d715e
!white
urxvt.color7:#c0b18b
URxvt.color15:#bdbdbd

Last edited by fmash (2020-04-07 18:04:06)

Offline

#2 2020-04-07 17:00:52

Soul
Member
Registered: 2019-07-08
Posts: 9

Re: [SOLVED] urxvt shows bash prompt twice

This issue may be related to a default setting of PROMPT_COMMAND in bash, which can be used to execute a command before showing the prompt (e.g., to set some variables).
I had a similar problem, and it turned out PROMPT_COMMAND was echoing its own prompt, causing the double prompt when PS1 was also printed afterwards.
To fix it, you can either override PROMPT_COMMAND in your .bashrc or find the source of the setting and change it there (try the /etc directory).
Here's more info on what you can do with PROMPT_COMMAND: https://stackoverflow.com/questions/305 … pt-command.

man bash

has even more information on configuration with shell variables.


"This quote is often falsely attributed to Mark Twain" -- Randall Munroe

Offline

#3 2020-04-07 17:18:49

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,522
Website

Re: [SOLVED] urxvt shows bash prompt twice

The problem is PROMPT_COMMAND, but not because it is trying to print to the screen, but rather than it is trying to set the window title.  Some change you made resulted in the ansi sequences for setting the title get ignored resulting in the output going to the stdout or screen.

EDIT: here's the problem:

URxvt*termName:  screen-256color

Why do you set that at all, and specifically to screen when you are not using screen??

Last edited by Trilby (2020-04-07 17:19:26)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2020-04-07 18:02:07

fmash
Member
Registered: 2020-04-06
Posts: 3

Re: [SOLVED] urxvt shows bash prompt twice

Trilby wrote:

The problem is PROMPT_COMMAND, but not because it is trying to print to the screen, but rather than it is trying to set the window title.  Some change you made resulted in the ansi sequences for setting the title get ignored resulting in the output going to the stdout or screen.

EDIT: here's the problem:

URxvt*termName:  screen-256color

Why do you set that at all, and specifically to screen when you are not using screen??

Thanks! Removing the termName solved the problem.

I set the default-terminal in my tmux.conf to screen-256 to show the correct 256 term colors(?) according to a post. I switched to urxvt lately from gnome-terminal. I was checking out urxvt configurations and set the termName to rxvt and it messed up my statusline colors on tmux, so I changed the termName to screen-256 and that fixed that. Now, I'm seeing that removing the line completely works, with tmux as well. It doesn't cause a problem on my debian machine because the TERM_COMMAND variable is not set, but it is set on my arch to print a prompt, which I found out now.

Last edited by fmash (2020-04-07 18:24:53)

Offline

#5 2020-04-07 18:13:36

fmash
Member
Registered: 2020-04-06
Posts: 3

Re: [SOLVED] urxvt shows bash prompt twice

Soul wrote:

This issue may be related to a default setting of PROMPT_COMMAND in bash, which can be used to execute a command before showing the prompt (e.g., to set some variables).
I had a similar problem, and it turned out PROMPT_COMMAND was echoing its own prompt, causing the double prompt when PS1 was also printed afterwards.
To fix it, you can either override PROMPT_COMMAND in your .bashrc or find the source of the setting and change it there (try the /etc directory).
Here's more info on what you can do with PROMPT_COMMAND: https://stackoverflow.com/questions/305 … pt-command.

man bash

has even more information on configuration with shell variables.

Thanks! This too solves it.
I didn't know about this PROMPT_COMMAND variable, and it was in fact showing its own prompt. Overriding this variable removes it. But only setting the TERM name to screen-256 executes the command stored in the variable. Cannot figure out why.

Last edited by fmash (2020-04-07 18:19:07)

Offline

Board footer

Powered by FluxBB