tmux is a terminal multiplexer. It allows you to have multiple virtual consoles open in a single terminal window. Moreover, you can detatch and attach to a tmux session without ending it, allowing you great flexibility when working on remote servers or machines. In many respects it is just like GNU Screen, but is distributed under a BSD license.
Working from tmux: Productive Mouse Free Development from Pragmatic Press I created my initial .tmux.conf file. Over time I have modified my configuration, most recently to improve the status bar information displayed. What follows is a somewhat annotated listing of my tmux configuration.
# use UTF8
set -g utf8
set-window-option -g utf8 on
# make tmux display things in 256 colors
set -g default-terminal "screen-256color"
# set scrollback history to 10000 (10k)
set -g history-limit 10000
# set Ctrl-a as the default prefix key combination
# and unbind C-b to free it up
set -g prefix C-a
unbind C-b
# use send-prefix to pass C-a through to application
bind C-a send-prefix
# shorten command delay
set -sg escape-time 1
# set window and pane index to 1 (0 by default)
set-option -g base-index 1
setw -g pane-base-index 1
# reload ~/.tmux.conf using PREFIX r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# use PREFIX | to split window horizontally and PREFIX - to split vertically
bind | split-window -h
bind - split-window -v
# Make the current window the first window
bind T swap-window -t 1
# map Vi movement keys as pane movement keys
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# and use C-h and C-l to cycle thru panes
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
# resize panes using PREFIX H, J, K, L
bind H resize-pane -L 5
bind J resize-pane -D 5
bind K resize-pane -U 5
bind L resize-pane -R 5
# explicitly disable mouse control
setw -g mode-mouse off
set -g mouse-select-pane off
set -g mouse-resize-pane off
set -g mouse-select-window off
# ---------------------
# Copy & Paste
# ---------------------
# provide access to the clipboard for pbpaste, pbcopy
set-option -g default-command "reattach-to-user-namespace -l zsh"
set-window-option -g automatic-rename on
# use vim keybindings in copy mode
setw -g mode-keys vi
# setup 'v' to begin selection as in Vim
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# update default binding of 'Enter' to also use copy-pipe
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
bind y run 'tmux save-buffer - | reattach-to-user-namespace pbcopy '
bind C-y run 'tmux save-buffer - | reattach-to-user-namespace pbcopy '
# ----------------------
# set some pretty colors
# ----------------------
# set pane colors - hilight the active pane
set-option -g pane-border-fg colour235 #base02
set-option -g pane-active-border-fg colour240 #base01
# colorize messages in the command line
set-option -g message-bg black #base02
set-option -g message-fg brightred #orange
# ----------------------
# Status Bar
# -----------------------
set-option -g status on # turn the status bar on
set -g status-utf8 on # set utf-8 for the status bar
set -g status-interval 5 # set update frequencey (default 15 seconds)
set -g status-justify centre # center window list for clarity
# set-option -g status-position top # position the status bar at top of screen
# visual notification of activity in other windows
setw -g monitor-activity on
set -g visual-activity on
# set color for status bar
set-option -g status-bg colour235 #base02
set-option -g status-fg yellow #yellow
set-option -g status-attr dim
# set window list colors - red for active and cyan for inactive
set-window-option -g window-status-fg brightblue #base0
set-window-option -g window-status-bg colour236
set-window-option -g window-status-attr dim
set-window-option -g window-status-current-fg brightred #orange
set-window-option -g window-status-current-bg colour236
set-window-option -g window-status-current-attr bright
# show host name and IP address on left side of status bar
set -g status-left-length 70
set -g status-left "#[fg=green]: #h : #[fg=brightblue]#(curl icanhazip.com) #[fg=yellow]#(ifconfig en0 | grep 'inet ' | awk '{print \"en0 \" $2}') #(ifconfig en1 | grep 'inet ' | awk '{print \"en1 \" $2}') #[fg=red]#(ifconfig tun0 | grep 'inet ' | awk '{print \"vpn \" $2}') "
# show session name, window & pane number, date and time on right side of
# status bar
set -g status-right-length 60
set -g status-right "#[fg=blue]#S #I:#P #[fg=yellow]:: %d %b %Y #[fg=green]:: %l:%M %p :: #(date -u | awk '{print $4}')::"For a time I used tmux-powerline for my status bar. However this felt like a sledgehammer for peanuts kind of solution. This past weekend I removed tmux-powerline and created the status bar setup shown above. With the potential to show four IP address the left side of the status bar is a bit crowded, but I only ever use tmux in a full screen terminal window so I have real estate to spare.
The right side of the status bar displays the session name, screen and pane numbers, date, and local time, and finally UTC time. The middle of the status bar shows a list of the current windows.
The status bar colors are loosely based on tmux-colors-solarized.
You can see my .tmux.conf, along with my entire dotfiles collection by visiting my dotfiles repository on GitHub.
Increasingly I rely upon libraries and applications installed via Homebrew. In addition the commands for listing installed brews, searching for new brews, or installing brews, there are several maintenance commands that should be run on a regular basis in order to keep your brews healthy and happy.
Rather then run these commands serially, and manually, I’ve created the following alias that runs them for me.
$ alias bu='brew update; brew upgrade; brew cleanup; brew doctor'brew update updates the Homebrew installation making sure you have the latest version installed. It also refreshes the list of available brews to their latest versions.
brew upgrade upgrades any brews you have installed to the latest version as provided for my the update step above.
brew cleanup removes outdated brews from your Cellar and keeps your installation tidy.
brew doctor verifies that all the components necessary for brew to work properly (like having the current Xcode command line tools) are in place and functioning.
Every day I take a moment to run bu in my Terminal and my Homebrew setup works reliably as a result.
Out of the box Mac OS X version 10.8.x (Lion) comes with zsh version 4.3.11 (i386-apple-darwin12.0). However zsh is currently at version 5.0.2 (x86_64-apple-darwin12.2.1). Here’s how to use the newer version.
Install zsh using Homebrew.
$ brew install zshEdit /etc/shells to add a new entry for the Homebrew zsh.
$ brew install zsh
$ sudo vim /etc/shellsThe resulting /etc/shells file should look like this:
$ cat /etc/shells
/bin/bash
/bin/csh
/bin/sh
/bin/tcsh
/bin/zsh
/usr/local/bin/zshThe /usr/local/bin/zsh location is the symlink Homebrew creates when installing zsh.
To actually change the shell assigned to your user account run
$ chsh -s /usr/local/bin/zshNow you have the most recent zsh as your shell.
Removing a Git submodule is nowhere near as easy as adding one. In my projects I typically use a submodule for managing dependencies that are themselves a Git repository. When that dependency goes away it is necessary to remove the submodule. Here’s how I go about that task.
First delete the relevant section from the .gitmodules file at the root of the parent project. This section will have this format:
[submodule "vendor"]
path = vendor
url = git://github.com/some-user/some-repo.gitNext stage the .gitmodules file.
$ git add .gitmodulesNow delete the relevant section from the config file located in the .git directory at the root of the project. It will look something like this:
[submodule "vendor"]
url = git://github.com/some-user/some-repo.gitNow it’s time to use git rm to tell Git to stop tracking the submodule.
$ git rm --cached path/to/submoduleBe careful not to include a trailing slash on the git rm command as it will cause errors.
Now that no longer is tracking the submodule it can be deleted from the file system.
$ rm -rf .git/modules/submodule_nameCommit the changes to the repository.
$ git commit -m "Removed <vendor> submodule."Finally you can delete the actual submodule.
$ rm -rf path/to/submoduleThat’s it. The submodule has been completely removed from Git and removed from the file system.
In order to provide as much as 30-days of stand-by time on Retina MacBook computers that are equipped with Solid-State Drives (SSD) the computer is configured to enter deep hibernation after just one hour stand-by time by default. Upon waking the computer after an hour or more has passed there will be a 3 to 5 second delay as the data that was cached to the SSD is recovered so that the computer’s state can be restored.
I personally found this delay to be annoying and so I changed the stand-by delay to be longer. Instead of the default 4200 seconds, or seventy minutes, I have mine set to 86,400 seconds or 1,440 minutes. Which is 24 hours.
Open Terminal.app and issue the following command to see the current settings.
$ pmset -gHere is the output on my computer prior to changing the standbydelay.
Active Profiles:
Battery Power 1*
AC Power 2
Currently in use:
standbydelay 4200
standby 1
halfdim 1
sms 1
hibernatefile /var/vm/sleepimage
darkwakes 0
disksleep 10
sleep 10
autopoweroffdelay 14400
hibernatemode 3
autopoweroff 1
ttyskeepawake 1
displaysleep 2
acwake 0
lidwake 1By issuing this command,
$ sudo pmset -a standbydelay 86400I changed the stand-by delay to be a full 24 hours.
It is also possible to change the hibernationmode setting, by default 3 to 0 which would eliminate hibernation entirely. I choose to simply delay hibernation rather than eliminate it.
This thread on apple.stackexchange.com has more details.
Since making the change my 13" Retina MacBook Pro awakens immediately on most occasions, as I tend to use it every day.
Rather than use Cicso’s AnyConnect (which has given me trouble in the past) I have setup Openconnect for VPN access.
Here is a high level set of steps to install and configure it for your use. As always, proceed at your own risk, make a backup, complete your last will and testament, and accept that your computer may overheat and fuse into a worthless pile of slag as a result of following these directions.
##Installs You’ll need openconnect and vpnc-script.
I used Homebrew to install openconnect.
$ brew install openconnectThe caveats for openconnect warn you that you’ll need the TUN/TAP kernel extensions. Get TUN/TAP from http://tuntaposx.sourceforge.net/download.html. After running the installer, run
$ cd /Library/Extensions
$ sudo kextload -v tun.kextDownload vpnc-script. I saved mine to /usr/local/bin/vpnc-script. Make sure the script is executable.
$ chmod +x /usr/local/bin/vpnc-script##Configuration You can view the openconnect command options by running
$ sudo openconnectRather than enter the options each time you want to create a virtual private network, create an openconnect configuration file and put the configuration values you need there.
$ cd ~
$ touch .openconnect
$ vim .openconnectHere is my .openconnect file:
authgroup=*****VPN
user=****
no-cert-check
script=/usr/local/sbin/vpnc
background
passwd-on-stdinFill in your own authgroup and user information.
There is no configuration necessary for vpnc-script.
##Running openconnect With a configuration file in place, here’s how to start a VPN:
$ sudo openconnect --config ~/.openconnect https://your.vpn.urlIf you don’t want to have to enter your local account password for the sudo command, you can add an exception for the openconnect command to /etc/sudoers, like so:
$ sudo visudo -f /etc/sudoersAnd add this line to the file:
%admin ALL=(ALL) NOPASSWD: /usr/local/bin/openconnectFinally, create an alias for the openconnect command above to make life easier.
Seven years ago I lost 57 pounds using a spreadsheet. This year my goal is to lose more weight using a variety of iOS apps on my iPhone.
In a nutshell I am hacking my eating and exercise lifestyle. I am watching what I eat in an effort to eat less. And I am tracking what I do in an effort to exercise more. So far I’ve lost 15 pounds at an average of just under 4 pounds a month.
Seven years ago I used an Excel spreadsheet to record everything I ate. I’d look up the calories on the Internet and record them. I also tracked, using a 5-day running average, my weight.
This time around I’m using LoseIt!, WeightBot, Moves, and a FitBit Flex.
##LoseIt! LoseIt is at heart a calorie counter. It allows me to quickly and easily record the foods I eat and gives me a budget of calories for each day. I can also enter exercises or activities, lawn mowing for example, so that I can see at a glance whether I am ahead or behind on calories for the day.
The LoseIt database is large and includes nutrition information for many brand foods and restaurants. One of its best features is the ability to scan a UPC code and look up food item. It also remembers previous meals so you can quickly re-use something you recently had. I tend to eat the same thing for breakfast every day and rather than have to enter milk, cereal, and orange juice, I can just select the meal from the previous day.
LoseIt is free and there is a premium version if you want more features.
##WeightBot WeightBot is a simple weight tracking app. You can quickly and easily record your weight. It also has some very nice graphs allowing you to see your weight trends. I entered in a goal weight and date and each day I can see where I am on reaching that goal at a glance.
The app is very nicely put together and is well worth the $1.99 price.
##Moves Moves is a free app that uses the accelerometer and GPS features of your phone to track your movements throughout the day. As long as you keep your phone in your pocket you’ll get a pretty good approximation of how many steps you’ve taken in a day. Moves uses the iOS notification system to send you a morning summary of yesterday’s activity meaning you don’t ever have to open the app. Just install it and go.
Since it uses the location feature of the phone it does drain the battery. They claim that when the phone isn’t moving that battery drain doesn’t occur, but I have to charge my phone in the later afternoon or early evening. Otherwise by 9 pm (after being up for 14 hours) the phone will be under 20% charge remaining.
I think Moves is reasonable accurate and over time it lets you see what your average activity is in a very general way. Think of it as a free version of a FitBit.
##FitBit Flex The latest addition to my arsenal of weight/exercise toys and apps is a FitBit Flex. This is an activity monitor that you wear 24x7. It monitors your activity and sleep patterns.
I’ve only had mine for a couple of months and it has already proved to be very interesting. There is a companion iOS app that allows me to see at a glance how many steps I’ve taken or how many “very active” minutes I’ve had that day.
You can set goals for steps taken and the iOS app then cheers you on through notifications. I haven’t changed the default 5 miles or 10,000 steps goal. Most days I’m in the 8500 - 9500 step range, with an occasional 14000 step day just to throw the curve off.
It is interesting to see the sleep patterns it records, with information like time to fall asleep, number of times awake, and actual time asleep versus time in bed. My wife has a Flex too and here sleep patterns are different than mine. Rarely does one person being awake disturb the other.
##Using Technology to Lose Weight None of these apps nor the FitBit Flex will by themselves help you lose weight. All they can do is give you an awareness of what you are eating and what you are doing on a regular basis. When I used the spreadsheet in 2006 to lose weight I was shocked at first to discover the amount of snacking I was doing and at how costly (in terms of calories) those snacks were. I was able to eliminate 1000 calories a day from my diet without really working at it. As a consequence I was losing 2 pounds a week for a while.
This time around I am fine tuning my eating and increasing my exercise. The weight loss isn’t as dramatic but I am very pleased with the improved lifestyle my refocused awareness is producing. That the apps are fun to use and interact with only makes it easier to accomplish.
I do not believe in diets. To my mind a diet is an aberration of your normal lifestyle. You make a temporary change which does in fact alter your weight but when you end the aberration the weight returns. What I did seven years ago was change my lifestyle to eliminate snacks and to increase my activity. This year I am once again altering my lifestyle. We bought a treadmill last winter and I am walking on it at least 5 times a week. I’ve covered over 200 miles in the past 3 months.
My ultimate goal is to have a healthy, active lifestyle. If that happens to produce a lower weight that I can maintain without effort all the better.
TwelveSouth’s SurfacePad for iPhone 5 and 4/4S is once again available after nearly five months unavailability. I have been fortunate enough to be beta-testing the iPhone 5 version since early June.
##Fit, Finish, and Color It is perfectly sized for my iPhone 5. I had to apply it twice to get the edges aligned with the edges of the iPhone. However, it is easy to remove and realign so this isn’t a problem. I also had to fit the iPhone 4S SurfacePad twice when I installed it.
The back color of the black iPhone 4S was (if I remember correctly) uniformly black from top to bottom. The iPhone 5 has a black band across the top 10th and bottom 10th of the back. The middle 80% is slate colored. The remove for the camera lens, flash LED, and video microphone, in the folio is large enough to expose a bit of the slate color in addition to the glossier black at the top. This creates a tricolor effect: the muted black leather, the glossy black of the phone, and the muted slate of the back’s center piece. I realize that room is required around the lens and flash so as not to impede their function. Still it would be interesting to know if a smaller remove in the back cover, one that was flush with the union between the slate and glossy black (perhaps with a chamfer to keep it out of the way of the lens optics or flash) would work.
Having the slate exposed is not a deal breaker for me, but it is distinctive.
The stitching along the hinge on the back is smooth and even. On my previous SurfacePad (for the iPhone 4S) one of the stitch ends was slightly exposed and, while not sharp, was noticeable.
When closed the SurfacePad lays smoothly across the face of the phone and stays in place under its own weight. When opened the cover lays flat against the desktop.
The color (black) is even all over, and the leather is smooth and blemish free. The embossed “12” logo on the outside of the front cover is nicely understated. The interior color (gray) is also smooth and unblemished. The “SurfacePad” and “12 TwelveSouth” embossing are clear and nicely lined up with the edges of the folio. The slight chamfer around the edges of the folio’s cover is even all around, both inside and outside the cover.
The embossing for the volume up and down buttons are nicely understated. Both appear to be slightly toward the back of the case, i.e., ever so slightly off center. They do line up with the volume controls.
The hinge for holding the phone in landscape position is was a bit stiff when the case was new, but it has broken in nicely. It holds the phone at a good viewing angle.
The new leather had a wonderful aroma. Now that it has aged a bit the aroma isn’t as apparent. It lingers just at the edge of your awareness.
##Packaging The packaging is imaginative and makes for a good “out of box experience”. I especially like the cardboard iPhone 5 mock-up that the folio comes with. I also like the TwelveSouth decals that are provided. It would be ideal if the removable film on the back of the decal could say “permanent” or “removable” so that who ever apples one knows whether or not they are decorating their laptop or whatever permanently or not.
##Use and Wear With my previous SurfacePad I noticed that over a few weeks time the cover was slightly askew when closed. This, I believe, was due to my inserting the phone into my front pants pocket in the same orientation every time. When I noticed the way the cover was forming as a result of this, I started alternating how I put the phone in my pocket. One time power-switch-end first, one time power-switch-end last, sometimes face toward my leg, sometimes face outwards. After two-and-a-half months use the iPhone 5 case hasn’t produced any skewing of the cover. I usually put my phone in my pocket the same way out of habit, but when I think of it I switch the orientation around.
There are two places where the adhesive on the leather is slightly apparent. It isn’t sticky but there is a little discoloration along the edge next to the SIM-card slot and a smaller blemish along the bottom. Neither is really objectionable, they just add a little character to the folio. There are a couple of places along the cut edges of the cover that are now distressed. Again, this just adds character to the folio.
Having a hinged cover on your phone does alter how you interact with it. I religiously hold the phone in my left hand during phone calls. Consequently I fold the cover back against the rear of the phone while holding it. When I use the phone at my desk or a table I just flip the cover open so that it lays next to the phone. Using the phone with just my right hand (I’m primarily right handed) is easy. Using it with just my left hand is a tad trickier as the cover is in the way. My hands are large enough that I can pick up the phone open the cover and fold it behind single handed even on the left side.
The leather has enough grip to keep it from sliding when placed on a mildly sloped surface. I used my iPhone 5 naked for a couple of months before getting the SurfacePad and found the phone to be extremely slippery. The tactile feel of the leather is pleasing and I feel my phone is much more secure in my hand; especially when removing it from my pocket.
I use the hinged-stand quite a bit while practicing cello, as it holds the tuner/metronome app I like at the perfect viewing angle.
Taking photos or videos requires that you deal with the cover. While it is obvious that you can’t fold the cover back since it will cover the lens, it is surprising the number of times I have done just that. I rotate the phone so that the Home button is to the right to reach landscape orientation. This allows the cover to dangle out of the way. If you prefer the Home button to the left you would have to hang on to the cover in order to use the camera.
##Conclusion On the whole I am extremely pleased with my SurfacePad. I liked the original one for the 4S enough that I worked hard at getting one for my iPhone 5. It is distinctive and classy in a very understated way. It minimally protects the phone, choosing to enhance its overall appearance rather than protect it at the cost of hiding the fine machining of the phone’s exterior.
As I said at the end of my iPhone 4S SurfacePad review, it isn’t the least expensive cover you can get for your iPhone, but its quality, fit and finish enhance the phone wonderfully.
Note: I was given a beta SurfacePad to test as a result of contacting TwelveSouth.
Back in the day, when I had an 80-pound glass and steel mainframe terminal on my desk, there was only one place I had to go to change my password every month. Eventually I had access to more than one mainframe system and then I had two or three passwords, but still just one place I had to go to change them.
This afternoon I completed the bi-annual password change required by the university. The following list is all the places I needed to go to complete this one password change.
I am certainly not advocating returning to the limited technology of mainframes in the early 1980s, but there has to be a better way to manage our means of authentication than some 20 password changes in 10 locations. I’m technologically savvy. In making my list of anticipated password changes I only missed enumerating one change. How do non-technical people who have a smartphone and a table and a laptop and a desktop manage to survive this recurring chore?
Some aspects of our increasingly technological society are making life easier and better, but other aspects have only become more daunting and tedious. Hopefully there is some startup out there with a novel approach to biometric identification or password management that will remove this odious chore from our lives.
For my day job I’ve been doing a lot of work with Chef, Vagrant, and veewee. All of these tools are continually evolving and, over the course of several weeks time, I’ve updated versions more than once. As a result my set of Ruby Gems was causing some conflicts trying to run vagrant up after using veewee.
To clear things up so that I could make better use of RVM Gemsets to manage what Gems were loaded for a given process, I wanted to delete all Gems installed on my machine. A quick StackOverflow search lead me to this command:
$ [sudo] gem list --no-version | xargs [sudo] gem uninstall -aIx
While I’ve marked sudo as optional, you should use them as a pair — either have both of them in the command or neither of them.
Running this command didn’t work as expected as it ran afoul of the default gems that are pre-installed with Ruby. Another search lead me to this gem-reset Gist on GitHub.
#!/usr/bin/env ruby
# Remove all gems EXCEPT defaults :)
`gem list -d`.split(/\n\n^(?=\w)/).each do |data|
match = data.match(/(?<name>([^\s]+)) \((?<versions>.*)\)/)
name = match[:name]
versions = match[:versions].split(', ')
if match = data.match(/^.*\(([\d\.]*),? ?default\): .*$/)
next if match[1].empty? # it's the only version if this match is empty
versions.delete(match[1] || versions[0])
end
versions.each { |v| system "gem uninstall -Ix #{name} -v #{v}" }
endThis script removes all Gems except the ones marked as default. I forked it and used the wget option to run it. Once the script completed my machine only had the default gems installed.
For each of my Ruby-based projects I added a .ruby-gemset and .ruby-version file specifying the gemset name I wanted and the Ruby version desired. Next I visited each project, checked that the gemset was in use, and ran bundle install to re-install the gems, this time in managed gemsets.
This not only cleared up the gem conflict I had introduced, but has made seeing and managing my installed Gems easier.