Posts Tagged ‘terminal’
Wednesday, October 6th, 2010
I was completely useless the other day when Command Tab (or Apple Tab) stopped working. Also my dock wouldn’t show up. I was able to regain these features by opening Terminal.app and issuing:
killall Dock
Apparently Dock also controls the Command Tab feature.
Tags: dock, mac os x, terminal
Posted in code | No Comments »
Sunday, September 5th, 2010
If you wake your mac from sleep and suddenly your screen is all a slightly blueish hue. Open up Terminal.app and issue this command:
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/DMProxy
Update: This also works if you screen gets a funny bluish tint when Powerpoint slideshow mode goes back and forth from fullscreen.
Tags: blue, mac os x, screen, sleep, terminal
Posted in code | No Comments »
Saturday, July 3rd, 2010
On my Mac os X 10.6 machine at work I’ve suffered from slow scroll speed using vim with syntax highlighting in Terminal.app. The screen refreshes very slowly when using colored syntax highlighting in vim and only in Terminal.app (xterm is fine, but I don’t like to have to start x11 and all just for a terminal, and anyway Terminal.app is fine otherwise).
Apparently something got broken during Terminal.app version 2.0.2 and Terminal.app version 2.1, the latter even being 64-bit. Who knows what it was but I can find any reason to use the new Terminal so I will use the old one on the new machine.
I’m backing up my old copy of terminal, but you should probably find your own to be safe. The scroll speed works fine with the old Terminal.app. Just drag it over from an intel machine and it should work find. All my bash profiles and vimrc loaded just fine, so I didn’t need to set anything else up.
Tags: 10.5, 10.6, bash, mac os x, terminal, vim, xterm
Posted in code | 2 Comments »
Wednesday, June 16th, 2010
Just started working on a snow leopard machine and have been annoyed that the screenshots are saved as PDFs. To switch back to png I opened Terminal.app and issued this command:
defaults write com.apple.screencapture type png
Then you must issue:
killall SystemUIServer
to make the change take effect.
Note: You can replace png in the above with any of these: png, pdf, tiff, pict, bmp, gif, psd, sci, or tga.
source
Tags: 10.6, grab, mac os x, pdf, png, screenshot, snow leopard, terminal
Posted in code | No Comments »
Monday, April 12th, 2010
Here’s a little script I’ve been meaning to write for while. Often I’m roaming around in the Finder GUI and I want to switch to a terminal. This is not so hard if I already have a terminal window open I can type cd into the command line then drag the current folder I’m looking at in Finder onto the terminal window and I get the full absolute path to that file. Then I hit enter to navigate there on the command line.
To make this totally effortless and seemless if Terminal.app is not already running. I wrote the following applescript:
-- if not given files then just act like opening a terminal to the home screen. I.e. `cd`
tell application "Terminal"
activate
do script ""
end tell
-- if fiels are drag-and-dropped on this app
on open (these_files)
-- just use first file if more than one
set this_path to (quoted form of basedir(POSIX path of (first item of these_files)))
tell application "Terminal"
activate
do script "cd " & this_path
end tell
end open
on basedir(the_path)
set last_occurrence to last_offset(the_path, "/")
if last_occurrence is equal to 0 then
return "."
end if
if last_occurrence is equal to 1 then
return "/"
end if
return items 1 thru (last_occurrence) of the_path as string
end basedir
on last_offset(the_text, char)
try
set len to count of the_text
set reversed to reverse of characters of the_text as string
set last_occurrence to len - (offset of char in reversed) + 1
if last_occurrence > len then
return 0
end if
on error
return 0
end try
return last_occurrence
end last_offset
Using some older functions I wrote:
last offset of a character in a string
base directory of a POSIX path
Then I save as an application and drag a shortcut onto my finder bar.
Tags: applescript, cd, command line, finder, mac os x, posix, terminal
Posted in code | No Comments »
Sunday, March 14th, 2010
Found this list of Bash keyboard shortcuts on Mac OS X. Here are my favorites that I want to remember:
Say you have typed ( where the pipe, “|”, represents where your cursor is):
mv foo bar|
Then if you hit CTRL+[ then B you will move back one word:
mv foo |bar
To go forward again hit CTRL+[ then F:
mv foo bar|
Now the coolest one, to swap the last two words hit CTRL+[ then T:
mv bar foo|
Tags: bash, mac os x, terminal
Posted in code | No Comments »
Friday, November 6th, 2009
This is posted all over the web, but sanity’s sake I’ll post it again here. This use of the unix command line program find will locate and remove all the .DS_Store files that Finder populates throughout your directories. The following removes all files by the name .DS_Store in the current directory recursively:
find . "-name" ".DS_Store" -exec rm {} \;
Tags: find, linux, mac os x, rm, terminal, unix
Posted in code | No Comments »
Sunday, September 13th, 2009
Here’s a simple script to open Terminal.app and execute a shell script.
tell application "Terminal"
activate
do script "ls"
end tell
Note: Note the subtle difference from another applescript feature you might be used to, namely do shell script. The latter, do shell script, when executed anywhere in an applescript runs a script at root level (but without root permissions). So running a script like:
set contents to do shell script "ls"
The variable contents will hold the return of ls for the root directory, /. On the other had something like the code at the top will execute ls at the default location of a new Terminal window, which (unless you have changed it) is by default the home directory of the current user. So in a Terminal tell block,
do script "ls"
opens a new terminal window and executes ls in that window, presumably at the user’s home directory, ~.
Tags: applescript, bash, ls, mac os x, terminal
Posted in code | No Comments »
Monday, September 7th, 2009
I recently upgraded to Mac OS X 10.5 and reinstalled vim (VIM – Vi IMproved 7.2). I noticed that the delete key on my keyboard was forward deleting (deleting the next character to the right of the cursor) rather than backward deleting (deleting the previous character to the right of the cursor). It felt like the backspace and delete (windows-style) keys had been switched or swapped.

I fixed the problem by changing my Terminal.app settings. Under Terminal > Preferences choose Advanced. Check “Delete sends Ctrl-H”. Now, vi and vim should understand the delete key more intuitively.
Note: Mapping the “delete” key in my vimrc file seemed like probably the correct way to do this, but that’s a lot of trouble. Is there any reason not to do it this way?
Tags: 10.5, backspace, delete, mac os x, terminal, vi, vim
Posted in code | No Comments »
Monday, July 27th, 2009
Tags: command line, drive, external hard drive, file, folder, icon, image, mac os x, terminal, volume
Posted in code | 3 Comments »