aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-06-29 19:05:11 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-06-29 19:05:11 +0200
commit1576639e6aed9ac98ba9c43dbc34123a6f45d25d (patch)
tree30924cecd1475e3d5d167942546886b9095fa940
parent8a00961524ba5bf2a65eaab1ccc496cf02471280 (diff)
downloadxutil-1576639e6aed9ac98ba9c43dbc34123a6f45d25d.tar.gz
Add 'iso8859-1' and 'utf8' utilities
I use these to open vi in iso8859-1.
-rwxr-xr-xiso8859-13
-rwxr-xr-xutf83
-rwxr-xr-xxtopen20
3 files changed, 21 insertions, 5 deletions
diff --git a/iso8859-1 b/iso8859-1
new file mode 100755
index 0000000..da1d5a5
--- /dev/null
+++ b/iso8859-1
@@ -0,0 +1,3 @@
+#!/bin/sh
+export LC_ALL=en_US.ISO8859-1
+exec "$@"
diff --git a/utf8 b/utf8
new file mode 100755
index 0000000..21598b3
--- /dev/null
+++ b/utf8
@@ -0,0 +1,3 @@
+#!/bin/sh
+export LC_ALL=en_US.UTF-8
+exec "$@"
diff --git a/xtopen b/xtopen
index 7774377..3b698a8 100755
--- a/xtopen
+++ b/xtopen
@@ -14,16 +14,20 @@ abbr() {
if [ $# -eq 0 ]; then
xmessage -buttons sorry:0 -default sorry -nearmouse \
- "usage: $0 [-k] [-K] cmd ..."
+ "usage: $0 [-i] [-k] [-K] [-u] cmd ..."
exit 1
fi
+i=
k=
K=
-while getopts kK o; do
+u=
+while getopts ikKu o; do
case $o in
+ i) i=1 ;;
K) K=1 ;;
k) k=1 ;;
+ u) u=1 ;;
?) xmessage -buttons sorry:0 -default sorry -nearmouse \
error: "unknown flag $1"
exit 1 ;;
@@ -37,8 +41,14 @@ if ! which "$1" >/dev/null; then
exit 1
fi
+prefix=
+
+[ ! -z "$i" ] && prefix=$prefix\ iso8859-1
+[ ! -z "$u" ] && prefix=$prefix\ utf8
+
case "$k,$K" in
-1,*) exec xterm -title "$* (`abbr "$PWD"`)" -e with-shell "$@" ;;
-*,1) exec xterm -title "$* (`abbr "$PWD"`)" -e with-shell-on-error "$@" ;;
-*,*) exec xterm -title "$* (`abbr "$PWD"`)" -e "$@" ;;
+1,*) prefix=$prefix\ with-shell ;;
+*,1) prefix=$prefix\ with-shell-on-error ;;
esac
+
+exec xterm -title "$* (`abbr "$PWD"`)" -e $prefix "$@"