From 4abcce013c9ee3053badf2abda77190233066676 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Fri, 23 Feb 2024 10:35:22 +0100 Subject: Testing thoughts page --- _posts/2023-05-25-show-xterm-colors.md | 85 ---------------------------------- 1 file changed, 85 deletions(-) delete mode 100644 _posts/2023-05-25-show-xterm-colors.md (limited to '_posts/2023-05-25-show-xterm-colors.md') diff --git a/_posts/2023-05-25-show-xterm-colors.md b/_posts/2023-05-25-show-xterm-colors.md deleted file mode 100644 index 56050fd..0000000 --- a/_posts/2023-05-25-show-xterm-colors.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -title: Display xterm color palette -permalink: /xterm-color-palette.html -date: 2023-05-25T12:00:00+02:00 -layout: post -type: note -draft: false -tags: [linux] ---- - -- `bash xterm-palette.sh` - will show you number of max colors available -- `bash xterm-palette.sh -v` - will create a list of all colors with codes - -![xterm color palette](/assets/notes/xterm-palette.png){:loading="lazy"} - -```sh -#!/usr/bin/env bash -# xterm-palette.sh - -trap 'tput sgr0' exit # Clean up even if user hits ^C - -function setfg () { - printf '\e[38;5;%dm' $1 -} - -function setbg () { - printf '\e[48;5;%dm' $1 -} - -function showcolors() { - # Given an integer, display that many colors - for ((i=0; i<$1; i++)) - do - printf '%4d ' $i - setbg $i - tput el - tput sgr0 - echo - done - tput sgr0 el -} - -# First, test if terminal supports OSC 4 at all. -printf '\e]4;%d;?\a' 0 -read -d $'\a' -s -t 0.1