Skip to content

Instantly share code, notes, and snippets.

@rud
Forked from bjensen/vol
Created November 12, 2012 10:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rud/4058591 to your computer and use it in GitHub Desktop.
Save rud/4058591 to your computer and use it in GitHub Desktop.
open the newest file of a directory in vim
# --------------------------------------------------------
# vol as a shell script
# --------------------------------------------------------
# You would put this code in a directory that's in your
# path, like ~/bin (PATH=~/bin:$PATH in your .bashrc to
# add a directory like that to your path.)
# The invokation syntax is the same as that of the
# function.
# --------------------------------------------------------
# Example usage:
# vol
# vol path/to/directory
# --------------------------------------------------------
#! /bin/sh
unset latest
for file in "${1:-.}"/*
do
if [ -f "$file" ]
then
latest=${latest-$file}
find "$file" -prune -newer "$latest" | read -r dummy && latest=$file
fi
done
test -e "$latest" && exec /usr/bin/vim "$latest"
# --------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment