Welcome to apple.newbox.org Wednesday, November 22 2017 @ 02:21 AM EST  
Links |  Past Polls |  Advanced Search |   
Topics
Home
Applications (8/0)
Classic (0/0)
Hardware (12/0)
Miscellaneous (6/0)
Networking/Serving (3/0)
Mac OS X (13/0)
Terminal/CLI (3/0)
iPhone (3/0)
General News (3/0)
GeekLog (1/0)

User Functions
Username:

Password:

Don't have an account yet? Sign up as a New User

What's New
STORIES
No new stories

LINKS last 2 wks
No recent new links


Older Stories
Saturday 06-Mar
  • iPad thoughts (0)

  • Friday 19-Feb
  • A Couple Small Time Machine Notes (0)

  • Saturday 26-Sep
  • Details about iPhone backups and restore (0)

  • Monday 29-Jun
  • Camera updates in iPhone OS 3.0 (0)

  • Saturday 30-May
  • Mac mini disassembly notes (0)

  • Friday 15-May
  • Notes about Windows 7 on a 10.4 Mac with Virtual Box (0)

  • Monday 02-Mar
  • Safari 4 (Beta) notes (0)

  • Saturday 17-Jan
  • Random software notes (0)

  • Wednesday 17-Dec
  • Quicksilver vs. Spotlight (0)
  • 10.5's Dock still sucks (0)


  • Colorful Terminal    
    Monday, June 13 2005 @ 09:47 PM EDT
    Contributed by: Admin

    Terminal/CLII spend a lot of time SSHing to various boxes. This handy little script will set the Terminal to a certain color when I start a session and set it back to white when I'm done. There's nothing worse than being on one box and thinking you're on another. Also, this makes the minimized icons colorful.

    First of all, we need to learn how the Terminal refers to colors. You can just use basic words like 'white', 'red', etc., but those colors tend to be pretty intense. It's better to use a light tint of a color, so if you want to get custom,

    1. Launch Terminal
    2. Choose 'Window Settings...' from the 'Terminal' menu
    3. Choose 'Color' from the dropdown menu
    4. Click the white box next to 'Background'
    5. Pick a color you like
    6. Copy and paste this line into Terminal exactly as shown:
      osascript -e 'tell application "Terminal" to set x to the background color of the front window'
    7. Jaguar might give an error but you'll still get the output you want. Panther and newer will just give output. What you're looking for is something like this:
      -1, -16950, 4296
    8. Select and copy those numbers.
    Now, we need to write a little SSH script, Here's mine, called 'sshweb,' to get to a website I admin.

    #!/bin/bash
    osascript -e 'tell app "Terminal" to set background color of first window to {15601, -1, 31913}'
    ssh jsmith@example.org
    osascript -e 'tell app "Terminal" to set background color of first window to "white"'

    Line one is the shebang, of course. Line two sets the Terminal to the color I want. Line 3 actually starts the connection. Once you're logged into the remote box, the script is still running as far as the local machine is concerned. The Terminal will stay that color for as long as you're logged in. Once you log out of the remote box, the local script resumes, sets the Terminal back to white (line 4), and exits. Pretty sweet, eh? Use this and you'll always know at a glance where you are.

    Update for 10.5 and 10.6: It seems that Apple has finally gotten smart about color values. It is now three numbers, apparently from 0 to 65k, and apparently just R, G, and B. To get the murky green that used to be "{18712, -25207, 21758}" I now use "{20000, 40000, 20000}".

    Another udpate: when running on a 64-bit CPU, add "arch -i386" before "osascript", like this:
    arch -i386 osascript -e 'tell app "Terminal" to set background color of first window to {48000, 48000, 48000}'
    Thanks http://forums.adobe.com/thread/486208 !

    Bonus tip: and speaking of colors, Mac OS X by default gives monochromatic responses to commands like "ls". To make the actual output colorful, put
    export CLICOLOR=1
    export LSCOLORS=ExFxCxDxBxegedabagacad

    into your ~/.bash_profile. (Thanks http://theappleblog.com/2009/03/26/terminal-tips-using-the-command-line-with-style/ !)

      [ Views: 4763 ]  


    Colorful Terminal | 0 comments | Create New Account
    The following comments are owned by whomever posted them. This site is not responsible for what they say.
    What's Related

    Story Options
  • Mail Story to a Friend
  • Printable Story Format


  • Created this page in 0.29 seconds


     Copyright © 2017 apple.newbox.org
     All trademarks and copyrights on this page are owned by their respective owners.

    Powered By