Skip to content

Instantly share code, notes, and snippets.

@mladenp
Created July 4, 2023 15:11
Show Gist options
  • Save mladenp/02527a2704a816e00b411ba122f1b0dc to your computer and use it in GitHub Desktop.
Save mladenp/02527a2704a816e00b411ba122f1b0dc to your computer and use it in GitHub Desktop.

Revisions

  1. mladenp created this gist Jul 4, 2023.
    37 changes: 37 additions & 0 deletions iterm-color-tab
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@

    precmd() {
    # sets the tab title to current dir
    echo -ne "\e]1;${PWD##*/}\a"
    }

    PRELINE="\r\033[A"

    function random {
    echo -e "\033]6;1;bg;red;brightness;$((1 + $RANDOM % 255))\a"$PRELINE
    echo -e "\033]6;1;bg;green;brightness;$((1 + $RANDOM % 255))\a"$PRELINE
    echo -e "\033]6;1;bg;blue;brightness;$((1 + $RANDOM % 255))\a"$PRELINE
    }

    function color {
    case $1 in
    green)
    echo -e "\033]6;1;bg;red;brightness;57\a"$PRELINE
    echo -e "\033]6;1;bg;green;brightness;197\a"$PRELINE
    echo -e "\033]6;1;bg;blue;brightness;77\a"$PRELINE
    ;;
    red)
    echo -e "\033]6;1;bg;red;brightness;270\a"$PRELINE
    echo -e "\033]6;1;bg;green;brightness;60\a"$PRELINE
    echo -e "\033]6;1;bg;blue;brightness;83\a"$PRELINE
    ;;
    orange)
    echo -e "\033]6;1;bg;red;brightness;227\a"$PRELINE
    echo -e "\033]6;1;bg;green;brightness;143\a"$PRELINE
    echo -e "\033]6;1;bg;blue;brightness;10\a"$PRELINE
    ;;
    *)
    random
    esac
    }

    color