Created
September 20, 2010 07:05
-
-
Save mmisono/587520 to your computer and use it in GitHub Desktop.
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
function latest(){ | |
local dir num | |
num=1 | |
while getopts hn: OPT | |
do | |
case $OPT in | |
"n" ) num="$OPTARG" | |
shift 2 ;; | |
* ) echo "Usage: $0 [-n number] [dir]" 1>&2 | |
return;; | |
esac | |
done | |
if [ $# = 0 ]; then | |
dir="`pwd`/" | |
else | |
dir="$1/" | |
shift 1 | |
fi | |
for i in `ls -t ${dir}$1 | head -n $num` | |
do | |
echo ${dir}${i} | |
done | |
} | |
function _latest(){ | |
_arguments -s : \ | |
'l:file:_files' | |
} | |
compdef _latest latest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment