Sep 21

Strange, but I couldn’t empty the trash of a mounted SD card. Importing photos is no problem, because iPhoto offer to delete the photos after import. Importing videos with iMovie is different. When I copy the raw data only I have no option to empty the SD card.

Terminal to the rescue

chflags -R nouchg .Trashes/
rm -rf .Trashes/*

Caution: The first line clear recursively the user immutable flag

Tagged with:
Sep 17

The preferences of the Terminal.app doesn’t offer to define a keyboard shortcut. Using Spotlight to open apps is sufficient in most cases. If you use an app like the Terminal more often you might be looking for a simple keyboard shortcut. Install Quicksilver and add a custom trigger:

Now pressing Option-T opens the Terminal or gives it focus.

Tagged with:
Aug 29

This one is a must have! If you use IDEs like IntelliJ IDEA you are used to press magic keys. Here is how you add some magic to the usage of git from your bash terminal. You need the git bash completion. If you use Homebrew and installed git you can start immediately with modifying your bashrc. In my case I change /etc/bashrc.

Git Completion

# add git completion
source /usr/local/etc/bash_completion.d/git-completion.bash

That’s it! Now enjoy the power of the tab-key: Complete git commands, sub-commands, branch names, remotes, …

Git Prompt

The above defines a git prompt as well. You need to add $(__git_ps1 ” %s”) to your prompt.

PS1='\[\e[0;32m\][\w]$(__git_ps1 " %s")\n\u@\h$\[\e[m\] '

Everything between the double-quotes will be displayed in your prompt. The %s will be replaced with the current branch name. Some more information can be
added with flags (see comments in git-completion.bash). I like these:

GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWUPSTREAM="auto"

GIT_PS1_SHOWDIRTYSTATE displays unstaged changes “*” or staged changes “+” next to the branch name. GIT_PS1_SHOWUPSTREAM=”auto” indicates if you are behind “<", ahead ">” or diverged “<>“.

Sample

KYPSTA-2902-hdnCode-for-SecurityProvider is the branch name, I have untracked files and I’m ahead. Cool.

To do a good job we should finish with coloring our terminal.

Tagged with:
Aug 29

Terminal Coloring
Here is what is necessary to achieve the above layout and coloring. I want these changes for all my accounts on my laptop, so I edit the /etc/bashrc.

# terminal coloring
export CLICOLOR=1
export LSCOLORS=dxfxxxxxbxegedbxbxdxdx

CLICOLOR=1 enables the coloring. LSCOLORS defines the coloring. There are 11 attributes that can be colored. Each attribute has a foreground and a background color. A color is represented by a single character, now we have our 22 character string: dxfxxxxxbxegedbxbxdxdx. See the manual of ls and search for LSCOLORS for details.

Prompt
I like to have the prompt always at the same spot and want to see the full path of the working directory. Therefore I change the default prompt:

# two line prompt with full path
PS1='\[\e[0;32m\][\w]\n\u@\h$\[\e[m\] '

Explained:

  '\[\e[0;32m\]     change font to green
  [\w]\n            current working directory + newline
  \u@\h$            user@host$
  \[\e[m\] '        stop the green coloring and add a trailing space

What else is possible? See enhance the system prompt.

Tagged with:
preload preload preload