Just another way to set colors in Linux shells.
New C++ Version
I will be re-writing this in C++ with more features. Probably coming the end of 2020 or the beginning of 2021.Build |
Status |
---|---|
This is a command line utility that is a wrapper for setting colors in Linux shells/consoles/terminals/ttys; whatever you want to call them.
This essentially replaces something like; (given alias sc='setcolors'
):
'\033[1;31mText\033[0m'
with something like:
$(sc 1 31)Text$(sc)
, but this is just a very basic example as this can be used programmatically and can be passed arrays. You can find more examples on this page.
This will not override any normal color stuff you have going on in your environment just as if you were using escape sequence colors in the same way.
Sometimes I like to be able to set console colors without direct escape sequenced colors; I'd prefer to pass colors and styles as arguments or arrays of arguments to a program and with this program I can do so easier. This a rewrite of a program I wrote in Fortranβ½ΒΉβΎ. and of functions I've written many times in various environments.
This is a compiled binary executable written in ππππ β½Β²βΎ.
This is a Linuxβ½Β³βΎ command line utilityβ½β΄βΎ.
This can be used in any place you can receive command line output (stdout
); so any shell, console, terminal, tty, script, or other program that can display output in a command line.
There are absolutely no dependencies.
Since this has 0 dependencies this can be used portably or installed. There is one installable .deb
package or 2 portable methods; the simple file
or the .AppImage
.
If you install it with the .deb
package it will install to /usr/bin/setcolors
and you can simply run it anywhere.
As with any portable application in any operating system if you want to run it by it's file name then the program file
must be in a directory that's in the PATH variable. In Linux this is the $PATH
variable. If the file
is not in $PATH
then to be executed you must provide the full /path/to/file
.
As with any executable file in Linux you make have to grant these files executable permission with either:
chmod +x /path/to/setcolors # or u+x for user only
# or
chmod 755 /path/to/setcolors-x86_64.AppImage # 744 or 700 for user only
This is a self contained Rust binary executable with no dependencies and so is easily portable. There isn't necessarily a need for the AppImage, but it's there for those who prefer that method. The binary and AppImage are used in the exact same way.
File Name | File Description |
---|---|
setcolors |
Rust - file - binary executable. |
File Name | File Description |
---|---|
setcolors-x86_64.AppImage |
AppImage - .AppImage - binary executable. |
File Name | File Description |
---|---|
setcolors.deb |
Debian - .deb - installable file. |
You can install this .deb
package with:
sudo dpkg -i /path/to/setcolors.deb
Non-exhaustive list of examples.
All examples assume an alias to 'sc':
$ alias sc='setcolors'
- Set bold dark red underlined text with a white background.
printf `sc 1 2 4 31 107`' TEXT '`sc`'\n'
- Create a clickable file in many terminal programs.
printf `sc 4`'file://'"${HOME}\n"`sc`
or
printf `sc 4`'file://%s\n'`sc` "${HOME}"
- Print blinking 'USA' in red, white, and blue with a black background.
printf \
`sc 1 5 91 40`' \n U'\
`sc 97`'S'\
`sc 94`'A \n \n'\
`sc`
- Help Message
setcolors --help
Set console colors.
E.g. setcolors 1 31 107
setcolors 4;echo "file:///${HOME}/Documents"
@USAGE:
setcolors [OPTIONS...]
setcolors [COLORS...]
@OPTIONS:
-h,--help This HELP message.
@COLORS:
Integers Any amount of numbers
from the list below.
0-5 Various styles.
30-37 Darker foreground colors.
90-97 Lighter foreground colors.
40-47 Darker background colors.
100-107 Lighter background colors.
@ERRORS: Integers - Exit Codes.
0 No errors.
1 Passed arguments are not integers
between 0-255.
2 Error in 'printf'.
There are 3 main files (you only need one; your choice, of course) and all can be found in the Continuous Build section of Releases at this repositories home page. Here you will find links to all files involved.
Link | Description |
---|---|
Continuous.setcolors@github.com | Continuous stable release page. All current files. This is the recommended option. |
setcolors@github.com | This repository. |
setcolors@github.io | This repository - themed. |
Get the files directly from here if you like.
Link | Description |
---|---|
setcolors.deb - Continuous | The most up-to-date Debian package installer. |
setcolors - Continuous | The most up-to-date portable file executable. |
setcolors-x86_64.AppImage - Continuous | The most up-to-date portable AppImage executable. |
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# | Item | Description | Link |
---|---|---|---|
ΒΉ | Fortran | The "Fortran" programming language. | Fortran@en.wikipedia.org |
Β² | ππππ | The "Rust Lang" programming language. | rust-lang.org |
Β³ | Linux | The "Linux" operating system. | Linux@en.wikipedia.org |
β΄ | command line utility | A tool for a command line interface (CLI). | Console_application@en.wikipedia.org |
Description | Status |
---|---|
Total downloads for this project |