Jump to content

GuiB

Member
  • Posts

    366
  • Joined

  • Last visited

  • Days Won

    19

Everything posted by GuiB

  1. It's because your quotes are not escaped try that: function sf() { filePath=$(realpath "$1") osascript -e "tell application \"Alfred 3\" to search \"$filePath\"" -e "tell application \"System Events\" to key code 98" } You may need a delay to wait that Alfred is in front: function sf() { filePath=$(realpath "$1") osascript -e "tell application \"Alfred 3\" to search \"$filePath\"" -e "delay 0.1" -e "tell application \"System Events\" to key code 98" }
  2. I never used 'readlink', but from a little test, it seems that 'readlink' give you a relative path from your symbolic link to where it point to. So, that's why it returns a '.' . You would need to get the full path to the file you want to access
  3. That because you need to give the full path of the file to the command (the command doesn't search inside your computer for where you have a file named script.sh)
  4. Try with my last scripts (those from my first post should work and don't know why your current terminal session quits, but those last scripts should be better for your use case) As for why it quits... do you get error from you '~/.bash_profile' ? or everything is set without complaint ? -- Edit Try to run that line directly in your terminal to see if it makes an error: osascript -e "tell application \"Alfred 3\" to search \"~\"" Do you see Alfred pop or an error ? Or maybe try with: /usr/bin/osascript -e "tell application \"Alfred 3\" to search \"~\""
  5. Thanks @vitor for your recommendation! @nikivi, here is new version of the scripts so you are set directly to the file or folder in Alfred (before you were set "into" it) For the alias version: alfredSearch() { filePath=$1 if [[ -d $filePath ]] || [[ -f $filePath ]]; then dir=$(dirname "${1}") filename="${filePath##*/}" echo $filename | pbcopy osascript -e "tell application \"Alfred 3\" to search \"$dir"\" -e "delay 0.1" -e "tell application \"System Events\" to keystroke \"v\" using command down" # uncomment if prefer to keystroke the filename instead of using the clipboard and comment the two lines above # osascript -e "tell application \"Alfred 3\" to search \"$dir"\" -e "delay 0.1" -e "tell application \"System Events\" to keystroke \"$filename\"" else osascript -e "tell application \"Alfred 3\" to search \"$*\"" exit 1 fi } alias alfreds=alfredSearch For the script file version: #!/bin/bash filePath=$1 if [[ -d $filePath ]] || [[ -f $filePath ]]; then dir=$(dirname "${1}") filename="${filePath##*/}" echo $filename | pbcopy osascript -e "tell application \"Alfred 3\" to search \"$dir"\" -e "delay 0.1" -e "tell application \"System Events\" to keystroke \"v\" using command down" # uncomment if prefer to keystroke the filename instead of using the clipboard and comment the two lines above # osascript -e "tell application \"Alfred 3\" to search \"$dir"\" -e "delay 0.1" -e "tell application \"System Events\" to keystroke \"$filename\"" else osascript -e "tell application \"Alfred 3\" to search \"$*\"" exit 1 fi I think it's quite nice to have in the terminal! This could be set to pop Alfred with an action directly set from the terminal
  6. Not exactly to open the File Action window, but this would make things easier and faster... Just make yourself a bash alias to open Alfred with the file path and then activate the File Action from Alfred (using your defined key binding) Put in your '.bash_profile' (change 'alfreds' to the alias name that you prefer to use): alfredSearch() { osascript -e 'tell application "Alfred 3" to search "'"$*"'"'; } alias alfreds=alfredSearch Or create a file in one of you bash path that is executable with this script inside: #!/bin/bash osascript -e 'tell application "Alfred 3" to search "'"$*"'"' This has the advantage that you can open Alfred with any query that you want (not just file and folder), but you need to activate the File Action as a second action from Alfred
  7. Hi, just wanted to say that if you buy the Alfred Powerpack, nothing prevent you from using Spotlight at the same time as Alfred... I mean, if you prefer a feature in Spotlight or think one is missing from Alfred, but is in Spotlight, you could still use those features with Spotlight even if you have Alfred. Use the best tool for the job that you need to be done. For example, I've seen people using Alfred+Launchbar even if many features overlap, but preferred some features in one vs the other, so they use both together. You could see both applications as complement to each other... or one is like an addons for the other that allow more actions to be easily done on your computer... As @Vero pointed you, your key features could pretty much be done in Alfred as is or by creating a workflow (or looking for one) and Alfred has many other great features that are not possible in Spotlight or that could replace other applications (ex: Clipboard history or Snippets / Auto text expanding utility). Just have a look and see if the extra commodity is worth the price. ---- Edit ---- About the Dictionary feature and don't want't to write "define" before... You can easily write a workflow to query a string with the Alfred "Dictionnary Filter" action. It's just 2 objects to put together, a Hotkey object + a Dictionary Filter object. The first object is to activate the workflow and pop Alfred so you can write the word you want the definition for and the second object is to output the definition in Alfred. So, you just need to write the word that you want (no "define" before) and you would only get dictionary results (so no extra items that gets in the way, ex: no "Best results", "Mail and Messages", "Files"... like in Spotlight, you only get the definition)
  8. Here is a workflow to show you the second idea using a Hotkey and a List Filter. You would need to put the Hotkey combination inside the Hotkey object, but this could work great as well. Workflow example: https://nofile.io/f/Y6DdDhAn9lF/Multi-Stage+Action+Shortcuts.alfredworkflow
  9. Dear @greghoch, you made me thought that I could write a small post about a workaround that I had in mind... The idea is to use the Snippets trigger as a workaround. So please, look at my post in the other thread to have a look and idea of how this could be done ("in some way") (Just click the link below). I've made an example like Sublime to modify text to uppercase using cmd+k, cmd+u in the attached workflow (translated to alt+k, alt+u using a snippet trigger). It's not as transparent, but could be useful Hope this helps! ---- Edit ---- Have a look at it or you may also prefer to use a List Filter or Script Filter that is activated using a Hotkey with the text selection and that would output a list of actions... Example: cmd+k as the hotkey and then you write "u" to filter the list to the Uppercase action or "l" for the Lowercase action, so the keypress combination could be something like: cmd+k+u+Enter
  10. Hi everyone! I thought I would write this down here to give some ideas to some of you... Using the new "Snippet" object, it is now possible to have some kind of a workaround for multi-stage shortcuts. I said workaround, since you need to be aware that the keypress would be sent to the front application. Therefore, you need to be careful with which key you use. To make it more like command keys, I'm using the "alt" key as modifier. This is writing symbols, so you could used those symbols as the text for the Snippet action. For example, [ alt+o, alt+m ] would be [ øµ ] (on my French-Canadian Keyboard) and could be used to (for example) open the activity monitor (or run any action that you wish) Here is a workflow to give you some example, but keep in mind that this is a workaround https://nofile.io/f/FSS6iMp9fw3/Hotkey+Sequence+Trigger.alfredworkflow I would put here my README that's inside the workflow to give you a better overview about the idea: ------------- Hotkey Sequence Trigger - README This is a workaround idea to have a multi-stages hotkey trigger. The idea is to use the "Snippet" object to detects the key sequence and run a defined action if there's a match. * This is working very well, but has the inconvenient that every key press is sent to the front application. Therefore, make sure the snippet key sequence doesn't interfere with your application. Also, please note that Alfred will send keypress to remove the snippet text before doing the action. This is great so the entered key sequence is removed from a text editor, but this could lead to unwanted behaviour if the snippet is run from a non text field (example: in a browser window, there's good chances that Alfred would activate the shortcut to go to previous pages). * To work with text, you would need to copy it first (with the help of a script if the hotkey sequence doesn't interfere with the selection or with cmd+c). * To modify text in a text editor, you would need to first copy the selection and keep it selected or use cmd+x to copy and remove the text before doing the hotkey sequence so the text is replaced. Note: to make it more like a sequence of key commands, I've used snippet that use special symbol using the "alt" modifier key, but this is working with any key sequence that you set in the Snippet object. ** Please note that the key sequence are based on a French-Canadian keyboard and may be different than what is written in the object note. So, you may be better to change them for something that better suit your keyboard. ------------- I hope this is useful to some!
  11. Oh yes, I briefly remember having read something related to environment variables in an release note, but I read it fast and it seems I didn't clearly catch this information! Thanks for letting me know and I prefer this method than my internal JSON! Sorry for taking your time on this then, have a nice day!
  12. Since this is what I think the standard way to set an environment variable from a Script Filter, I think this should be working, but feel free to move this post to the feature request if this the normal behaviour and not a bug. When building a workflow that works with files and folders, I like to allow to run actions on those files/folders. So, since the File Action is made for that, I like to just activate it on my script filter output item by using my File Action shortcut (sets to cmd-cmd in my case). However, when I want to set an environment variable inside the Script Filter, then the File Action shortcut doesn't work anymore even if "type" is set to "file" in the JSON. Since this environment variable is used when I normally activate the selected item on my workflow by pressing enter and could change based on which item of the Script Filter is activated, I need to set it inside the Script Filter and not after or before, but would like to keep the default behaviour of the " 'type': 'file' " item. Here is a workflow to demonstrate this: https://nofile.io/f/xZGFinuS44I/Script+Filter+-+File+Type+with+File+Action+-+Test.alfredworkflow Let me know if something isn't clear enough! Best!
  13. @JoelStickney, I just looked into this since this was something I wanted to get around as well. I found out it's quite easy and just a one bash line and consist of removing an extended attribute from the application bundle... One line script to remove the extended attribute and launch the application: xattr -d com.apple.quarantine /App/Path && open -a /App/Path If you just want to remove the extended attribute in you Hazel script, then you just need the first part of this line above: xattr -d com.apple.quarantine /App/Path For anyone wanting a workflow, here is one that would launch an application and remove the quarantine extended attribute if present. It works like @Carlos-Sz workflow using the "uni" keyword ("uni appName") or by launching using a file action: https://nofile.io/f/5kwX381ojBy/Unidentified+Developer+-+Open+App.zip
  14. @td. it seems the path to Bear database has changed (or I don't know, I just tried the workflow now since your post made me think that I could look at a workflow for Bear...). @chrisbro, I made it works by changing the database path in the script "queries.py" at line 11 to 13 From: DB_LOCATION = ( "/Library/Containers/net.shinyfrog.bear/Data/Library/Application Support/" "net.shinyfrog.bear/database.sqlite") To: DB_LOCATION = ( "/Library/Containers/net.shinyfrog.bear/Data/Documents/Application Data/database.sqlite") Also, ( @td., you may need to do that as well) the cached database didn't update so I deleted the "db_path.cpickle" in "~/Library/Application Support/Alfred 3/Workflow Data/com.chrisbro.bear/db_path.cpickle" and after that, now everything seems to be working Here is an updated version while @chrisbro update his version : https://nofile.io/f/wSoOfp0ILrP/Bear.alfredworkflow
  15. Hi @Misha, I did a small workflow as example to show you multiple ways of doing it (using a: File action, a Hotkey or a Keyword). This way you can use the way you find it best for your use case. Myself I would use the file action since you want to work with files and this is made for that... but any method should works great Here is the workflow: https://nofile.io/f/O7scHb0o3rm/File+Selection+&+OCR_Keywords.alfredworkflow Hope this helps!
  16. There's no direct shortcut, but a workaround would be to use the Help Search fonction in the menu... Select the cells that you want to sum then press "Option+/" to access the Help Search menu and type "sum" and the focus would be on the "INSERT FUNCTION: SUM" function. Just press Enter and you are set. This also has the benefit to easily access any menu item by name and working in other Google applications like Docs and Slides
  17. CMD + SHIFT + T ?? There's already a keyboard shortcut for that in Excel if I clearly understand you question... Here is a list of shortcut for Excel if you want to find some others: https://support.office.com/en-us/article/Keyboard-shortcuts-in-Excel-2016-for-Mac-acf5419e-1f87-444d-962f-4e951a658ccd
  18. Is it what you're after ? : https://github.com/deanishe/alfred-searchio For myself, this is working to have google searches and other websites
  19. @vitalyb, you're right! I added the "=" quite fast and habitually I put a space after the "=" symbol so I didn't see there was an error in this case... so thanks! Here is an updated version if anyone want it: https://nofile.io/f/5G55Cwax3h8/Numi.alfredworkflow
  20. @vitalyb, this is interesting, however, please note that this break the workflow if we want to input something that doesn't starts with a number (for example: starting with sin(), cos(), ln()...). So, at least it would be preferable to keep the workflow starting with "n" or do like the builtin calculator and make the workflow works by starting with "=" ... Beside that, thanks @nikolaeu for the workflow and for Numi ! Very great application! === Edit === For those interested in trying @vitalyb workflow, but with the possibility to start the workflow with "=" like the builtin calculator so queries that doesn't start with a number works. here is an update to the workflow with that modification: https://nofile.io/f/SQI84dsXiQy/Numi.alfredworkflow
  21. Thanks @Vero, I checked Alfred before submitting, but couldn't see an update in the pre-release... I now clicked on the "pre-release" in the combo box and Alfred scanned for updates and now I got it. I thought the auto-update scanning was more automatic and faster to tell when there's new releases. However, now after updating, yes thanks, this is now fixed in 3.4.1 pre-release!
  22. When creating a workflow using the new Snippet node, it's not possible to connect to an Inputs node if this last one is created using a secondary click on the canvas. I mean, it's working great when dragging the outlet of the Snippet node and releasing the mouse (the popup menu allow to insert an Input node and this node is automatically connected), but it's not working when we try to connect to an Input node that is already created on the canvas. Here in the attachment you can see that the inlet of the Input nodes doesn't appear while dragging the wire for connection.
  23. Here is an updated version I wanted to test to find a way so the script wait that the application is ready instead of a definite time before sending the keystrokes. With this version it should be faster and less error prone. Best! on alfred_script(q) if (text 1 thru 2 of q) is equal to "cd" then do shell script "open -a Hyper " & text 4 thru -1 of q else do shell script "open -a Hyper ~" set appOpen to false set nbrOfTry to 0 delay 0.5 repeat try tell application "System Events" if exists (window 1 of process "Hyper") then set appOpen to true exit repeat end if end tell end try set nbrOfTry to nbrOfTry + 1 if nbrOfTry = 20 then exit repeat delay 0.5 end repeat if appOpen then tell application "System Events" to keystroke q & return end if end alfred_script
×
×
  • Create New...