Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

change osx terminal encoding via command line or applescript

1,190 views
Skip to first unread message

alois....@gmail.com

unread,
Jul 20, 2012, 11:20:18 AM7/20/12
to
We use Mac OSX (Lion) as desktops, and we use terminal windows connecting to a Linux server where we run among other things an old legacy application.

By default the encoding on Mac Terminal is utf-8 and we want to keep it that way.
But this one old legacy application needs the terminal encoding in iso latin 1

We would like to have a possibility to change the terminal encoding by a script
(or command line option for the terminal.app) just when we run this legacy
application.

Is there a known way to do this via Applescript, or other means?

Patrick Stadelmann

unread,
Jul 20, 2012, 11:56:47 AM7/20/12
to
In article <cf6c6c77-b9bd-45ef...@googlegroups.com>,
alois....@gmail.com wrote:

> Is there a known way to do this via Applescript, or other means?

You need to create a duplicate of your default settings in the
preferences of Terminal, named for instance "Legacy". Then, change the
encoding settings.

If it fits your needs, you can simply open "Legacy" window from the
"Shell -> New Window" menu. You can also change the settings of an
already opened window by using the Inspector (Command + I).

If you need to apply the settings from AppleScript, you can do:

tell application "Terminal" to set current settings of front window �
to settings set "Legacy"

If you want to do it from the CLI, just create a shell script with:

osascript -e 'tell application "Terminal" to set current settings of
front window to settings set "Legacy"'

Patrick
--
Patrick Stadelmann <Patrick.S...@unine.ch>

astrodiens...@gmail.com

unread,
Dec 21, 2012, 11:04:19 AM12/21/12
to
Thank you, Patrick.
I have now created such a setting, called Legacy.

I do not want to make it the default, because it is only needed for specific legacy server access.

I can open a window, by starting from an existing terminal window with
Shell -> New Window -> Legacy

I would like a shortcut for that, so that some staff can get this legacy
terminal quickly
a) a keyboard shortcut withing the terminal app
There exists a shortcut for opening a new terminal window with default settings, command+N
I had no success in trying to assign a shortcut to the menu item 'Legacy'
nor to any of the other pre-existing terminal settings which are not default.
Is there a way to assign a shortcut to the Legacy setting style?

b) by writing a short script which starts a new terminal window with the
Legacy setting.
I am afraid I do not know how to do that on Mac OSX.

I am an old Unix/Linux guy with 25 years of working on Unix and later Linux, but OSX is new to me, though I am glad it is Unix-like underneath.

But I have never written an 'Applecscript' and would not know how to do that to start a terminal with these specific settings. I am familiar with shell scripts, of course, but terminal app seems not to be scriptable via command line options.


Patrick Stadelmann

unread,
Dec 24, 2012, 2:08:32 AM12/24/12
to
In article <917b829c-96ae-4051...@googlegroups.com>,
astrodiens...@gmail.com wrote:

> I would like a shortcut for that, so that some staff can get this legacy
> terminal quickly
> a) a keyboard shortcut withing the terminal app
> There exists a shortcut for opening a new terminal window with default
> settings, command+N
> I had no success in trying to assign a shortcut to the menu item 'Legacy'
> nor to any of the other pre-existing terminal settings which are not default.
> Is there a way to assign a shortcut to the Legacy setting style?

You can create a shell script with this command (on a single line) :

osascript -e 'tell application "Terminal" to set current settings of
front window to settings set "Legacy"'

When called, it will apply the Legacy settings to the window.

> b) by writing a short script which starts a new terminal window with the
> Legacy setting.

From the "Settings" tab in the preferences, you can export your Legacy
configuration to a file (via the cogwheel popup menu at the bottom).
Opening this file in the Finder will create a new window with the
specified settings.

If you want to do it from a shell script, use :

open <path_to_legacy_settings_file>
0 new messages