Created
March 7, 2015 06:46
-
-
Save hitswa/59239d6b1ab3306868ae to your computer and use it in GitHub Desktop.
Everything Search Engine alternative script for ubuntu
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 | |
t=$(mktemp) | |
locate "$1" | awk '{ printf "%4d\t\"%s\"\n", NR, $0 }' > $t | |
[[ -s $t ]] || { echo "No results found"; exit; } | |
rows=$(wc -l "$t" | cut -d' ' -f1) | |
if [[ $rows == 1 ]]; then | |
file=$(sed 's/^.*\t"\(.*\)"$/\1/' $t) | |
xdg-open "$file" & | |
else | |
response=$(dialog --stdout --menu 'Choose a File:' 20 70 15 --file $t) | |
if [[ -n "$response" ]]; then | |
file=$(sed -n "/^\s*$response\t/{s/^.*\t\"\(.*\)\"$/\1/;p}" $t) | |
if [[ -n $file ]]; then | |
echo "You chose $file" | |
xdg-open "$file" & | |
fi | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment