bash prompt and putty tweaking

Discussion about using NAS on Linux and Unix OS.
itteam
Getting the hang of things
Posts: 64
Joined: Thu Jul 25, 2013 1:25 am

bash prompt and putty tweaking

Post by itteam » Wed Apr 04, 2018 1:08 am

I have used this on RHEL and CentOS in my .bashrc
Provided by a cohort initially and tweaked to my liking.

Code: Select all

case $TERM in
   xterm*)
             PROMPT_COMMAND='echo -ne "\033]0;PROVIDER:hostname.myserver.tld: ${PWD}\007"'
            ;;
        *)
            ;;
esac

export PS1='\n\n[\d \t \u \w]\n\$ '


Instead of " 192.168.X.X - Putty " it titles my putty window with the datacenter (provider) and hostname and working directory like this:
" PROVIDER:hostname.myserver.tld: /home/root/monlogs "
and it gives me date time, my user, and working directory on my prompt line like this:
[Tue Apr 03 12:50:42 root /home/root/monlogs]

Both incredibly useful tidbits - facilitate navigation between several putty windows, and have a timestamp when you c/p any commands and results
BUT IT FAILS for me on the QNAP!
I do not know enough about the intricacies of the different Unix or shell flavors to fix it.
CAN YOU ?
[ TS-873U-RP @HQ ][ TS-220 + TS-221 +TS-419 U II @Satellite branches ] [ TS-212P + HS453-DX @Home ]

User avatar
OneCD
Ask me anything
Posts: 7968
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: bash prompt and putty tweaking

Post by OneCD » Wed Apr 04, 2018 7:24 am

Append your code to [/root/.profile] instead.

Note: changes to this file are not persistent, so you'll need to reapply this mod after each NAS reboot, or restore this file from a location such as your array.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage

itteam
Getting the hang of things
Posts: 64
Joined: Thu Jul 25, 2013 1:25 am

Re: bash prompt and putty tweaking

Post by itteam » Fri Apr 06, 2018 6:22 am

Thank you - that works!
[ TS-873U-RP @HQ ][ TS-220 + TS-221 +TS-419 U II @Satellite branches ] [ TS-212P + HS453-DX @Home ]

virtualdj
Experience counts
Posts: 1971
Joined: Wed May 26, 2010 2:44 am

Re: bash prompt and putty tweaking

Post by virtualdj » Fri May 31, 2019 12:31 am

Hi @OneCD, as I see that you're very skilled on the terminal configuration, can you suggest me why my old TS-231 (system #1) doesn't horizontally scroll the prompt and the "new" (actually it's old now... :cry: system #2) TS-453mini does not?

I mean:
Image
I would like to avoid horizontal scrolling, so just like #1.
I have:

Code: Select all

[~] # bind -v | grep horiz
set horizontal-scroll-mode off
set print-completions-horizontally off
... but Putty, as you can see, still scrolls. I've tried adding:

Code: Select all

set horizontal-scroll-mode off
to /etc/inputrc (which is my $INPUTRC) but it doesn't make any difference, maybe because it's already set.

User avatar
OneCD
Ask me anything
Posts: 7968
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: bash prompt and putty tweaking

Post by OneCD » Fri May 31, 2019 5:08 am

virtualdj wrote:
Fri May 31, 2019 12:31 am
I would like to avoid horizontal scrolling, so just like #1.
I'm a bit inexperienced with PuTTY as I don't use it. Konsole is a much nicer UX. ;)

I've just done some mucking about to try and replicate this issue - no problems here.

Probably the easiest way around this is to edit [/root/.profile] on your NAS and append your command to turn off horizontal scrolling:

Code: Select all

bind 'set horizontal-scroll-mode off'
... but, as mentioned previously, this file is not persistent, and should be re-written or restored from persistent storage on each reboot.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage

virtualdj
Experience counts
Posts: 1971
Joined: Wed May 26, 2010 2:44 am

Re: bash prompt and putty tweaking

Post by virtualdj » Fri May 31, 2019 11:47 pm

OneCD wrote:
Fri May 31, 2019 5:08 am
I'm a bit inexperienced with PuTTY as I don't use it. Konsole is a much nicer UX. ;)
It's not a terminal client issue, unfortunately, because it's the same with ConnectBot:
Image
And also within an Ubuntu terminal session in a VM (i.e. by typing "ssh admin@qnap_ip"):
Image
While the same on the old NAS results in:
Image
OneCD wrote:
Fri May 31, 2019 5:08 am
Probably the easiest way around this is to edit [/root/.profile] on your NAS and append your command to turn off horizontal scrolling:

