Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by Bhishan

  1. @vitor The code suggested is much more concise, I also got another AppleScript solution from stack overflow: The problem is solved. You can close the topic. if running of application "Safari" then tell application "Safari" if the URL of ¬ the current tab of ¬ the front window ¬ does not contain missing value then set theURL to ¬ the URL of ¬ the current tab of ¬ the front window else return end if end tell
  2. Question: How to get the frontmost url from Safari and open it in Google Chrome Incognito? So far I was able to get the name of frontmost url. I have also seen another workflow to open in chrome incognito. But, I was struggling to combine two. I would truly appreciate if somebody jumps in and give me suggestions. I am looking for AppleScript that will do the work, if there is AppleScript I will be able to create new Alfred Workflow and use it there. Some references are included below:
  3. This is one of most useful workflows I have ever seen. But for some reasons the workflow is not working for me. Is this workflow still in use (2020 April) ? I tried following: - installed downvid workflow - go to youtube and played the url elephants dream trailer - typed `dv` in alfred Error for elephants trailer in Chrome ====================== ``` [11:25:45.071] ERROR: DownMedia[Run Script] WARNING: Unable to extract video title ERROR: This video is unavailable. ``` Error for elephants dream video in C
  4. You are in better luck than me. My Alfred uses Python 2. For each workflow I write separate python script and run in Alfred with `/Users/poudel/miniconda3/bin/python myscript.py` rather than typing python script right on the Alfred objects.
  5. @deanishe Thanks, now it works, I forgot to append ?= in the end of query. Thanks a lot.
  6. How to search a query using let me search that for you website? For wikipedia I can use: http://www.wikiwand.com/en/{query} # this works good For lmgtfy I tried: https://lmgtfy.com/{query} # this does not work This does not work. Is there a way we can make alfred web search for lmgtfy? If web search is not possible, how can it be done using Alfred Workflow? Help is appreciated.
  7. @vitor This time: 1. runscript applescript ``` tell application "Finder" set someSource to selection as alias list if someSource = {} then return "Select a file in Finder first" end if set theFile to item 1 of someSource as alias return quoted form of the POSIX path of theFile end tell ``` 2. utility transform ``` Transform utitliy trim space ``` 3. runscript ``` pbcopy < "${1}" ``` Error: ``` [10:24:
  8. @vitor I used: javascript ``` try { decodeURI(Application('Finder').selection()[0].url()).slice(7) } catch(error) { error.message } ``` instead of applescript ``` tell application "Finder" set someSource to selection as alias list if someSource = {} then return "Select a file in Finder first" end if set theFile to item 1 of someSource as alias return quoted form of the POSIX path of theFile end tell ``` and got errror: ``` [09:5
  9. @deanishe Thanks a lot for suggestion. My attempt was simpler than given link. I am interested in copy text files (.txt, .py, .md etc), images,pdf other types are not required. As vitor, suggested creating file action is super easy just pbcopy < "${1}" works good even for folder with spaces. But, I was attempting to create keyword (I already have file action) since it was easier to use and I didnt need to invoke file action trigger on selected file. I could simply use usual alfred command (double shift) as like in all other cases.
  10. @vitor Thanks for suggestion. 1. I used keyword to copy file contents of a file because its easier. using keyword: double tap shift on a file, type copy file contents, paste using file action: hit cmd \ on a file, search workflow copy file contents, select the workflow, paste using keyword saves invoking file action (cmd \) , I can directly use double shift to invoke Alfred command. 2. I appreciate pbcopy < "${1}", this is nicer than cat "$1" | pbcopy. I already have made file action for file copy, it works with s
  11. I was trying to create an Alfred workflow using which I can copy the contents of file without opening the file. github link of workflow: https://github.com/bhishanpdl/Shared/blob/master/Alfred_questions/2019/aa 00 copy file contents.alfredworkflow?raw=true Fails when: folder name has space in it. Commands used: 1. keyword: copy file contents 2. Run script with osascript ``` tell application "Finder" set someSource to selection as alias list if someSource = {} then return "S
  12. @deanishe I have a url like: ``` http://localhost:8888/notebooks/Dropbox/Data_Science/Untitled.ipynb ``` I want to open the url: ``` http://localhost:8888/notebooks/Dropbox/Data_Science/ ``` Which excludes the last part after "/". When I copy paste this url, it works good in Chrome, but When I open using "OPEN URL" of Alfered, it opens blank tab.
  13. I was trying to make a workflow to go one step up in jupyter notebook. When I print the output to the LARGE FONT the output is correct, I can paste the output to the Google Chrome and it works correctly. But when I use OPEN URL object, it opens the blank tab. I tried many times still it only opens the blank url. I have shared the workflow in github: https://github.com/bhishanpdl/Shared/blob/master/Alfred_questions/Jupyter Up.alfredworkflow?raw=true Question ---------------- How to make the workflow open the current jupyter notebook ru
  14. @deanishe Thanks for the suggestion. Now I can paste the last part of the list and also hit "shift-enter". But still I am sure how to make this in a for loop so that it works for all the parts of the list. Example: print(3) # comment print(5) I copied this text to the clipboard and ran my updated workflow: https://github.com/bhishanpdl/Shared/blob/master/Alfred_questions/a a a split the imports updated.alfredworkflow?raw=true It gives: """ # some comment print(5) """ And also hits "shift enter" (this means goes to next cell in jupyter
  15. Apologies for unclear question. Here is what I am trying to achieve: 1. Lets say I have a list mylist = ["#hello", "#world"] obtained from clipboard which in fact contain arbitrary number of elements. 2. print #hello to given app and simulate keystroke cmd + enter 3. print #world to given app and simulate keystroke cmd+enter If I already know how much elements in list, I can append alfred workflow object "output > keyboard combination" one by one, but I don't know how many elements are in the list and I want to hit keyboard keys cmd+enter af
  16. I have long string of python imports like this: # usual imports import os import sys # data manipulation import numpy as np import pandas as pd While working in Jupyter notebook, when I paste something and hit "cmd enter" it will go to next cell and again we can do paste and hit enter. How can it be done using Alfred? I have tried this so far: import sys import os import time s = """ # usual imports import os import sys # data manipulation import numpy as np import pandas as pd """ lst = s.lstrip().rstrip().split('\n#') for i,l in
  17. Thanks for the suggestion of use of json. I appreciate it. What I meant by spending hours is, I saw your solution, but tried to make it work in python alone and it took me hours. There is much to absorb in the given tutorial (python, applescript and so many things) but not a single stand alone python workflow which is kind of complete. So, I tried to implement the workflow in python borrowing all the ideas from that link. The link is helpful but its broad and takes some time to filter out.
  18. I was wondering how to create multiple argument variable using python. After hours of googling I found this link: https://www.deanishe.net/post/2018/10/workflow/environment-variables-in-alfred/ and I figured out myself. # Create env variables ```python import sys s = "apple banana; car truck" lst = s.split(';') a = lst[0] b = lst[1] myjson = """ {"alfredworkflow": { "arg": "", "variables": {"a": "%s", "b": "%s" } } } """ % (a,b) myjson = myjson.strip()
  19. I would just like to add my 2cents here. Whenever, I scroll down a long markdown or script file in github, I see something off and needs to edit it. Then I have to scroll back to top and then click the edit button. That is tedious and I found a better way of doing it using Alfred. We can use AlfredBookmarklet with following command: document.querySelector('[aria-label="Edit this file"]').click(); Hope it would be beneficial for others too.
  20. Can we change the default separator from `\n` to python list? For example: fake name tab 5 shoud give: `['name0', 'name1', 'name2', 'name3', 'name4']`
  21. Thanks for instructing me how to report the crashes: 1. I am very unfamiliar with Mac OS app development. Currently I am using Alfred in my Laptop (Mojave). Alfred has crashed few times in last few weeks (may be once or twice but not much). I looked at Console.app but I am not sure how to find the App specific log files. There are folders like a. ~/Library/Logs b. /Library/Logs and c. /var/log. I looked inside them and did not find any folder named Alfred, so I am not sure how to find the related log file of Alfred. 2. The alfred crashes in my o
  22. Date: July 10, 2019 Alfred version: 4.0.2 MacOS: 10.10.5 (Yosemite) I just wanted to report the bug that Alfred4 keeps shutting down on itself when I am trying to invoke some snippet expansions or use some workflow on MacOS Yosemite. I am using Alfred in Yosemite in office computer and use it everyday. In every few days ( one or two days in week) Alfred keeps shutting down without doing anything and it also takes long time to start on. I have lots of workflows (about 200) and many snippets (~MB) and application size may be the issue but I am exper
  23. I have found this workflow very useful. For example: In github commit the edited file: document.getElementById('submit-file').click();. I am totally unfamiliar with javascript, Is there also an option to "EDIT" the file in github? If so what would be the command? Help is highly appreciated. P.S. Where can I find some commands like: document.getElementById('submit-file').click();. online ? These commands are new to me.
  • Create New...