LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 01-09-2018, 02:00 AM   #1
genese
Member
 
Registered: Feb 2006
Location: belgium
Posts: 76

Rep: Reputation: 20
colorized ssh sessions


Hello All,

Starting from a kde konsole, I ssh to different hosts.

I'd like to set the background with a different colors according to the host.

I have excluded the 'setterm' command because of the restricted choice of colors.

I tried to use ANSI sequences like
Code:
printf "\e[48;2;241;255;236m \n"
but

1) colorized commands like 'ls' or 'grep' reset the bg color. OK, I can disable colorization.

2) vim background is independent of the terminal background, and that is my real problem.

Any suggestion ?
 
Old 01-09-2018, 02:18 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
i think you will need to start a dedicated terminal emulator window with different settings for each ssh session.
 
Old 01-11-2018, 11:10 PM   #3
genese
Member
 
Registered: Feb 2006
Location: belgium
Posts: 76

Original Poster
Rep: Reputation: 20
Opening a new terminal would certainly solve my problem, but implementation will not be easy with my current setup.

I run my desktop as an unprivileged user, open Konsoles, and then su to root.

From that point, I open ssh sessions to other hosts, jumping from one host to another, possibly returning to the first.

Hence my need of colorization ;-)
 
Old 01-18-2018, 12:25 PM   #4
redfox2807
Member
 
Registered: Jul 2012
Distribution: Debian testing/stable, Gentoo, CentOS 7, Sailfish OS, Android
Posts: 167

Rep: Reputation: 31
Why do you need root for openning a ssh session? You can always ssh from a regular user
 
Old 01-18-2018, 02:27 PM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
^ i wholeheartedly agree, but didn't mention it earlier since it didn't seem relevant for the colorization issue.
 
Old 01-18-2018, 03:17 PM   #6
redfox2807
Member
 
Registered: Jul 2012
Distribution: Debian testing/stable, Gentoo, CentOS 7, Sailfish OS, Android
Posts: 167

Rep: Reputation: 31
Indeed. I just was pretty surprised to read that root was needed. The best way to solve a problem is to avoid it =)

Concerning the colorozation issue:

1) On all hosts I use zsh with oh-my-zsh extension. Setting different ZSH_THEME variables in ~/.zshrc for different hosts makes the hosts easily distinguishable. No need for fore/background color changes.

2) For vim different foreground and background colors could be set in ~/.vimrc
Code:
highlight Normal ctermfg=red ctermbg=yellow
 
1 members found this post helpful.
Old 01-19-2018, 08:16 AM   #7
genese
Member
 
Registered: Feb 2006
Location: belgium
Posts: 76

Original Poster
Rep: Reputation: 20
[SOLVED]

Ok I managed to get colorized ssh sessions by

1) applying redfox2807 suggestion to .vimrc

2) in .bash_profile, getting colors from .vimrc and including them in the prompt (PS1)

3) viewing man pages with "view" (read only vim) instead of "less"

I expect some command breaking my display in the future, but for now I'm satisfied with this solution.

Thank you redfox2807 and ondoho for your useful comments.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Colorized Bash Prompts carlosinfl Arch 12 10-04-2010 03:30 PM
is there a way to restrict ssh sessions to a specific ssh client? smbhat Linux - Networking 8 03-11-2009 07:36 AM
SSH help, concerning sessions frokid879 Linux - Newbie 4 11-11-2005 11:22 AM
i have to su to get colorized 'ls' in xterm..? doublefailure Slackware 2 03-16-2003 08:47 AM
dead ssh sessions babroga Linux - Newbie 1 03-03-2002 08:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 02:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration