micharbet / CLE

Command Live Environment
GNU General Public License v2.0
25 stars 4 forks source link

Allow different configs cf-HOSTNAME #44

Closed vladki77 closed 5 years ago

vladki77 commented 5 years ago

We have a few servers that share the /home partition via NFS. In that case it is useful to have different config (colors) for each server. Default is ~/.cle-username/cf Server specific version is ~/.cle-user/cf-hostname It has to be created manually. This tweak does it: [[ -r $CLE_D/cf-$CLE_SHN ]] && CLE_CF=$CLE_D/cf-$CLE_SHN

micharbet commented 5 years ago

This is indeed very good idea! Need to think more than I'm capable at this (night)time. But this will be implemented too.

micharbet commented 5 years ago

Hi Vladki,

I implemented your idea in slightly different way: The config file will contain hostname by default. Seamless transition from cf to cf-hostname is ensured.

I'd appreciate if you check this new feature. Instead updating please kindly check branch 'NovaDev', download either clerc or clerc.sh and temporarily replace your environment. I strongly believe you exactly know what to do. (ask me if not, of course)

https://github.com/micharbet/CLE/tree/NovaDev https://github.com/micharbet/CLE/commit/3244ca3079b7f0ddd0f4981f14ed3cb9b15c3230

Let me know if it works, if something else would be better, or anything related. Thank you in advance!

-michael-

vladki77 commented 5 years ago

Hello Michal,

it seems to work well. I was just surprised that for other files you use short host name (like rc-$CLE_SHN, tw-$CLE_SHN), and for config you use full host name. Not a big problem, just consistency and esthetics ;)

Vladki

micharbet commented 5 years ago

Yes, Vladki, You're absolutely right and yesterday night I was thinking about the same - consistency and aesthetics... but it was too late :-) Nevertheless, here is the reason why I used CLE_FHN: I consider CLE_FHN stable, while the shortened form will be changeable to the user's taste. Remember our discussion about what could be removed from the hostname. So I will update CLE also with an option to easily alter CLE_SHN. And, for consistency reasons all future hostnames will contain $CLE_FHN.

BTW, many thanks for beta-testing!

-michael-

On Wed, 21 Nov 2018 at 10:34, Vladislav Kurz notifications@github.com wrote:

Hello Michal,

it seems to work well. I was just surprised that for other files you use short host name (like rc-$CLE_SHN, tw-$CLE_SHN), and for config you use full host name. Not a big problem, just consistency and esthetics ;)

Vladki

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/micharbet/CLE/issues/44#issuecomment-440597146, or mute the thread https://github.com/notifications/unsubscribe-auth/AH_0gG0MXpBrECuJInUFs7ieJjznJQK7ks5uxR43gaJpZM4YTtfs .

-- - - .. -.-. ....

michael arbet

vladki77 commented 5 years ago

OK. just an idea for cle_shn/fhn. What about an option how many levels to remove from FHN to form SHN? Your current default is 2, mine is 1. Maybe someone will have use for more, like host.fit.vut.cz... So a check to leave at least the first part would be needed...

micharbet commented 5 years ago

Hi Vladki, I've just merged latest changes into master branch with almost all of your inspirations. Including the customized shortening. Define variable $CLE_SRE in tweak file and create your very own shortened hostname. In your case you can use following statement to remove just one level from FQDN: CLE_SRE="'s:\.*[^.]*$::'"

Note that you can create more complicated statements combining several expressions like: CLE_SRE="-e 'expr1' -e 'expr2' ..."

Also double quotes and single quotes are necessary! Everything is already documented in file HOWTO.md ( read using cle doc )

I hope it's all useful, let me know if something needs improvements Kind regards -michael-

vladki77 commented 5 years ago

Thank you, works perfectly. I have already used the double expression option:

CLE_SRE="-e 's:\.[^.]*$::' -e 's:\.webstep::'" and now my CLE_WT is much simpler:

# window title
_setwt () {
        [[ $TERM =~ linux ]] && return # no tits on console
        CLE_WT=${CLE_SHN}:
        [[ $USER = root ]] && CLE_WT=${CLE_WT^^}
}

Vladki