Skip to content

Scope of functions

TomfromBerlin edited this page Feb 18, 2023 · 7 revisions

This .bashrc actually consists of not just one, but several files. On the one hand the actual .bashrc and on the other hand a few files that contain certain settings, functions, and other stuff (see below). In principle, the contents of these files could also be written directly to the .bashrc, but it is a bit cleaner this way. These additional files must live in the ~/.shellcfg/ directory for full functionality.

Aliases and functions

There are a few functions and aliases as well as color definitions in the corresponding files. To take full advantage, be sure to check out these files.

However, be aware that things can get messed up very quickly if something is modified in the wrong way (see section Automated Backup).

Aliases in ~/.shellcfg/alias

Way to much to mention all here. Most of them are explained in the file, but currently mostly in German.

Functions in ~/.shellcfg/functions

Name Usage Description
__add_command_replace_alias will be invoked automatically This function checks if certain applications are installed and defines aliases in case of. This will not remove the application. But if you call it the usual way the more sophisticated version will be used, e.g. 'htop' instead of 'top'. If for some reason you need the original program, you can use command <program name> to override the alias, e.g., command top.
Source: https/github.com/slomkowski/bash-full-of-colors/bash_aliases.sh
colortest colortest this function displays a line with a smooth gradient if the terminal used supports 256 colors or more; with less, the colors will be clearly separated from each other and there will be no gradient at all
allcolors allcolors It will show you color codes that can be used when prettifying your prompt, whereby the name "allcolors" promises more than it delivers. Basically, there are 16 colors + variants that are output.
Before you fiddle around with color codes just have a look at the file ~/.shellcfg/colors. There is a chance your desired color has already a human-readable equivalent.
truecolors truecolors Well, the function allcolors only outputs 16 foreground colors plus 16 background colors in the possible combinations. Additionally there are blinking versions if the terminal supports this attribute. The colors themselves are usually available in a dark and a light version. This should be sufficient in most cases. But if, for example, fifty shades of gray are needed (pun somewhat intended), I have something up my sleeve. Type truecolors on the command line and press Enter. If the terminal has the capability (most will), you should now see the color codes for 256 colors. (I know, True Color actually means 16 million colors. The name of the function is reminiscent of the song "True Colors" by Cindy Lauper.)
command not found will be invoked automatically This is available in most distributions, but not necessarily installed. It should actually be called in /etc/bash.bashrc for the function to be available globally, but it doesn't hurt if it lives in ~/.bashrc either. Under Arch Linux, line 10 in ~/.shellcfg/colors must be commented out (#source /usr/share/doc/pkgfile/command-not-found.bash). It should be processed before the function will be declared, otherwise the whole thing won't work in this distribution. Other non-Debian-/Ubuntu-based distributions may have similar requirements.
extract extract <filename> extracts all formats of archive files (credits: urukrama, Ubuntuforums.org)
ff (find file) ff <filename> It's supposed to, well, find files.
wtfis wtfis <arg> Like which but exposes much more info. <arg> has to be the name of a program, symlink, function, or alias that can be found on your system, e.g. wtfis man.
Be patient! This function takes some time to collect all the information.❗
Source: 'https://raw.githubusercontent.com/janmoesen/tilde/master/.bash/commands'