Text Post

Alfred tips

I have been using Alfred as my application launcher / search engine / file navigator / … for some time now.

Since the pre-release of version 0.9, this application got even more awesome. You can now set global hotkeys to launch applications or run applescripts and you can configure “Terminal shortcuts” that let you run shell commands.

Here are some ways I use Alfred. These tips show how to use some more advanced features of this program. You will find general help in the help section of their website.

1. Search a website

You can use the custom search section in the preferences to add new search options to Alfred. Find the URL used by the website when doing a search and replace the search term with {query}.

If you want to include a “search github” command, use the following settings :
- Search URL : https://github.com/search?q={query}
- Title : Search Github
- Keyword : github 

 

2. Open a website

When you create a custom search that does not include a {query}, you create a shortcut for this website. You can even add a nice icon to the shortcut. I prefer this to importing all my safari bookmarks. 

3. Open a folder

You can use the Terminal Shortcuts setting in the preferences window to add a command for opening a specific folder. Just use “open path_to_folder" as the command. Activate the "Silent" checkbox next to the terminal shortcut to prevent the terminal from opening a new window.

4. Open a file / folder in MacVim

You can also create a terminal shortcut to open a file or folder in MacVim. Use the command “/usr/local/bin/mvim —remote-silent {query}” to do the work and if you check the “Action” checkbox you can even use this command as an action when navigating your directory structure.

5. Copy path to use in file navigation

I use Alfred for file navigation, but sometimes I want to start the navigation from a folder deep in the directory hierarchy : “/Library/Webserver/Documents/” (the location of my local development webserver).

I created a terminal shortcut to make this easier.

the keyword for the shortcut is “webserver” and the command is :

printf "%s" "/Library/Webserver/Documents/" | pbcopy && open -a Alfred

This will add the path to the directory to the clipboard and open the Alfred window again. I only have to use COMMAND-V to paste the path in the search window and I can start navigating my filesystem from this point.