solution works for bash, zsh, tcsh on linux, osx, cygwin