0

I'm a Debian Stretch user coming from Windows. In Windows with the launchy app (also available for Linux), I had a method of entering text into launchy that was then appended to the end of a .txt or .md file.

To do this in Windows, I created a file called note.bat that contained the following:
echo %*>>"C:\collectednotes.md"

I'd make launchy aware of note.bat by adding its containing folder to “Launchy” → “Settings” → “Catalog” and adding filetype *.bat.

From there, I'd launch launchy, type note, hit Tab, enter some text, hit Enter, and then the text would be added to the end of collectednotes.md.

A mostly working process is detailed in my answer below. I'll give the green checkmark answer to anyone that can adjust this process (via note.sh and/or launchy plugin setup detailed below) to appropriately handle all special characters.

This may contain the solution to this question:
Which characters need to be escaped in Bash? How do we know it?

Adam Smith
  • 2,584
  • 2
  • 20
  • 34
  • 1
    I can sort-of see what you're doing here; but is your text file so huge and unwieldy that you can't just make a desktop shortcut that opens it in a text editor? FWIW I guess the Linux equivalent of of your batch script would be something like `echo "$@" >> /path/to/text/file` – Kevin Boone Oct 14 '17 at 07:50
  • @KevinBoone The idea is to remove as much friction/distraction as possible in taking notes. The idea is popular in the "GTD" community. This is the earliest I recall seeing it: http://www.43folders.com/2004/09/04/quicksilver-append-to-a-text-file-from-anywhere – Adam Smith Oct 16 '17 at 16:36
  • Hello @KevinBoone - please see the partial solution below. Thanks for the early input - your comment is part of the solution. An additional issue with creating shortcuts and just opening text file: 1) always have to `ctrl`+`end` if you want top to bottom to log oldest to newest 2) have to close the file after each note or keep it open and tolerate the clutter and 3) possible to get distracted by having to confront previously saved text. You'll have to try it to become a believer! – Adam Smith Jun 12 '18 at 17:54

1 Answers1

0

Solved (almost). I'm keeping this question unanswered and will give to whoever completes the remaining ~5%. Steps to get the 95% solution with xfce4-terminal version 0.8.3-1:

Install launchy and launchy-plugins (both are version 2.5-4 for me):
apt-get install launchy
apt-get install launchy-plugins

Open terminal to default location of ~/ and create collectednotes.md:
echo "# Launchy Notes Collected Here" > collectednotes.md

Create note.sh shell script:
echo '#!/bin/sh' > note.sh

Create shell script line 2:
echo ALL_ARGUMENTS='"$@"' >> note.sh

Create shell script line 3:
echo 'echo "$ALL_ARGUMENTS" >> ~/collectednotes.md' >> note.sh

If you open note.sh, it will look like:

#!/bin/sh
ALL_ARGUMENTS="$@"
echo "$ALL_ARGUMENTS" >> ~/collectednotes.md

Make note.sh executable:
chmod +x note.sh

Launch launchy and click the gear icon in upper right for settings. If consistency with launchy for Windows is desired, set launchy Hotkey to Alt+Space. If you receive a keyboard shortcut conflict message as I do on Debian with Xfce, first go to Settings, Window Manager, Keyboard tab, and clear Alt+Space as the shortcut for Window operations menu.

Next in launchy settings, go to Plugins tab and enable the plugin Runner. Click the + button and create a new Runner custom command as follows:
- Name: note
- Program: /home/YOURUSERNAMEHERE/note.sh (launchy does not like Program path of ~/note.sh, so a specific path with username is required)
- Arguments: '$$'

Click the Catalog tab and hit Rescan Catalog just in case. Hit OK to close launchy settings.

Now let's test it.
- launch launchy with Alt+Space or your hotkey
- type note (You may have to wait 10 second or so on first run. You'll know things are as expected when you see the text "note" with a orange/yellow icon containing silhouette of a person.)
- hit Tab
- enter some text (no need for single or double quotes or escapes), e.g.: Remember to donate at least $3 to Josh at Launchy https://www.launchy.net/donate.php
- hit Enter

Now open collectednotes.md to confirm the text was captured.

The remaining issues seem to be dealing with single quotes and double quotes. For example, consider the following note:
I don't know what I'd do without Launchy.

Which results in the following in collectednotes.md:
I dont know what Id do without Launchy.

Or:
Would David Allen like universal text capture from anywhere in Linux? My bet is "yes!"

Results in the following in collectednotes.md:
Would David Allen like universal text capture from anywhere in Linux? My bet is \yes!\

Single quoting and/or double quoting the input to launchy doesn't solve it. Note the launchy Runner custom plugin construction component of '$$' is a piece of this puzzle.

I'll give the answer to anyone that can adjust this process (via note.sh and/or launchy plugin setup) to appropriately handle all special characters. Maybe this would add proper escapes to user input with something like gsub.

The rationale for being exacting regarding proper character handling is that this process is useful for copying and logging random chunks of text from web pages, but if common characters like single quotes are not handled as expected, confidence in the system is much reduced.

Adam Smith
  • 2,584
  • 2
  • 20
  • 34