Jump to content
Sign in to follow this  
PeterB

XTermTitle plg - Machine name/cwd display in Xterm sessions connected to unRAID

11 posts in this topic Last Reply

Recommended Posts

If, like me, you frequently work with several terminal sessions open, you may find the following (very) simple plugin useful.

 

When I started connecting to my ArchLinux VMs, I was interested to note that the target machine/cwd was displayed in my terminal window title bar and tabs - I'd never seen this with unRAID, so I created this little utility to add the same feature to unRAID.

 

This version of the plugin will work with unRAID v6.0 beta12

 

The plugin can be found at

https://github.com/PeterAOBell/unraid/raw/master/XTermTitle.plg

Simply paste the url into the install plugin box and click 'Install'.

Share this post


Link to post

Nice little addition :)

 

I installed it and logged in as a non-root user via ssh, worked great. But if I ran su to do something as root it didn't updated the window title anymore.

 

So I added a ~/.bashrc file which just contains

source /etc/profile

and now it works just fine :D

 

Any possibility you could add the creation of the .bashrc file to the plugin?

 

It also doesn't update from within a screen session, not found a fix for that yet though.

 

Edit:

 

I think I found a fix for the screen issue. I changed the added code in /etc/profile to be

if [ $?TERM ]; then     #paob
  case $TERM    #paob
  in    #paob
     xterm*)    #paob
     PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' #paob
     ;; #paob
     screen) #paob
     PROMPT_COMMAND='echo -ne "\033P\033]0;${USER}@${HOSTNAME}: ${PWD}\007\033\\"' #paob
     ;; #paob
     *) #paob
  esac  #paob
fi      #paob

 

and it works from within a screen session too

Share this post


Link to post

Nice little addition :)

 

Thanks, I find it helps to eliminate confusion!

 

I installed it and logged in as a non-root user via ssh, worked great. But if I ran su to do something as root it didn't updated the window title anymore.

 

Ah, I always log in as root!  :-[

 

So I added a ~/.bashrc file which just contains
source /etc/profile

and now it works just fine :D

 

Any possibility you could add the creation of the .bashrc file to the plugin?

 

Done!

 

It also doesn't update from within a screen session, not found a fix for that yet though.

 

Edit:

 

I think I found a fix for the screen issue. I changed the added code in /etc/profile to be

if [ $?TERM ]; then     #paob
  case $TERM    #paob
  in    #paob
     xterm*)    #paob
     PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' #paob
     ;; #paob
     screen) #paob
     PROMPT_COMMAND='echo -ne "\033P\033]0;${USER}@${HOSTNAME}: ${PWD}\007\033\\"' #paob
     ;; #paob
     *) #paob
  esac  #paob
fi      #paob

 

and it works from within a screen session too

 

Okay,so the screen session merely needs the xterm prompt wrapping in an <ESC>P....<ESC>\ pair?

 

I can add that easily enough.

Share this post


Link to post

Okay,so the screen session merely needs the xterm prompt wrapping in an <ESC>P....<ESC>\ pair?

 

I can add that easily enough.

Yep, if that's what those codes mean (I found it in a forum somewhere).

 

Having it added to your plugin would be great if you get a chance.

Share this post


Link to post
Having it added to your plugin would be great if you get a chance.

 

Okay, done.  Give that a try and let me know if any problems.

Share this post


Link to post

Bumping this to see if the author can confirm that it is compatible with 6.1.

 

I am using it under 6.1 without issues.

Share this post


Link to post

I just downloaded this plugin after learning about it here:

I'd like to be able to preserve/repopulate .bashrc with some aliases I use often. I'm not really sure how to go about doing this. Any pointers?

Share this post


Link to post
3 hours ago, Bob1215 said:

I just downloaded this plugin after learning about it here:

I'd like to be able to preserve/repopulate .bashrc with some aliases I use often. I'm not really sure how to go about doing this. Any pointers?

A little OT,

What I do is use "heredocs" in the go file;

 

Like so:

cat << 'EOF' > ~/.bashrc

Your

Full

Bashrc

Goes

Here

EOF

 

You can do this for any files you'd like.

You can also store them in a "overlay" folder, which can be more convenient depending on circumstances (I'm going to switch to this as I have several user customized files now)

You would do this by creating an overlay folder in the same directory as the "go" script on your boot drive.

 

Put your .bashrc, .bash_profile etc into there.

 

At the end of your "go" file put:

mount -t overlay overlay -o lowerdir=~/,upperdir=./overlay ~/

 

This "should" (I have not tested it yet) make the original ~/ created by unraid read only, and mount the "overlay" directory from the flash drive as read write over the top of it. Anything written to the home directory of root ~/, /root/ will be written to the flash drive and persistent across reboots.

This makes for a good failsafe, if something breaks you can simply comment out the mount line in the go file and it will be reverted. I'm kind of surprised a persistent home directory hasn't already been added to unraidnin this manner.

Share this post


Link to post
7 hours ago, Xaero said:

Anything written to the home directory of root ~/, /root/ will be written to the flash drive and persistent across reboots.

How are you handling permissions? FAT32 doesn't support normal linux permissions, and causes issues if not dealt with.

Share this post


Link to post
Posted (edited)
On 7/8/2019 at 5:59 AM, jonathanm said:

How are you handling permissions? FAT32 doesn't support normal linux permissions, and causes issues if not dealt with.

You could use a persistence file, I forgot about this issue. We've dealt with this in USB Linux Land for a long time.

 

Basically,

dd if=/dev/zero of=/boot/config/persist.img bs=1M count=512

(For a 512mb persist file)

mkfs.ext4 /boot/config/persist.img

 

And then change the overlay mount to mount that persist image rather than a folder.

 

Max size in this case would be 4gb due to fat32 ceiling.

 

EDIT:
This was from memory - there's a few steps involved. I'll document this in a separate thread and then link that thread here, so as to not derail this OP any further. I may also make it a feature suggestion, since it wouldn't be too outlandish to offer this as an option in the WebUI by default, and have safe mode just "NOT" use the home folder overlay.

Edited by Xaero

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this