Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8783259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:47:02+00:00 2026-06-13T20:47:02+00:00

I am looking for a simple solution that would give me a RGB color

  • 0

I am looking for a simple solution that would give me a RGB color for each hostname.

I plan to use this for setting the tab-color in iTerm2, so I can easily spot the correct host based on the the color picket for it.

Now, I cannot use all 3-bytes because in some cases the differences can be too subtile, and also because I need to ban too dark to too light color.

Bases on this I can only assume that I could safely use 5 bits for each color, this would give me something like 2^15 = 128 colors to pick from. I can take care of the formula for converting the number to R,G,B values 😉

So what I need is a simple piece of code that would give me a 15 bit hash of a string (hostname).

If this would be doable in bash, it would be perfect, but I also accept a Python variant. 

The solution has to work on Debian, RedHat and OS X without having to install additional utils or libraries.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:47:03+00:00Added an answer on June 13, 2026 at 8:47 pm
    #!/bin/bash
    MD5="md5sum"
    if [[ $OS == 'darwin' ]]; then MD5="md5" ; fi
    HASH=`hostname -s | ${MD5}`
    echo -n -e     "\033]6;1;bg;red;brightness;$((0x${HASH:0:2}))\a\033]6;1;bg;green;brightness;$((0x${HASH:2:2}))\a\033]6;1;bg;blue;brightness;$((0x${HASH:4:2}))\a"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for a simple solution for the issue that my GWT DialogBox
I'm looking for a simple clock synchronization protocol that would be easy to implement
I'm looking for a very simple wpf diagram toolset that would allow me to
I'm looking for an elegant solution to this very simple problem in MATLAB. Suppose
I'm looking for a simple solution using Python to store data as a flat
I am looking for a simple solution to do Exception Logging combined with Error
I'm looking for a simple C# solution to manage a playlist. Not the actual
I'm looking at a SSO (Single Sign On) solution to fit our relatively simple
I am looking for simple example code for setting up a Message in an
Ok, this is an embarassingly simple-looking problem, but is driving me crazy. I'm learning

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.