» » Create a text memo from the selected text

Create a text memo from the selected text

Other / Office

Create a text memo from the selected text

Often, while surfing on the Internet there is a need to store some information on your computer. A small script which will save the information to a text file. It is very convenient.

You can save the entire page, but it is not always necessary, often you want to save a few lines of text.

Previously, manually created text file and copied it right, but it is exhausting.

Then it was decided to automate this process was written a small script to create notes that I would like to share with you.

The principle of operation of a script.
Let's say I want to save the information to disk. Select the text, run the script (I run on a combination of hotkeys). The selected text itself is copied into the opened window:

Create a text memo from the selected textCreate a text memo from the selected text

It can be edited as desired. Press OK.

A window opens to enter the name of the file that will be saved note:

Create a text memo from the selected text

If you leave this field blank, the title will be "Note [random number].txt".
Press OK. All selected text will be saved into the text file.

Let's check:

Create a text memo from the selected text

Create a text memo from the selected textCreate a text memo from the selected text

Guide - "How to do?".
Must be installed packages zenityxclip:

sudo apt-get install -y zenity xclip

Create the script file:

nano notes

You can create a file in a text editor, where you want. Paste into this file this code:

# Adds the selected text to the note at the specified location
# Must be installed: zenity, xclip
# $ sudo apt-get install zenity xclip
dir="$HOME/Downloads" # folder where will be stored the notes
xclip -o | zenity --width=600 --height=300 --title "Text of the note" --text-info --editable > "$out"
if [ $? -eq 0 -a "`cat "$out"`" != "" ]; then
name=$(zenity --title "Title of the note" --entry --text "Enter the title")
if [ $? -eq 0 ]; then
if [ "`echo $name`" = "" ]
then name="Note $$"
cp "$out" "$dir/$name.txt"
rm "$out"
exit 0

Folder where will be saved the notes is specified in the variable dir. You can change on your own.
Save and close the editor.
Make the script executable:

chmod +x notes

Check the correct work of the script


Add in your system hot key to run a script or hot corner of the screen.
There is a small "glitch" - if you select text and then click elsewhere, for example, to open any menu, the text is not automatically inserted, a window opens empty.
It is therefore desirable to run a script with hotkeys.
I hope someone will find it interesting.

Good Luck!!!


Print version

Add comments

  • Local comments
  • Facebook comments
  • bowtiesmilelaughingblushsmileyrelaxedsmirk
Your working environment Other polls