> <iterm2.png>
> Still, when I enter a wrong command name in bash, say 'lo RET', I get:
>
> $ lo
> -bash: lo: Kommando nicht gefunden
>
> Any hint what I'm doing wrong?
Short version:
* The OS is telling iTerm2 to run in German.
* iTerm2 is telling your shell to start in German.
* Your `.bashrc` configures your shell to start its child processes in English, but cannot change the language that the shell itself runs in.
So the shell itself is running in German, but the programs that the shell runs (such as `locale` or `env`) will be started in English.
If you want the shell itself to run in English (i.e. "command not found" instead of "Kommando nicht gefunden"), here are a few ways to do it:
* Configure iTerm2 to run the shell in English, i.e. with "LANG=en_US.UTF-8". In iTerm2's settings:
* Change "Environment:" to "Use custom locale..."
* Use the "Change..." button and select "English (United States), UTF-8"
* Add something to your `.bashrc` file so that, if the shell doesn't have the correct `LANG` value, it exports the correct value and executes a new shell process over the current shell. It might look something like this, at the top of the file:
if [[ "$LANG" != "de_DE.UTF-8" ]]
then
LANG="de_DE.UTF-8" exec "$SHELL" -l
fi
----------------------------------------
Details:
(1) Each process has its own set of environment variable. When a parent process creates a child process, it gives the child the list of variables that it starts with.
(2) Unless you deliberately did something strange, the main iTerm2 process will be a child of `launchd`. When `launchd` starts iTerm2, it sends the `LANG` variable with the appropriate value for the system's primary language.
(3) When a window or tab opens, iTerm2 starts a shell in that window/tab. It may or may not send the shell a `LANG` environment variable, depending on the "Environment:" setting from your screenshot.
(4) In your case, the shell is starting with "LANG=de_DE.UTF-8".
(5) There is no way to make `bash` re-configure its own locale after it has been started. The closest thing you can do is start a new instance of bash with the new `LANG` value.
It *looks like* when you use the "Do not set locale environment variables", the `LANG` value it sends to the shell is the same value that iTerm2 inherits from `launchd`. I'm not sure if this is a bug or not, but at the very least the description isn't 100% correct.
* With the option "Do not set locale environment variables" and label `$LANG will not be set`, I would assume that iTerm2 *removes* the `LANG` and `LC_xxx` variables from the environment block it gives the shell.
* If iTerm's intent is to *copy* whatever values iTerm2 inherited from `launchd`, I would probably have called the option "Do not *change* locale environment variables", with the label `$LANG will keep the system-wide value`.
Other things to point out:
* The `locale` command shows you the *effective* settings, whether the underlying environment variables are set or not. Run `env` to see which variables are actually set, and which values are implied.
$ locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL=
$ env | grep '^L[AC]'
LANG=en_US.UTF-8
LC_TERMINAL=iTerm2
LC_TERMINAL_VERSION=3.6.9
* The command `pstree -s iTerm` will show the chain of parent/child relationships involving iTerm2. Seeing this may help you to "visualize" how the `LANG` value makes its way from `launchd` down to the shell.
* If you don't have the `pstree` command, you can install it using Homebrew, using `brew install pstree`. (This is one of the standard packages I install on all of my macOS machines.)
Good luck.
--
John Simpson - KG4ZOW
https://jms1.net/