Showing posts with label macosx. Show all posts
Showing posts with label macosx. Show all posts

Tuesday, 21 August 2012

OSX Terminal: alt-left jump word ctrl-left go to start and more

By default OSX Terminal doesn't let you use many standard OSX text-editing shortcuts. For example, CMD or Control Left normally jumps to the start of the line. Alt-left jumps left one word. Also forward delete doesn't work.

Happily it's possible, though slightly confusing, to add these shortcuts back.

Here's how:
  • Open Terminal Preferences
  • In the Settings Pane, select Keyboard


  • Click the + button



  • Now let's add those shortcuts back.
For jump-to-start-of-line:
  • Key: Cursor Left
  • Modifier: Control
  • Action: send string to shell: (the default)
  • Click in the empty white box and press CTRL-A. \001 will appear
For jump-to-end-of-line:
  • Key: Cursor Right
  • Modifier: Control
  • Action: send string to shell: (the default)
  • Click in the empty white box and press CTRL-E. \005 will appear
To re-activate forward delete
  • Key: forward delete
  • Modifier: none
  • Action: send string to shell: (the default)
  • Click in the empty white box and press CTRL-D. \004 will appear
To move forwards one word at a time
  • Key: cursor left
  • Modifier: option
  • Action: send string to shell: (the default)
  • Click in the empty white box and press Escape+b. \033b will appear
To move backwards one word at a time
  • Key: cursor right
  • Modifier: option
  • Action: send string to shell: (the default)
  • Click in the empty white box and press Escape+f. \033f  will appear.


I find adding these shortcuts in makes terminal much more usable. 


Thursday, 23 December 2010

Building FFMPEG on Mac OSX Snow Leopard

FFMPEG is an amazing set of video and audio conversion tools, accessible via the command-line. It's rather fiddly to use, but being a command-line program it can be easily integrated into your server-side tools. The sequence of steps below worked perfectly for me on Snow Leopard with XCode 3.2.4 installed.

cd ~
# checkout the latest version of the source
svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
cd ffmpeg

# enable mp3 support (you need to install lame first. omit --enable-libmp3lame to build without it)
./configure --enable-libmp3lame --enable-shared --disable-mmx --arch=x86_64

# compile
make

# install
sudo make install



Example Commands


Here are some of the commands I've run so far..

Rotate a video 90 degrees clockwise (good for films shot in portrait


ffmpeg -vf "transpose=1" -i input.mp4 output.mp4

Note that there are many tutorials on the web that suggest you should use --vfilter "rotate=90" to rotate a video. This no longer works, as vfilters has been renamed vf, and the rotate option has been removed. As of Dec 2010, the above command does work.

Convert a mp3 to a flv audio file


ffmpeg -y -i myfile.mp3 -f flv -acodec libmp3lame -ab 64 -ac 1 myfile.flv

I'm using this command as part of a project I'm working on, flv is better than mp3 as you can stream (using flowplayer) an flv in such a way that user can jump around to any point of the audio without needing to download it all to that point. However, this is quite fiddly, a future blog post will explain how I did this!

Wednesday, 24 November 2010

Mac OSX - Making the finder search work (almost) properly

One thing that has irritated me for a long while is that the search box in the top right of the finder window in mac osx defaults to searching my whole mac, and not the folder I'm currently looking at. If I wanted to search the whole Mac I'd use the Spotlight search wouldn't I Mr Jobs?

Anyway, I just discovered that it's possible to change this behaviour. Open Finder, go to the menu and choose Finder / Preferences / Advanced, and select 'When performing a search: Search the current folder".



So much better!
Now I just need to find a way to make it search by FIle name and not file contents.

EDIT: Apparently there is no way of defaulting to search by file name in Snow Leopard. However, in finder you press CMD-SHIFT-F, then it will put the cursor in the search panel, and set it to search by file name. Not too bad at all!

Monday, 25 October 2010

Remove the MobileMe icon from the menu bar on Mac OSX

The fact that Apple's MobileMe icon installs itself on my menu bar despite the fact I have no intention of ever using it was starting to annoy me. There's no obvious way of removing the icon or uninstalling the app I could find anywhere.

However, thanks to this post, it turns out to be really easy to remove it.

Simple hold CMD, and drag and drop the mobile me icon off the menu bar. It disappears in a puff of smoke never to be seen again. Hurrah!

Wednesday, 6 October 2010

Allowing SymLinks in Mac OSX Web Sharing

The Web Sharing feature in Mac OSX allows you to share a folder in your home directory via Apache.
What I often want to do is to temporarily share a web site or suchlike that I'm currently working on, so I can access it via my iPhone for on-device testing. So what I wanted to do was to create a symlink from my ~/USERNAME/Sites folder to the actual folder where I'm working.

However, by default, any SymLinks within Sites not be followed due to the apache configuration. Happily this can be easily fixed.

Edit the file at:

/private/etc/apache2/users/USERNAME.conf


Which by default looks like this:

Directory "/Users/USERNAME/Sites/"
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
/Directory


To add the FollowSymLinks option. So the file should look like this:

Directory "/Users/USERNAME/Sites/"
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
/Directory


Then all you need to do is restart apache and you are done!

From the terminal type:

sudo apachectl graceful

Wednesday, 8 September 2010

Mac OSX Terminal: Recursive list of files in directory excluding .svn and .DS_Store folders / files

Those pesky .svn and .DS_Store files and folders are the enemy of many a terminal command..
Here's how to get a handy list of all files in a folder without them, in a simple format for later processing.

find * -type f | grep -v "\.svn" | grep -v "\.DS_Store"


Outputs:
App-Info.plist
Default.png
GpsDrawTheme/theme.json
RootModule/code/common.js
RootModule/code/db.js
RootModule/code/drawing.js
RootModule/code/drawingMenu.js
RootModule/code/index.js
RootModule/code/instructions.js
RootModule/code/myDrawings.js
.. etc


I'm sure there's a way this could be simpler, but this works for me.

Wednesday, 1 September 2010

MacOSX: Opening documents, folders, and applications from the command line

The Mac OSX command line has a very handy 'open' cp,,amd which tells the Mac OS UI to open the item you pass in. This is great for switching from using the terminal to using the UI for those times when the UI is more convenient.

Open the current folder in Finder
open .


Open a file using the default application
open mydoc.txt


Open a file a specific application
This is the same command as right-clicking on an item in finder and choosing 'Open With'. It can be really handy for testing an html file in a specific browser.

open -a /Applications/Safari.app index.html