Skip to content

Commit f98a6ff

Browse files
committedNov 6, 2021
Add directory search
1 parent 7985829 commit f98a6ff

File tree

5 files changed

+168
-79
lines changed

5 files changed

+168
-79
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Before your first use, run `:gdlaunchd` and wait for the notification. The more
1010

1111
To rebuild the cache on demand, do `:gdrebuildcache`.
1212

13-
When done, call `gd` and type to filter the contents of your Google Drive.
13+
When done, call `gd` and type to filter the contents of your Google Drive. `gdf` limits the search to directories.
1414

1515
The Workflow Environment Variables have defaults which will work for most. You only have to mess with them if you have an atypical setup.
1616

4.41 KB
Loading

‎source/gd

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
require 'json'
55
require 'sqlite3'
66

7-
Query = ARGV[0].split(' ').map { |w| "%#{w}%" }
7+
Dir_only = ARGV[0] == 'dir_only' ? 'isdir = 1 AND' : ''
8+
Query = ARGV[1].split(' ').map { |w| "%#{w}%" }
89
Limit = ENV['result_limit'].to_i <= 0 ? 50 : ENV['result_limit'].to_i
910
Tmp_file = File.join(ENV['alfred_workflow_cache'], 'tmp_db')
1011
Cache_file = File.join(ENV['alfred_workflow_cache'], 'cache.db')
@@ -23,7 +24,7 @@ end
2324

2425
# Filter paths
2526
db = SQLite3::Database.new(Cache_file)
26-
Results = db.execute("SELECT fullpath FROM main WHERE #{Array.new(Query.length, 'basename LIKE ?').join(' AND ')} ORDER BY accesstime DESC LIMIT ?;", Query, Limit).flatten
27+
Results = db.execute("SELECT fullpath FROM main WHERE #{Dir_only} #{Array.new(Query.length, 'basename LIKE ?').join(' AND ')} ORDER BY accesstime DESC LIMIT ?;", Query, Limit).flatten
2728

2829
Script_filter_items = Results.each_with_object([]) { |path, array|
2930
array.push(

0 commit comments

Comments
 (0)
Failed to load comments.