Skip to content

Instantly share code, notes, and snippets.

@f4th4n
Created October 23, 2016 22:22
Show Gist options
  • Save f4th4n/6bf252a42f5dc05a7e0016d5d7267657 to your computer and use it in GitHub Desktop.
Save f4th4n/6bf252a42f5dc05a7e0016d5d7267657 to your computer and use it in GitHub Desktop.
Shortcut to Drop Cache Linux on Zshell
# Press F5 on command line to drop cache
# Tested on Ubuntu 16
is_sudoed=false
eval "f5() {zle push-line;LBUFFER+='fkey_f5';zle accept-line}"
zle -N f5
bindkey '^[[15~' f5
function fkey_f5 {
if [ "$is_sudoed" = 'true' ]; then
sync | sudo tee /proc/sys/vm/drop_caches
else
sync && echo 'you_root_password_here' | sudo -S tee /proc/sys/vm/drop_caches
fi
is_sudoed=true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment