tmux is one of the tools I use everyday. But one thing always annoyed me: even though I am using X11 forwarding and ssh-agent forwarding when re-attaching to a session, the DISPLAY
and SSH_AUTH_SOCK
environment variables are often wrong. Environment variables are initialized only once when the window was created. tmux is able to update some environment variables for new windows and panes based on the update-environment
setting, however, existing shell windows cannot be updated.
Category Archives: Development
Subversion diff with vimdiff improved
Almost three years ago, I published a bash wrapper function for the svn
command on this blog. This shell function allows to use external tools when calling svn diff
, for example colordiff
, Apple’s FileMerge on OS X or vimdiff.
Performance improvements in the upcoming Subversion 1.7 release
I just tried out a build from the Subversion 1.7.x branch which appears to come close to a final release. Instead of creating .svn
directories everywhere, the new working copy layout switches to a central storage using SQLite. You will only see a single .svn
at the top most directory of the working copy. Details are outlined in the preliminary release notes.
pastie.org shell script
I wrote a bash script to create new pastes on pastie.org. It features automatic source language selection based on the file extension and has a switch to make a private paste.
$ pastie --help Usage: pastie [options] [files...] Options: -h, --help display this help -l, --langset language of the paste -p, --private make paste private If --lang is not specified, this script will try to determine the type of each file automatically based on the extension. If no files are given on the command line it reads from standard input.
You can download it here:
http://pastie.org/904797
The script is public domain, so do whatever you want with it.
Although this is the initial release, I bumped the version number to 1.6 already. During testing the script I pasted itself several times to pastie.org. I set a arbitrary higher version number to avoid confusion in case the previous pastes ever turn up in Google or wherever.
Update:
Seems like their parser for shell is a bit broken and doubles the heredoc starting and ending sequences in the output. For whatever reason it appears as “<<END<<END”. Please use the raw version for download instead of copy & paste.
Calculating sum of numbers in the shell
More than one time I wanted to sum up numbers in the shell.
Imagine a command producing a list of numbers like this:
$ ...
42
23
966
1764
529
4711
Now calculating the sum of these numbers is not trivial. Using tools like bc
or calc
directly is not possible because you would need to put plus signs between the numbers first. So you could probably replace all ‘\n’ with ‘+’ with tr
— but not the last one as that would lead to a syntax error later. Or as an alternative you could write a long shell construct with while read ...
etc. In short this is just getting way too complicated for such a simple task.
Here is the simple solution in awk
:
$ ... | awk 'BEGIN {total = 0} {total += $1} END {print total}'
8035