https://github.com/reiniiriarios/ansihelp
Bash script help file for using ansi codes. Covers 16-color, 8-bit color, 24-bit color, text decoration, and cursor position.
https://github.com/reiniiriarios/ansihelp
ansi bash bash-script
Last synced: 2 months ago
JSON representation
Bash script help file for using ansi codes. Covers 16-color, 8-bit color, 24-bit color, text decoration, and cursor position.
- Host: GitHub
- URL: https://github.com/reiniiriarios/ansihelp
- Owner: reiniiriarios
- License: gpl-3.0
- Created: 2021-03-11T02:13:08.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-06-17T21:57:43.000Z (about 4 years ago)
- Last Synced: 2025-01-18T02:27:01.709Z (over 1 year ago)
- Topics: ansi, bash, bash-script
- Language: Shell
- Homepage:
- Size: 18.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ansihelp
Bash script help file for using ansi codes (primarily colors)
## Installation
`chmod +x ansihelp.sh`
`mv ansihelp.sh /usr/sbin/ansihelp`
(Or move wherever you like)
## Usage
`ansihelp` or `ansihelp -h`
```
ansihelp [-hadc123456]
This script is a reference for common (and less common) ANSI codes.
options:
-h show this help text
-a how to use ansi codes
-d text decorations (bold, underline, etc)
-c cursor position
-1 colors: dark text on dark backgrounds
-2 colors: light text on dark backgrounds
-3 colors: dark text on light backgrounds
-4 colors: light text on light backgrounds
-5 colors: 8-bit (256) colors
-6 colors: 24-bit (RGB) colors
```
`ansihelp -a`
```
┌──────────────────────────────────────────────────────────────────────────────┐
│ ANSI Codes are a sequence of an escape character, usually a left open │
│ bracket, and a specific code. For codes with options, the options are │
│ generally separated by semicolons. │
│ [ [;; │
│ │
│ An escape sequence can be typed as an octal or hexidecimal │
│ or entered by typing Ctrl+V then Esc. Hexidecimal is rarely used. │
│ \033 \x1b ^[ │
│ │
│ A common usage is to change text color: │
│ \033[32mgreen\033[0m ^[[32mgreen^[[0m => green │
│ │
│ Not all ANSI codes will function on every terminal, and so they should │
│ be used with care. For compatibility, more common ASCII escape │
│ sequences and tput commands should be used when possible. This │
│ script can be used to test compatibility of color and text │
│ decoration codes. │
└──────────────────────────────────────────────────────────────────────────────┘
```
`ansihelp -c`
```
┌────────────────────────────────────────────────────────────┐
│ Position the cursor: │
│ ^[[;H or ^[[;f │
│ puts the cursor at line L and column C │
│ │
│ Move cursor up N lines: ^[[A │
│ Move cursor down N lines: ^[[B │
│ Move cursor left N lines: ^[[C │
│ Move cursor right N lines: ^[[D │
│ │
│ Clear the screen, move to (0,0): ^[[H │
│ Erase to end of line: ^[[K │
│ Save cursor position: ^[[s │
│ Restore cursor position: ^[[u │
│ │
│ Enable scrolling for entire display: ^[[r │
│ Enable scrolling from row start to row end: ^[[;r │
│ Scroll down one line: ^[[D │
│ Scroll up one line: ^[[M │
│ │
│ Linefeed: \n ^[[J │
│ new line │
│ Carriage Return: \r ^[[M │
│ moves the cursor to the beginning of the line │
│ Backspace \b ^[[H │
│ moves the cursor back one space │
│ Tab \t ^[[I │
│ horizontal tab │
└────────────────────────────────────────────────────────────┘
```