16 Oct 2017

OS X Terminal Tweaks

macos howto osx bash    

Some tweaks to my OS X shell (Terminal.app) that I've found useful.

I'm using the Solarized Color Theme:

  • In Terminal > Preferences, choose to open new windows with the Solarized Dark.
  • The theme Profile > Text section has Use Bold Fonts checked.
  • Under the Window section, I prefer to check the Working Directory or Document and Path options, so the terminal window title is the the current directory.
  • Under the Shell section, select When the Shell Exits, Close the shell if exited cleanly.

Terminal Profile Perferences

In my logged in users' home directory, .bash_profile contains:

export CLICOLOR=1
export PS1="\[\e[36m\]\w\[\e[0m\]$ "
alias ll='ls -GFhl' dir='ls -GFhl'
alias start=open
printf "\033]0;`date "+%a %d %b %Y %I:%M %p"`\007"
alias title='printf "\033]0;%s\007"'
  • Line 1: Enable colors for ls (without requiring the argument -G)
  • Line 2: Set the Shell prompt to show the current directory in cyan. I really don't need to know my user and hostname.
  • Line 3: To save me from slips, ll and dir will show the long file listing. The former is a hangover from my UNIX days, while the latter is from Windows.
  • Line 4: When entered as start . (i.e. open .) opens Finder to the current directory à la Windows (I've got loads more of these Windows-like in my profile).
  • Line 5: Set the Terminal title to the date and time it was started.
  • Line 6: An alias to change the title, again just like DOS! Useful to quickly distinguish between Terminal windows.

Terminal

And finally, to allow keyboard entry while hovering over Terminal (without setting focus first and even when the Terminal is partially obscured), i.e. "focus follows mouse":

defaults write com.apple.terminal FocusFollowsMouse -bool true

You need to re-start Terminal by Quitting it before it takes effect!

Edited 28 April: Corrected the PS1 prompt color

Updated 20 June: Recently stumbled upon an old tip from Xensoft to speed up opening a new terminal window/tab.

Normally, terminal will display the last login time, which requires a scan though the Apple System Log. To disable this, create a file .hushlogin in your user directory, e.g.

cd
touch .hushlogin

Related Posts

Newer Post Older Post