Code: Select all

bind 'set horizontal-scroll-mode off'
I've already tried that, but it doesn't change... and the fact that "bind -v" reports the options as "off" let me think that it's correct.
OneCD wrote:
Fri May 31, 2019 5:08 am
I've just done some mucking about to try and replicate this issue - no problems here.
The important thing is that you create a long folder:

Code: Select all

[~] # mkdir -p Very.Long.Folder.To.Demonstrate.The.Scrolling/Another.Long.Sentence.That.Should.Not.Scroll.If.Possible/
and then when you are in the home directory ~:

Code: Select all

[~] # cd Ver<TAB><TAB>
this horizontally scrolls the prompt on my QNAP :evil:

These are my files:

Code: Select all

[~] # cat /root/.profile
export PS1='[\w] # '
reset
source /opt/etc/profile

[~] # cat /etc/inputrc
# /etc/inputrc - global inputrc for libreadline
# See readline(3readline) and `info readline' for more information.

# Be 8 bit clean.
set input-meta on
set output-meta on
set bell-style visible

# To allow the use of 8bit-characters like the german umlauts, comment out
# the line below. However this makes the meta key not work as a meta key,
# which is annoying to those which don't need to type in 8-bit characters.

# set convert-meta off

"\e0d": backward-word
"\e0c": forward-word
"\e[h": beginning-of-line
"\e[f": end-of-line
"\e[1~": beginning-of-line
"\e[4~": end-of-line
#"\e[5~": beginning-of-history
#"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert

# Common standard keypad and cursor
# (codes courtsey Werner Fink, <werner@suse.de>)
#"\e[1~": history-search-backward
"\e[2~": yank
"\e[3~": delete-char
#"\e[4~": set-mark
"\e[5~": history-search-backward
"\e[6~": history-search-forward
# Normal keypad and cursor of xterm
"\e[F": end-of-line
"\e[H": beginning-of-line
# Application keypad and cursor of xterm
"\eOA": previous-history
"\eOC": forward-char
"\eOB": next-history
"\eOD": backward-char
"\eOF": end-of-line
"\eOH": beginning-of-line
I keep grinding my teeth! :evil: :cry:

User avatar
OneCD
Ask me anything
Posts: 7968
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: bash prompt and putty tweaking

Post by OneCD » Sat Jun 01, 2019 10:22 am

virtualdj wrote:
Fri May 31, 2019 11:47 pm
OneCD wrote:
Fri May 31, 2019 5:08 am
I've just done some mucking about to try and replicate this issue - no problems here.
The important thing is that you create a long folder:
Yup, did that. I was able to enable and disable horizontal scrolling with:

Code: Select all

bind 'set horizontal-scroll-mode on'
bind 'set horizontal-scroll-mode off'
... and was also able to see my test pathname wrap around or not in my terminal.

However, this is on QTS 4.2.6 #20190322.

When the QNAP demo site starts working again, I'll try it on vQTS 4.3.5
virtualdj wrote:
Fri May 31, 2019 11:47 pm
These are my files:

Code: Select all

[~] # cat /root/.profile
export PS1='[\w] # '
reset
source /opt/etc/profile
Your [/root/.profile] does not show the command I suggested? :'

Please try adding:

Code: Select all

bind 'set horizontal-scroll-mode off'
... as the last command to [/root/.profile] so this file looks like:

Code: Select all

export PS1='[\w] # '
reset
source /opt/etc/profile
bind 'set horizontal-scroll-mode off'
... then logout your SSH session, then back in again.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage

virtualdj
Experience counts
Posts: 1971
Joined: Wed May 26, 2010 2:44 am

Re: bash prompt and putty tweaking

Post by virtualdj » Sat Jun 01, 2019 8:14 pm

OneCD wrote:
Sat Jun 01, 2019 10:22 am
Your [/root/.profile] does not show the command I suggested? :'
Yeah, sorry :oops:, it wasn't displayed because I removed it after I saw no differences...
Anyway, let's retry:

Code: Select all

