Skip to content

Commit 65a87cb

Browse files
committed
Add OR AND Option
1 parent a90aba5 commit 65a87cb

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

PoorSelect.applescript

+38-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
on run --for dialog
22
if existsWindow() then
3-
display dialog "Filter word" default answer "" buttons {"OK"} default button 1
4-
set userInput to text returned of result
3+
display dialog "Filter word" default answer "" buttons {"and search", "or search", "search"} default button 3
4+
5+
set userInput to result
6+
7+
set userInputButton to button returned of userInput
8+
9+
set userInputText to text returned of userInput
10+
11+
if userInputButton is "search" then
12+
set userInput to userInputText
13+
else if userInputButton is "or search" then
14+
set textList to makeList(userInputText, " ")
15+
set userInput to ""
16+
repeat with i from 1 to number of items in textList
17+
set this_item to item i of textList
18+
set userInput to userInput & "-e " & this_item & " "
19+
end repeat
20+
else if userInputButton is "and search" then
21+
set userInput to replaceText(userInputText, " ", " | grep ")
22+
end if
523
main(userInput)
624
end if
725
end run
@@ -68,3 +86,21 @@ on main(userInput)
6886

6987
end try
7088
end main
89+
90+
on makeList(theText, theDelimiter) --テキストを指定語句で区切り配列に格納する
91+
set tmp to AppleScript's text item delimiters
92+
set AppleScript's text item delimiters to theDelimiter
93+
set theList to every text item of theText
94+
set AppleScript's text item delimiters to tmp
95+
return theList
96+
end makeList
97+
98+
on replaceText(theText, serchStr, replaceStr)
99+
set tmp to AppleScript's text item delimiters
100+
set AppleScript's text item delimiters to serchStr
101+
set theList to every text item of theText
102+
set AppleScript's text item delimiters to replaceStr
103+
set theText to theList as string
104+
set AppleScript's text item delimiters to tmp
105+
return theText
106+
end replaceText

readme.md

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Example
1616
- ^[0-9]
1717
- png$
1818
- -d txt
19+
- -i hoge
20+
- hoge | grep fuga
21+
- e hoge -e fuga
1922

2023
##Download
2124

0 commit comments

Comments
 (0)