Skip to content

Instantly share code, notes, and snippets.

@jiaozhu
Forked from criaturaExperimental/iterm2_badges.md
Created June 23, 2018 05:52
Show Gist options
  • Save jiaozhu/e2a32595eeea3eb9778bbcd52b9fff3d to your computer and use it in GitHub Desktop.
Save jiaozhu/e2a32595eeea3eb9778bbcd52b9fff3d to your computer and use it in GitHub Desktop.
Customizing badges for iTerm2

Customizing iTerm badges

There are two variables available to use in the badge field with

\(user.gitBranch) \n \(user.humpDay)
  • gitBranch shows the current branch the folder opened in the terminal is
  • humpDay shows an icon according to the date

This code goes into ~/.bash_profile

#iTerm setup
function iterm2_print_user_vars() {
  iterm2_set_user_var gitBranch $((git branch 2> /dev/null) | grep \* | cut -c3-)
  iterm2_set_user_var humpDay $(what_day_is_it)
}

function random_emoji {
    # Array with emojis
    emojis=("๐Ÿน" "๐Ÿ " "๐Ÿ" "๐Ÿฆ‘" "๐ŸŒด" "โญ๏ธ" "๐Ÿ„" "๐ŸŒป" "๐ŸŒ" "๐ŸŒ™" "๐Ÿ”ฅ" "๐ŸŒˆ" "๐ŸŒช" "๐Ÿ‘" "๐Ÿฅ‘" "๐Ÿฑ" "๐Ÿฃ" "๐ŸŽญ" "๐ŸŽจ" "๐ŸŽฌ" "๐ŸŽง" "๐ŸŽผ" "๐ŸŽน" "๐ŸŽฎ" "๐Ÿšœ" "๐Ÿ›ซ" "๐Ÿš‚" "๐Ÿš€" "๐Ÿ—บ" "๐Ÿ—ฟ" "๐Ÿฏ" "๐Ÿ•" "๐Ÿ”" "โ›ฉ" "๐Ÿ›" "๐Ÿ“€" "๐Ÿ“ผ" "๐Ÿ“ฝ" "๐ŸŽž" "โฐ" "๐Ÿ’ก" "๐Ÿ’Ž" "โš–๏ธ" "๐Ÿ› " "โš™๏ธ" "๐Ÿ’ฃ" "โš”๏ธ" "๐Ÿ”ฎ" "๐Ÿ’ˆ" "๐Ÿ”ญ" "๐Ÿ”ฌ" "๐Ÿ•ณ" "๐Ÿšฝ" "๐Ÿ›€๐Ÿฝ" "๐Ÿ—" "๐Ÿšช" "๐Ÿ–ผ" "๐ŸŽˆ" "โœ‰๏ธ" "๐Ÿ’Œ" "๐Ÿ–‡" "๐Ÿ”" "๐Ÿ’ฏ" "๐ŸŽถ" "๐Ÿ”" "โ™ž" "๐Ÿ‚ฑ" "โœ“" "โฆ" "โŒ˜" "โ™ป๏ธŽ" "๐Ÿ˜…" "๐Ÿคฃ" "๐Ÿ˜‹" "๐Ÿ˜™" "๐Ÿค“" "๐Ÿ˜Ž" "๐Ÿ™ƒ" "๐Ÿ˜ณ" "๐Ÿ˜ฑ" "๐Ÿ™„" "๐Ÿค–" "๐Ÿ‘พ" "๐Ÿ’€" "๐Ÿ‘๐Ÿผ" "๐Ÿ‘€" "๐Ÿ’ƒ๐Ÿป" "๐Ÿ‘“")

    # Seed random generator
    RANDOM=$$$(date +%s)

    # Get random expression...
    selectedemoji=${emojis[$RANDOM % ${#emojis[@]}]}
    # Write to Shell
    echo $selectedemoji

}

function what_day_is_it {
    case "$(date +%A)" in
        "lunes")
            if [[ $(date +%H) > 15 ]]
                then
                    random_emoji
                else
                    echo "๐ŸŒฑ"
            fi
            ;;
        "miรฉrcoles")
            if [[ $(date +%H) < 15 ]]
                then
                    random_emoji
                else
                    echo "๐Ÿช"
            fi
            ;;
        "jueves")
            echo "๐Ÿณ"
            ;;
        "viernes")
            echo "๐Ÿฆ„"
            ;;
        "sรกbado" | "domingo")
            echo "โ˜ ๏ธ"
            ;;
        *)
            random_emoji
            ;;
    esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment