Beautiful Bash

You spend most of your time in the terminal - why not make it nice looking. Using Oh-My-ZSH it's nice to rice.

Beautiful Bash
Photo by Joshua Aragon / Unsplash

You spend most of your time in the terminal - why not make it nice looking.

As most of our work with VM's and systems is bash/zsh based we should pay attention tho this tool. On zsh a use Oh-My-ZSH and the Jonathan theme, it has it all. For automation I use a long list of alias commands in my personal/alias file and folders.

For many things that has to be repeated 10 or 100 times TMUX is a awesome tool.

For security keys are the basic way to identify your self. Apps use tokens.

Multi lingual settings

I need to use UK, US, FI and SV settings depending on what and where I'm working. I have a set of aliases for this. Working with databases we often have to set the functions when using UTF8 settings. There is cultural rules we need to follow. Functions and sort orders are affected as soon as there are non US-ASCII characters in strings - so actually always.

US-ASCII is a special case not the norm. It's only used in the USA

Locale Environment Variables

These variables tell the OS how to display or output certain kinds of text. They’re prioritized, allowing us to influence which ones will come into play:

  1. LANGUAGE
  2. LC_ALL
  3. LC_xxx, while taking into account the locale category
  4. LANG

For example, we can have English set as a language using LANG, but with an Swedish/Finnish date-time format, using LC_TIME.

Example

Some of the standard locale environment variables present in Linux:

LANG=en_US.UTF-8 
LANGUAGE=en_US 
LC_CTYPE="en_US.UTF-8" 
LC_NUMERIC=fi_FI.UTF-8 
LC_TIME=fi_FI.UTF-8 
LC_COLLATE="en_US.UTF-8" 
LC_MONETARY=fi_FI.UTF-8 
LC_MESSAGES="en_US.UTF-8" 
LC_PAPER=fi_FI.UTF-8 
LC_NAME=fi_FI.UTF-8 
LC_ADDRESS=fi_FI.UTF-8 
LC_TELEPHONE=fi_FI.UTF-8 
LC_MEASUREMENT=fi_FI.UTF-8 
LC_IDENTIFICATION=fi_FI.UTF-8 
LC_ALL= 
# To change you need to type the following:
sudo update-locale LANG=LANG=en_US.UTF-8 LANGUAGE 
# or type 
sudo localectl set-locale LANG=en_US.UTF-8 
# or type 
sudo update-locale LC_TIME=en_UK.UTF-8 
# or 
sudo localectl set-locale LC_TIME=en_UK.UTF-8 

‌ To set a global locale for the current user, you can simply edit the file .bash_profile and add two lines.‌ (or any user: nano /home/user/.bash_profile)

nano ~/.bash_profile
LANG="en_IN.utf8"
export LANG

Or in the terminal type

export LANG=es_ES.UTF-8

For more information, see the locale, update-locale and localectl man pages.

The /etc/default/locale file can have additional lines and settings.

You can lock the locale to one language

LC_ALL is the strongest locale environment variable, except for LANGUAGE.

It overrides every other variable in priority, it's the first to be checked by the system.
Thus, it should be used with caution, and only when there are no other solutions to the problem we’re trying to solve.

It's a powerful way to ensure database errors do not occur. We usually use this in scripts or procedures where we don’t want user interference. (One tousend equals 1.000,00 = 1,000.00 = 1 000,00 or 1 pm = 13:00). Functions and sort orders are affected as soon as there are non US-ASCII characters in strings.
A special use of LC_ALL="C" forces to sort according to ASCII value.

Remember to reset it back to the value it had before when finishing the script execution.

# the file text.txt have 8 lines: b;B;A;c;a;C;D;d
# Normal sort results in:
sort text.txt 
a
A
b
B
c
C
d
D
# Setting LC_ALL="C" results in:
LC_ALL="C" sort text.txt 
A
B
C
D
a
b
c
d