1

In this answer, user pizdelect explains how to start a new Bash subshell that uses U+2018 and U+2019 for the single quote characters, but notes that you can't set this from inside bash. Therefore it seems that nothing in ~/.bashrc or ~/.bashprofile could set this. Yet always manually starting a new subshell is a gigantic pain.

How can I make Bash start up this way all the time?

AdminBee
  • 22,803
iconoclast
  • 9,198
  • 13
  • 57
  • 97

2 Answers2

1

On some (all?) Linux-based systems you can add the definition to /etc/default/locale. On my Debian-ish system here's what I now have in that file:

#  File generated by update-locale
LANG=en_GB.UTF-8

#  Fancy quotes, https://unix.stackexchange.com/a/584542/100397
LANGUAGE=en@quot:en_GB:en

When I login I have these in the environment

env | grep LANG
LANGUAGE=en@quot:en_GB:en
LANG=en_GB.UTF-8

and commands work in the way that you want

alias foo=bar
type foo
foo is aliased to ‘bar’
Chris Davies
  • 116,213
  • 16
  • 160
  • 287
  • I assume this works, but it's failing for me on the same Ubuntu system with Bash 4 that didn't accept LANGUAGE=en@quot:en_US:en bash... any ideas? ‍♂️ On macOS the file doesn't even exist. – iconoclast May 06 '20 at 00:23
  • @iconoclast in your previous referenced question you talk about using Ubuntu. Now you're using MacOS. This issue isn't just about bash but the entire locales subsystem. Please edit your question to make it clear what OS or distribution you really are using. I would expect my solution to work with Debian/Ubuntu but unlikely to be of any use with MacOS – Chris Davies May 06 '20 at 07:26
  • I'm using both, and mentioned both in my comment on the answer to the previous question, and also here. That this depends on something outside of Bash is new to me. Nonetheless Ubuntu is primary at the moment because I use zsh on macOS. I mention the behavior on macOS mainly for comparison. If we can get it working on Ubuntu, I can ask another question about Ubuntu/macOS localization differences either here or on the Apple SE site. – iconoclast May 06 '20 at 17:21
  • Please don't put important information in comments - it's far too easy to overlook. Ensure everything relevant is in the question itself. – Chris Davies May 06 '20 at 17:38
  • 1
    My comment was specific to the answer, and (as I mentioned) I had no reason to believe operating system differences were at play. Bash version differences seemed like a more obvious candidate. Overloading a question with probably useless but hypothetically potentially useful information can very easily make the question harder to digest and obscure the central information. – iconoclast May 06 '20 at 17:43
0

You'll have to add the LANGUAGE variable to whatever process is calling bash. This can change depending on how you're accessing the shell. First find the parent process of your shell: ps -o ppid= -p $$, then get the name of that process: ps -ef <pid from last command>. That's the program where you'll have to inject the environment variable. It could be a getty, a terminal emulator like gnome-terminal, or sshd.

John Moon
  • 1,013
  • On Bash 4 on Ubuntu ps -ef $(ps -o ppid= -p $$) gives me a very long list of processes... 143 of them. The one that stands out to me as a likely suspect is /lib/systemd/systemd-logind. (On macOS it gives me just one: /usr/bin/login.) – iconoclast May 06 '20 at 00:31