odetinin Posted May 17, 2014 Share Posted May 17, 2014 I'm kinda stuck. I'm trying to create a simple workflow to open Alfred with the content of the current working directory in terminal. This one opens Finder just fine: on alfred_script(q) tell application "Terminal" do script "open -a Finder ./" in first window end tell end alfred_script How can I modify it to open Alfred instead ? Link to comment
ctwise Posted May 20, 2014 Share Posted May 20, 2014 Anyone ? Anyone ? tell application "Alfred 2" search "whatever you want in the box" end tell Link to comment
odetinin Posted May 20, 2014 Author Share Posted May 20, 2014 How can I replace "whatever you want in the box" with current working directory in Terminal ? Link to comment
jdfwarrior Posted May 21, 2014 Share Posted May 21, 2014 How can I replace "whatever you want in the box" with current working directory in Terminal ? I thought I had replied to this... I looked around at this for a minute and.. there isn't a really straight forward way of doing this because there isn't an easy way to, from applescript, get the current path of the terminal so that you can tell Alfred to go there. Now.. you COULD do something like.. with a keyword or hotkey, execute some applescript that would tell the current window in terminal to execute a command that would write the output of pwd to a file (in the workflow's area or somewhere else) and then follow that step in the workflow with a script that would read that file to grab the path, tell Alfred to search that, then delete the file (or not.. don't guess it would HAVE to) Link to comment
odetinin Posted May 21, 2014 Author Share Posted May 21, 2014 Thanks. The "temp file" solution is somewhat cumbersome. I thought there was an easier way to do it, such as launch alfred from command line with a parameter to do a search, something like: open - a Alfred\ 2 $(echo pwd). Unfortunately this is not a case. Link to comment
raguay.customct Posted May 21, 2014 Share Posted May 21, 2014 Hi, Try this: Create a shell script in your path with this: #!/usr/bin/sh /usr/bin/osascript -e "tell \"Alfred 2\" to search \"$(`echo pwd`)\";"; Make the file executable and in your path. Then where ever you are in a terminal, just execute that shell script. Therefore, in your AppleScript above, replay the "open..." with just the name of the shell script with path to it. That should work. Link to comment
raguay.customct Posted May 21, 2014 Share Posted May 21, 2014 I went ahead and wrote it up. You can download it here: https://github.com/raguay/MyAlfred/blob/master/OpenInAlfred.alfredworkflow You have to run "oa:install" first to install a helper script into your /usr/local/bin directory. If it does not work, check to see if you have that directory. "oa:terminal" opens the topmost Terminal window into Alfred "oa:iterm" opens the topmost iTerm window into Alfred. Let me know if this is what you were looking for. Richard Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now