Aşağıdaki kabuk fonksiyonu ile geldim:
hash_string256() {
# Hash $1 into a number
hash_value=$(printf "%s" "$1" | md5sum |tr -d " -"| tr "a-f" "A-F")
# Add the hash with $2 and modulo 256 the result
# if $2 == "" it is 0
printf "ibase=16; (%s + %X) %% 100\n" $hash_value "$2" | bc
}
Bu fonksiyon (eğer sonuç doğruysa bu gibi kullanılabilir $HOSTolduğu LOL):
$hash_string256 $HOST
113
$hash_string256 $HOST 127
240
Bunu bağlamak için tmux, başlatılan ve yapılandırılan bir komut dosyası kullanabilirsiniz tmux.
#!/bin/sh
SESSION=$USER
hash_string256() {
hash_value=$(printf "%s" "$1" | md5sum |tr -d " -"| tr "a-f" "A-F")
printf "ibase=16; (%s + %X) %% 100 \n" $hash_value "$2" | bc
}
tmux -2 new-session -d -s $SESSION
tmux set -g status-fg colour$(hash_string256 $HOST)
tmux set -g status-bg colour$(hash_string256 $HOST 127)
# Attach to session
tmux -2 attach-session -t $SESSION
Hostname için LOLo kuracak status-fgkadar colour113ve status-bghiç colour240. 127 sayısı $(hash_string256 $HOST 127)oradadır, böylece arka plan ön plan rengiyle aynı değildir ve birbirinden çok uzaktır.
Hiçbiri GNU sistemi için
Sisteminizde satır md5yerinemd5sum
hash_value=$(printf "%s" "$1" | md5sum |tr -d " -"| tr "a-f" "A-F")
ile değiştirilebilir
hash_value=$(printf "%s" "$1" | md5 | tr "a-f" "A-F")
.tmux.confaldım"cut -c3- ~/.tmux.conf | bash -s apply_configuration" returned 1. Yine de, durum çubuğum gerçekten kırmızıya döndü !!!