summaryrefslogtreecommitdiff
path: root/lib/misc.zsh
diff options
context:
space:
mode:
authorfrozen_dude <frozendude@gmail.com>2013-07-29 20:04:23 +0200
committerMarc Cornellà <marc.cornella@live.com>2015-02-10 20:37:35 +0100
commit448e966129bb5c08c7b2da4636491f0f890cf0ab (patch)
treefd61ea0b87364a9639b568d96173897658a7d1d0 /lib/misc.zsh
parent8830f65c4dbb1d1727540c0d1f983237383884f0 (diff)
downloadzsh-448e966129bb5c08c7b2da4636491f0f890cf0ab.tar.gz
zsh-448e966129bb5c08c7b2da4636491f0f890cf0ab.tar.bz2
zsh-448e966129bb5c08c7b2da4636491f0f890cf0ab.zip
Fix for bad LC_CTYPE entry
LANG is a colon-separated list of prefered locales; LC_CTYPE is single entry, therefore we need to remove all but one entry. Also, there is no need setting it if it is already set (LC_ALL also sets LC_CTYPE, so we check it too).
Diffstat (limited to 'lib/misc.zsh')
-rw-r--r--lib/misc.zsh14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/misc.zsh b/lib/misc.zsh
index ea8a05fcb..6987c099c 100644
--- a/lib/misc.zsh
+++ b/lib/misc.zsh
@@ -9,11 +9,21 @@ setopt long_list_jobs
export PAGER="less"
export LESS="-R"
-export LC_CTYPE=$LANG
-
## super user alias
alias _='sudo'
alias please='sudo'
## more intelligent acking for ubuntu users
alias afind='ack-grep -il'
+
+## how to interpret text characters
+if [[ -z "$LC_CTYPE" && -z "$LC_ALL" ]]; then # only define if undefined
+ export LC_CTYPE=${LANG%%:*} # pick the first entry from LANG
+ [[ -z "$LC_CTYPE" ]] && \
+ export LC_CTYPE=`locale -a | grep en_US.utf8 | head -1`
+ [[ -z "$LC_CTYPE" ]] && \
+ export LC_CTYPE=`locale -a | grep en_US | head -1`
+ [[ -z "$LC_CTYPE" ]] && \
+ export LC_CTYPE=C # default to internal encoding.
+fi
+