Created
October 23, 2016 22:22
-
-
Save f4th4n/6bf252a42f5dc05a7e0016d5d7267657 to your computer and use it in GitHub Desktop.
Shortcut to Drop Cache Linux on Zshell
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
# 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