-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-shell-command.sh
executable file
·43 lines (36 loc) · 1.01 KB
/
run-shell-command.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env zsh
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Run Shell Command
# @raycast.mode fullOutput
# Optional parameters:
# @raycast.icon 📺
# @raycast.argument1 { "type": "text", "placeholder": "Command (Default: open Warp)", "optional": true }
# @raycast.argument2 { "type": "text", "placeholder": "Directory (Default: Finder)", "optional": true }
# Documentation:
# @raycast.description Run an arbitrary zsh command and return its output.
# @raycast.author Paolo Centomani
# @raycast.authorURL https://noveria.it
cmd="$1"
dir="${2/#\~/$HOME}"
source ~/.zshrc
if [[ -z "$dir" ]]
then
finder_dir=$(osascript -e "tell application \"Finder\"" -e "if exists window 1 then" -e "set pathList to (POSIX path of (folder of the front window as alias))" -e "pathList" -e "end if" -e "end tell")
if [[ -z "$finder_dir" ]]
then
dir="${HOME}"
else
dir="$finder_dir"
fi
fi
if [[ -z "$cmd" ]]
then
open -a Warp.app "$dir"
else
TERM="linux"
export TERM
cd "$dir"
eval "$cmd"
cd "$OLDPWD"
fi