Browse files

Added @copy() tagging to put partial answers in the clipboard when an…

…swering questions
  • Loading branch information...
1 parent 8b650bd commit 305b40029c1e12084dd8440505a20894470048c3 @ttscoff committed Oct 18, 2011
Showing with 11 additions and 3 deletions.
  1. BIN Alfred/quickquestion.alfredextension
  2. +4 −0
  3. +7 −3 qq
Binary file not shown.
@@ -58,6 +58,10 @@ You can add additional meta within the contents of the file to help in locating
An example of this would be a question like "What brand of cleaner did I use during the move?" The answer you gave was a cleaning solution you were really impressed with. A year later the only thing you may remember to ask is "cleaner," but you might not even remember that was the term you used. So you add "@(solution cleaning favorite)" to the answer. Now you can search for "favorite cleaning" or "cleaning solution" and still get the question you were looking for. It's similar to using tags, but you can be more verbose without cluttering up your pool of existing tags. In the example case, you can also use just the root or part of a word, e.g. `qq fav clean` to expand matching possibilities.
+### Copy to clipboard ###
+If your answer includes a command, url or other piece that you probably want to grab, you can surround it with @copy(part to copy) and the contents of the tag will be copied to the clipboard when the question is answered. The '@copy(' and ')' parts will be stripped from the answer given, but its contents will remain inline.
### Redacting answers ###
If you're using LaunchBar or Alfred it's assumed that you can locate the question file and open it in an editor of choice easily enough. It's even simpler if your questions are stored in Notational Velocity/nvALT as you can edit them at the same time you search for them.
10 qq
@@ -29,7 +29,7 @@ then
elif [[ "$1" == "-e" ]]; then
- ANSWER=`mdfind -onlyin "$NOTESDIR" "filename:.$NOTESEXT AND filename:$NOTESPRE AND ${INPUT%\?}"|head -n 1`
+ ANSWER=`mdfind -onlyin "$NOTESDIR" "filename:.$NOTESEXT AND filename:\"$NOTESPRE\" AND ${INPUT%\?}"|head -n 1`
if [[ "$ANSWER" == "" ]]; then
echo "No results found for search."
exit 2
@@ -38,7 +38,7 @@ elif [[ "$1" == "-e" ]]; then
- echo "`mdfind -onlyin \"$NOTESDIR\" \"filename:.$NOTESEXT AND filename:$NOTESPRE AND ${INPUT%\?}\"`"|while read LINE; do
+ echo "`mdfind -onlyin \"$NOTESDIR\" -interpret \"filename:.$NOTESEXT AND filename:$NOTESPRE AND ${INPUT%\?}\"`"|while read LINE; do
if [[ "$LINE" == "" ]]; then
echo "Sorry, I don't know the answer to that question."
exit 1;
@@ -48,7 +48,11 @@ else
NOTESPREESC=`echo "$NOTESPRE"|sed -E 's/([\?\!\$\`\"]) ?/\\\\\1/g'`
echo ${QUESTION%%.$NOTESEXT}|sed -E "s/$NOTESPREESC ?//g"|sed -E 's/(.)$/\1?/'
echo -n "A: "
- cat "$LINE"|sed -E 's/@\([^\)]+\) ?//g'|tr -s "\n"|sed -E 's/^[ ]*|[ ]*$//g'
+ cat "$LINE"|sed -E 's/@\([^\)]+\) ?//g'|sed -E 's/@copy\(([^)]*)\)/\1/'|tr -s "\n"|sed -E 's/^[ ]*|[ ]*$//g'
+ if [[ `cat "$LINE"|grep -E '@copy\('` ]]; then
+ cat "$LINE"|grep '@copy('|sed -E 's/.*@copy\(([^)]*)\).*/\1/'|tr -d '\n'|pbcopy
+ echo "Example in clipboard"
+ fi

0 comments on commit 305b400

Please sign in to comment.