-
-
Save sebble/667ced40e9897ee7b107 to your computer and use it in GitHub Desktop.
Command Line Fu
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
#!/bin/bash | |
## Pass all files in the PATH to dmenu and execute on success (with sorting by usage frequency) | |
tmp_bin=$(tempfile) | |
echo $PATH | tr ':' '\n' | xargs ls -1 | grep -Ev '^(/|$)' | sort -u > $tmp_bin | |
cat ~/.dme_history >> $tmp_bin | |
tmp_count=$(tempfile) | |
cat $tmp_bin | sort | uniq -c | sort -sb -k 1,1rn -k 2,2f > $tmp_count | |
run=$(cat $tmp_count | awk '{print $2}' | dmenu -b -i) && (echo $run >> ~/.dme_history ; $run) | |
rm $tmp_bin | |
rm $tmp_count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment