Bhishan
-
Posts
146 -
Joined
-
Last visited
Content Type
Blogs
Gallery
Downloads
Events
Profiles
Forums
Articles
Media Demo
Posts posted by Bhishan
-
-
# Given solution works in office compute but does not work in my laptop
Office computer: macos Yosemite, clean nothing quickview qlgenerators installed
Laptop: macos mojave and some quickview qlgenerators installed (eg. QLColorcode)
- /usr/bin/qlmanage -p a.pdf # it works despite some warnings
- /usr/bin/qlmanage -p a.sh # it does not work (qlmanage fails)
- NOTE: hitting space on a.sh works on finder
- NOTE: hitting cmd-y on a.sh works on finder
That is why I was looking a way using "APPLESCRIPT".
I am hardly familiar with AppleScript, but I feel I was pretty close to the solution in the third part of the applescript workflow in my question.
-
I am attempting to create a workflow that pastes the contents of clipboard to a file and opens that file using QuickView.
The simpleset approacth would be `qlmange -p myfile.ext`, but for some reasons my computer is not working `qlmanage -p ` command and I have to use `applescript`.
Here is link of my workflow: https://github.com/bhishanpdl/Shared/blob/master/Alfred_questions/aa Clipboard QuickView.alfredworkflow?raw=true
Here is outlook of my workflow:
# part1:
Keyword
# part 2: Bash
# if argument exist if [[ $# -gt 0 ]] ; then OUT="a.$1" fi # if arg doesnot exist if [[ $# -eq 0 ]]; then OUT="a.py" fi pbpaste > ~/Dropbox/$OUT echo -n "~/Dropbox/$OUT"
# part3: Applescritpt
property folderPath : "/Users/poudel/Dropbox" on run {} tell application "Finder" activate set myFolder to folder (folderPath as POSIX file) set myFile to first item of myFolder -- set myFile to quoted form of (item 1 of argv) select myFile tell application "System Events" to keystroke "y" using command down end tell end run
**Question**
1. In part3 I want to avoid hard coding "/Users/poudel/Dropbox" to "~/Dropbox" so that I can use the workflow in the office computer and my own laptop both.
2. The workflow is not working currently, I am struggling to select the file by its name.
Help with workflow is appreciated.
-
I believe it would be an astonishing feature if there is an option to press "shift" key at snippet so that it stays in floating window so that we can see the codes/notes/any snippet
and work altogether.
Ideas of implementation:
- Using QuickView
- Using Helium app which supports floating browser
Bonus:
It would be even nicer if the codes are syntax highlighted (reading shebang of snippet)
Hope we can see this feature in some of the upcoming versions of Alfred.
-
+1 I would also like to see this feature in upcoming version.
-
@deanishe I have uploaded the workflow here:
I am looking a way to create dynamic trigger using argument from the alfred workflow.
-
@deanishe Where are the snippets stored? May be If I create a directory "TemporarySnippets" in that folder and create a text file/json file/ whatever and call the snippet trigger afterwards?
-
-
I guess I got what you mean:
workflow:
Keyword sni ==> get argument name to "arg1" ==> Snippet and use "arg1" as trigger name.
I will try this method. If I could not manage to get it done, will seek further suggestion.
-
**Update**
I could not create Snippet triggers, but found alternative route using Alfred Keyword.
"sni hello" will create "hello.txt" from the clipboard.
"sno hello" will read that "hello.txt" and paste to the frontmost application.
This works great, but I am only missing "u;hello" and "u;hi" etc where I can simply type, instead of hitting keys.
-
Because, lets say i have a code snippet from pandas groupby in python:
gp1 = => daily = flights.groupby(['year','month','day'],as_index=False)
and another snippet as
gp2 = => daily = flights.groupby(['year','month','day'],as_index=True)
It would be easier to type u;gp1 and u;gp2 than go to clipobard manager and search for clipboard history.
-
It would be extremely useful if we can create snippets on-the-fly from the clipboard contents.
For example:
"snip tmp" will create a snippet called "u;tmp" from the clipboard content.
So that when typing "u;tmp" will expand that snippet automatically.
For only one snippet I can do this:
===========================
Alt shift t ==> copy the clipboard to tmp.txt
u;tmpp ==> autoexpand the text after reading from tmp.txt from that workflow directory.
But, this works only for one snippet.
It would be nicer if it can be done more dynamically.
The suggestion is much appreciated.
I have provided MWE in the github shared file:
-
Nevermind, I can confirm it works, I was just confused by dropbox log in request.
-
@Jasondm007 I was also trying to achieve the same.
I found your link useful but the link is broken, may be you can share it in github or bitbucket so that it will remain infinitely!
Thanks.
-
I was trying to write an Alfred workflow to replace a single letter/number (or substring) from the copied text.
Here is what I have done:
query=$1 old_new=($query) old=${old_new[0]} new=${old_new[1]} copied=$(pbpaste) changed=${copied/$old/$new} echo -n $changed
Here is the link to my workflow in github: https://github.com/bhishanpdl/Shared/blob/master/Alfred_questions/replace.alfredworkflow?raw=true
But, this workflow is not working for MULTI-LINE .
How to fix the workflow?
Example test
==========
s = 'hello'
print(s[0])
After running the command "replace 0 1"
I would like to have:
s = 'hello'
print(s[1])
-
I was trying to make an Alfred workflow to get the link of youtube open in any chrome tab.
I have shared my workflow did so far, which only works for Safari, how to make it work for Chrome?
The link of my alfred workflow is shared here.
So far I have done this to get URL from Safari, but I am struggling how to get this in Chrome?
on alfred_script(q) tell application "Safari" repeat with t in tabs of windows tell t if URL starts with "http://www.youtube.com/watch" or URL starts with "https://www.youtube.com/watch" then set vidurl to URL set AppleScript's text item delimiters to "&" set the item_list to every text item of vidurl set strip to text item 1 of vidurl set vidurl to the strip as string return vidurl exit repeat end if end tell end repeat end tell end alfred_script
-
@vitor Thanks a lot. However, I also created workflow using python, following the idea of @deanishe.
import sys import sqlite3 import os db= r"/Users/USERNAME/Library/Application Support/Alfred 3/Databases/snippets.alfdb" conn = sqlite3.connect(db) q = "SELECT snippet FROM snippets WHERE keyword='{} '".format(sys.argv[1]) c = conn.cursor() c.execute(q) ans = c.fetchone()[0] with open('snips.txt','w') as fo: fo.write(ans) os.system('qlmanage -p snips.txt')
-
@deanishe Yes, Alfred's Large Type works fine. But, how to pipe the outputs of "snip hello" to the Large Type ?
-
There are some ways to create and use the snippets in Alfred.
1. Using snip command .
We can only see the command name, and copy the snippets but cant see the contents.
2. Using clipboard manager
we can search and see the contents of snippets and copy it, but can not see the preview (eg. using shift key)
Here, I would like to get help creating a workflow which will write the snippets to a file and quickview it.
idea:
command: qsnip hello
effect: copies the snippet called hello and paste the contents "hello world" to a file called "mysnip.txt" in the directory of workflow.
effect: qlmanage -p mysnip.txt
Problem:
I am unware how to save the snippet to the file "mysnip.txt"
I have shared the minimal workflow here:
https://github.com/bhishanpdl/Shared/blob/master/Alfred_questions/qsnip.alfredworkflow?raw=true
-
@CJK Thanks for your help, but I got one small problem.
I tried to get only the basename of the png file instead of the whole POSIX path, but it failed.
My attempt:
I added following at the bottom of the script.
# copy basename of png to clipboard base=`basename "$name"` echo -n "$base" | pbcopy
How can the workflow only give the base name of the png?
-
Thanks a lot. This solved the problem.
-
I made a simple workflow to capture screencaputure, rename it, and move it to the current directory of the Finder.
The workflow works for folders like "Downloads", "Dropbox/hello", but it fails when I want to write to "Google Drive".
There is escaping problem.
I tried changing $1 to "$1" in the bash script, but it did not worked.
How the problem can be fixed?
The workflow is shared here:
-
I was trying to log the path of the current working directory of Finder window to a text file in Dropbox, the AppleScript used has no problem but when used in Alfred it gives me the empty log file.
Used AppleScript:
tell application "Finder" if exists Finder window 1 then set currentDir to target of Finder window 1 as alias else set currentDir to desktop as alias end if end tell log POSIX path of currentDir
Error log from debugging:
[2018-11-20 11:24:03][ERROR: action.script] /Users/poudel/Dropbox/Research/zz_LastWD/
**Question**
How to write the current path of Finder along with date in a text file using Alfred?
-
-
Thanks a lot, I figured it out.
-- cd to Downloads try set folderPath to POSIX file "{query}" on error set folderPath to (path to downloads folder as text) end try -- try to delete items in Downloads if any try tell application "Finder" set itemsToDelete to every item of folder folderPath delete itemsToDelete end tell end try -- empty trash tell application "Finder" empty trash end tell
Help with Clipboard Quickview workflow
in Workflow Help & Questions
Posted · Edited by Bhishan
1.
I forgot to post the error code and instead pasted the screenshot, with apologies, I have included the error log for the command of `qlmanage -p a.sh`
2. the error log says look at `/usr/include/servers/bootstrap_defs.h` but there is no directory called 'include' inside '/usr' and hence no file `bootstrap_defs.h`.
3. `qlmanage -p -d1 a.sh` full error log:
4. Also, since qlmanage is not working, an alternative might also be using applescript and avoiding qlmanage altogether.