Advertisement
Guest User

Untitled

a guest
May 27th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #!/bin/bash
  2. #Simple locate plugin example.
  3. #Put me in ~/.config/gambas3/higgins/extbin to use me
  4.  
  5. #This plugin will search for files using locate command, which has to be installed.
  6. #This plugin will run only when the trigger is used, so:
  7. # to search for "myfile.txt"
  8. # write: l:myfile.txt
  9. # (trigger is "l:")
  10.  
  11. #This plugin will not search anything lower than 3 characters (minchar=3)
  12.  
  13.  
  14. export IFS=$'\n'
  15. trigger="l:" #Search using the trigger? es: l:myfile
  16. minchar=3 #Don't search on queries smaller than that, trigger does not count.
  17.  
  18. query="$@"
  19.  
  20. #Do we use a trigger?
  21. if [ -n "$trigger" ] ; then
  22. #...Yes, we do, so exit if not triggered
  23. if [[ $query != $trigger* ]] ; then
  24. exit
  25. fi
  26. #Strip the trigger prefix from the query
  27. query=$(echo $query| sed "s/^$trigger//")
  28. fi
  29.  
  30. len=${#query}
  31.  
  32. #Exit if the query is too small
  33. if [ $len -lt $minchar ] ; then
  34. exit ;
  35. fi
  36.  
  37.  
  38. #Finally, start the search:
  39. for file in $(locate -i "$query") ; do
  40. echo BEGIN
  41. # For fields description and possible values, please refer to plugins/plugin_999_template
  42. echo Text=$(basename $file)
  43. echo SubText="in " $(dirname $file)"/"
  44. echo Image_file="mimetype://$file"
  45. echo Clipboard_data="$file"
  46. #echo Action="GUESS"
  47. echo Action="EXEC_TERMINAL"
  48. echo Action_p="$file"
  49. echo END
  50. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement