Thursday, July 28, 2011

Keep mac from "swooshing" to a different space

Do you ever click on a application in the Dock or do Cmd-Tab to switch applications and suddenly you are whipped to a different space? There's a simple fix that I found here. Just type the commands in a terminal. The first command changes the default swooshing property and the second restarts the dock.

defaults write com.apple.dock workspaces-auto-swoosh -bool NO
killall Dock


Note: if you want to restore the default behavior, run the first command with YES instead of NO. And then killall Dock to restart the dock.

Wednesday, July 27, 2011

ssh and scp easier

Do you ever find yourself typing long commands when using ssh or scp? Something like
  ssh username@DNS-name.edu
or
  scp file username@111.222.33.444:~/file


By modifying your ~/.ssh/config file you can change the two previous commands to
  ssh comp1
and
  scp file comp2:~/file
where comp1 and comp2 are your names for the two computers and can be anything.

All you have to do is add a couple lines to you ~/.ssh/config file and you will save yourself a lot of typing.  The steps below outline the proceedure:
  1. Open ~/.ssh/config in your favorite text editor (you may have to create the file)
  2. For each computer you ssh or scp to add a section to the file that looks like

     Host computer_name
     Hostname 111.222.33.444 (or DNS Name)
     User username
     ForwardX11 yes


    computer_name is what you want to call the compter (comp1 and comp2 in the examples), 111.222.33.444 is the IP address for the remote computer (you can also use the DNS Name), username is the user on the remote computer.
That's it!  Now you can ssh and scp to computer_name with ease.

    Tuesday, July 26, 2011

    Mac: Keyboard shortcut to launch program in current space

    Have you ever wanted to open an internet browser or a terminal to do a small task only to find that OS X sends you to an already open program on a different space.  This was really annoying me so I spent some time figuring out a solution that works great for me.

    We'll start with opening a terminal window because it is easier.
    1. Launch AppleScript Editor
    2. Copy and paste the following code into the editor

      tell application "Terminal"
      do script ""
      activate
      end tell


    3. Save the file as ~/Library/Scripts/Open-Terminal.scpt
    4. Open Finder and go to the ~/Library/Scripts folder
    5. Open Quicksilver (if you do not have it install it from here)
    6. Click the small down arrow and click on Triggers
    7. Click the "+" sign to add a new HotKey
    8. Drag Open-Firefox.scpt from the Finder window into the window that opens
    9. Click on the Trigger column to change the Hot Key (shortcut key)
    10. Now when you press the Hot Key a new Terminal window should appear on whatever space you are currently on and open redirect.html which instantly loads www.google.com
    For Firefox
    1. Launch AppleScript Editor
    2. Copy and paste the following code into the editor

      tell application "Firefox"
          open "~/Library/Scripts/redirect.html"
          activate
      end tell


      this code tells Firefox to open and go to redirect.html
    3. Save the file as ~/Library/Scripts/Open-Firefox.scpt
    4. Open Finder and go to the ~/Library/Scripts folder
    5. Create ~/Library/Scripts/redirect.html in a text editor and paste the following code into the file

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
      <html>
      <head>
      <title>Redirecting</title>
      <meta http-equiv="REFRESH" content="0;url=http://www.google.com"></HEAD>
      <BODY>
      <p> Redirecting </p>
      </BODY>
      </HTML>
    6. Open Quicksilver (if you do not have it install it from here)
    7. Click the small down arrow and click on Triggers
    8. Click the "+" sign to add a new HotKey
    9. Drag Open-Terminal.scpt from the Finder window into the window that opens
    10. Click on the Trigger column to change the Hot Key (shortcut key)
    11. Now when you press the Hot Key a new Firefox window should appear on whatever space you are currently on