[~] # echo "bind 'set horizontal-scroll-mode off'" >> /root/.profile
[~] # cat /root/.profile
export PS1='[\w] # '
reset
source /opt/etc/profile
bind 'set horizontal-scroll-mode off'
[~] # exit
OneCD wrote:
Sat Jun 01, 2019 10:22 am
... then logout your SSH session, then back in again.
Done, and then with Putty:
Image
With the Ubuntu VM:
Image
OneCD wrote:
Sat Jun 01, 2019 10:22 am
When the QNAP demo site starts working again, I'll try it on vQTS 4.3.5
I didn't know that it was possible to reach the QNAP demo site with SSH, too. I though it was only a demo of the web interface only.
OneCD wrote:
Sat Jun 01, 2019 10:22 am
However, this is on QTS 4.2.6 #20190322.
I'm running QTS 4.3.6.0923 and this is the bash version:

Code: Select all

[~] # sh --version
GNU bash, version 3.2.57(1)-release (x86_64-QNAP-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.
So might this be a bug? It's frustrating because copying and pasting from the terminal is very hard in this way!
Last edited by virtualdj on Sat Jun 01, 2019 8:23 pm, edited 1 time in total.

virtualdj
Experience counts
Posts: 1971
Joined: Wed May 26, 2010 2:44 am

Re: bash prompt and putty tweaking

Post by virtualdj » Sat Jun 01, 2019 8:19 pm

I also noticed that on the OLD NAS where the terminal behaves correctly (i.e. not scrolling) I have:

Code: Select all

[~] # echo $TERMINFO
 
While on the NEW, with scrolling therminal:

Code: Select all

[~] # echo $TERMINFO
/opt/share/terminfo
So I tried this modification:

Code: Select all

[~] # cat /root/.profile
export PS1='[\w] # '
reset
source /opt/etc/profile
bind 'set horizontal-scroll-mode off'
unset TERMINFO
but after reconnecting, I still get:
Image

User avatar
OneCD
Ask me anything
Posts: 7968
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: bash prompt and putty tweaking

Post by OneCD » Tue Jun 04, 2019 4:41 am

Hi @vdj, I'm still waiting to test this on the QNAP demo site.

Yes, I've been accessing their demo site vQTS sessions via SSH for some time. I even queried QNAP about this and they said they permit this so users can get the "complete experience" with vQTS. ;)

I can't think of anything else to check-for in the meantime. Maybe someone else has a suggestion?

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage

virtualdj
Experience counts
Posts: 1971
Joined: Wed May 26, 2010 2:44 am

Re: bash prompt and putty tweaking

Post by virtualdj » Tue Jun 04, 2019 1:52 pm

I opened a ticket with the QNAP helpdesk (on the developer category because I didn't know where it would fit) but still no reply from them.

User avatar
OneCD
Ask me anything
Posts: 7968
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: bash prompt and putty tweaking

Post by OneCD » Tue Jun 04, 2019 3:08 pm

I opened a couple of tickets several years ago. Still waiting... ;)

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage

virtualdj
Experience counts
Posts: 1971
Joined: Wed May 26, 2010 2:44 am

Re: bash prompt and putty tweaking

Post by virtualdj » Wed Jun 05, 2019 9:22 pm

OneCD wrote:
Tue Jun 04, 2019 3:08 pm
Still waiting... ;)
Well, you should at least "tease" them! :twisted:
OneCD wrote:
Tue Jun 04, 2019 4:41 am
I'm still waiting to test this on the QNAP demo site.
Today I was able to test it, with vQTS which runs firmware 4.3.5.0760 (older than the one on my NAS).
Ironically, the results are the same!

Image
OneCD wrote:
Tue Jun 04, 2019 4:41 am
Maybe someone else has a suggestion?
Have you got any suggestion on where should I ask for help, here? Because not all the guys may be monitoring this topic and PM is not available on this forum anymore...

virtualdj
Experience counts
Posts: 1971
Joined: Wed May 26, 2010 2:44 am

Re: bash prompt and putty tweaking

Post by virtualdj » Thu Jun 06, 2019 1:10 pm

@OneCD Which is the sh version in your QTS 4.2.6?
My OLD (working) has 3.2.0(269) while the NEW (non-working) has 3.2.57(1), exactly like the vQTS.
Last edited by virtualdj on Fri Jun 07, 2019 12:59 am, edited 2 times in total.

User avatar
OneCD
Ask me anything
Posts: 7968
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: bash prompt and putty tweaking

Post by OneCD » Thu Jun 06, 2019 2:47 pm

virtualdj wrote:
Thu Jun 06, 2019 1:10 pm
@OneCD Which is the sh version in your QTS 4.2.6?
I'll check it when I power-up my old NAS this Sunday.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage

Post Reply

Return to “Linux & Unix (NFS)”