Rechercher dans ce blog

mardi 15 septembre 2009

applescript open ssh window in terminal with specific encoding settings

Je ne suis pas certain du tout que ce script soit tout à fait comme il faut... mais comme je n'ai pas grande idée de comment exactement fonctionne applescript j'ai bidouillé ces deux scripts en glanant ça et là des idées... sans doute y a-t-il une manière plus élégante d'écrire ça... sans doute même des fonctions et des propriétés que j'ignore, mais pour simplement ouvrir 3 fenêtres de terminal avec ssh... du moment que ça marche, c'est bon pour moi.


property commandString : "ssh user@host" -- < Edit this line as desired.


tell application "Terminal" -- Get a free window to run the commandString,

set windowCount to (count of the windows)

--activate

if ((count of windows) is 1) then

close window 1 -- attention, s'il n'y a qu'une seule fenêtre ouverte, elle sera fermée

--tell window 1

-- set miniaturized to true

--end tell

repeat with w from 1 to 3 -- je veux 3 connexions

tell window (windowCount + 1)

do script commandString

end tell

tell application "Terminal" to set current settings of first window to settings set 7

  

--settings 7 = my colors and ISO-8859-1ISO Latin-1 encoding and police 16 pt

tell front window

set zoomed to true

-- Je veux que mes 3 fenêtres soient maximizées et occupent tout l'écran

end tell

end repeat

else

repeat with w from 1 to 3

tell window (windowCount + 1)

do script commandString

end tell

tell application "Terminal" to set current settings of first window to settings set 7

tell front window

set zoomed to true

end tell

end repeat

end if

end tell


*** Autre version, avec trois fenêtres disposées 1 full screen et 2 half screen ***

pour un écran de 1680 x 1050


property commandString : "ssh meteo@mars" -- < Edit this line as desired.


tell application "Terminal" -- Get a free window to run the commandString,

set windowCount to (count of the windows)

activate

if ((count of windows) is 1) then

close window 1

--tell window 1

-- set miniaturized to true

--end tell

repeat with w from 1 to 3

tell window (windowCount + 1)

do script commandString

end tell

tell application "Terminal" to set current settings of first window to settings set 7

tell front window

if w is 1 then

set zoomed to true

else

if w is 2 then

set position to {20, 22}

set size to {825, 960}

--properties

--tell application "Terminal" to set bounds of first window to {0, 0, 820, 975}

else

set position to {850, 22}

set size to {825, 960}

--properties

--tell application "Terminal" to set bounds of first window to {0, 670, 820, 975}

end if

end if

end tell

end repeat

else

repeat with w from 1 to 3

tell window (windowCount + 1)

do script commandString

end tell

tell application "Terminal" to set current settings of first window to settings set 7

tell front window

if w is 1 then

set zoomed to true

else

if w is 2 then

set position to {20, 22}

set size to {825, 960}

--properties

--tell application "Terminal" to set bounds of first window to {0, 0, 820, 975}

else

set position to {850, 22}

set size to {825, 960}

--properties

--tell application "Terminal" to set bounds of first window to {0, 670, 820, 975}

end if

end if

end tell

end repeat

end if

end tell