Skip to content

Instantly share code, notes, and snippets.

@dmerejkowsky
Last active August 25, 2017 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmerejkowsky/972c51582d75a3f019fb0ca11707911b to your computer and use it in GitHub Desktop.
Save dmerejkowsky/972c51582d75a3f019fb0ca11707911b to your computer and use it in GitHub Desktop.
Insert most recent file in current command line
# Display most recent file in the current directory
function latest() {
echo $(ls --quoting-style=shell -t | head -n1)
}
# Insert most recent file in the current line
latest-file-widget () {
LBUFFER="${LBUFFER} $(latest)"
local ret=$?
zle redisplay
return $ret
}
zle -N latest-file-widget
bindkey '^[l' latest-file-widget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment