-
-
Save bjensen/4058587 to your computer and use it in GitHub Desktop.
open the newest file of a directory in vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -------------------------------------------------------- | |
# 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