Markup Editors for Ubuntu

Refer: https://support.typora.io/Typora-on-Linux/

Debian/Ubuntu

# sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA300B7755AFCFAE
wget -qO - https://typora.io/linux/public-key.asc | sudo apt-key add -

# add Typora's repository
sudo add-apt-repository 'deb https://typora.io/linux ./'
sudo apt-get update

# install typora
sudo apt-get install typora

Upgrade

After installing Typora, the typora package will be managed by apt-get, so when your system updates installed packages, or you execute apt-get upgrade, Typora will be updated to latest version.

# upgrade all packages include Typora
sudo apt-get upgrade

Mint

# sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA300B7755AFCFAE
wget -qO - https://typora.io/linux/public-key.asc | sudo apt-key add -

# add Typora's repository
echo -e "\ndeb https://typora.io/linux ./" | sudo tee -a /etc/apt/sources.list
sudo apt-get update

# install typora
sudo apt-get install typora

Download deb file manually

You can also manually download and install the deb package file, following those steps:

The deb file is located at https://typora.io/linux/typora_${version}_amd64.deb, for example: https://typora.io/linux/typora_0.9.96_amd64.deb. Just downlad the deb installer at that url.

Double click the deb file to start intsall on Ubuntu / Debian.

Markt Text

Promising but it does not want you to look under the covers to see the source code easily.

Refer: https://marktext.app/

Use sed to Replace Anchor Tags

Convert links to markdown

Refer: https://digitalsanctum.com/2020/09/10/how-to-replace-html-links-with-markdown-links/

cat anchor-tag.html | sed -r 's/<a[^>]*href="([^"]*)[^>]*>([^<]*)[^>]*>/[\2](\1)/g'

This:

Refer to this: <a href="https://mruckman.com">link</a>

Changes to This:

Refer to this: [link](https://mruckman.com)

Use this command to convert ALL href tags into underline tags, this includes mailto links

cat anchor-tag.html | sed -r 's/<a[^>]*href="([^"]*)[^>]*>([^<]*)[^>]*>/\<u\>\2\<\/u\>/g'

This:

Refer to this: <a href="https://mruckman.com">link</a>

Changes to This:

Refer to this: <u>link</u>

Using BlueFish on Ubuntu

Currently you cannot define your own shortcuts keys, this really stinks because to join lines takes three key strokes. It does provide color coding and some extra goodies.

Configure HTML tidy, by adding extra filter settings.

Refer: http://www.gtalbot.org/linux-section/web-authoring/html-tidy/how-to-use-HTML-tidy-with-bluefish.html

Edit, Preferences, "External Filters"

|tidy -utf8 --clean yes --doctype strict --drop-font-tags yes --drop-proprietary-attributes yes --enclose-block-text yes --enclose-text yes -indent --logical-emphasis yes --output-html yes --replace-color yes --show-warnings no --wrap 1024|

Addtional Configurations for HTML Tidy

Refer: http://tidy.sourceforge.net/docs/quickref.html

Map Mouse Buttons in Ubuntu

Map_Mouse_Keys.pdf

Special HACK when using mouse with ONLY 3 buttons and you want pushing the scroll wheel to close tab.

# NOTE: SIMPLE MOUSE - SCROLL WHEEL CLICK TO CLOSE TAB
"xdotool key 'Control_L+w'"
        b:2

Sample Bindings:
xbindkeysrc

meld ~/.xbindkeysrc ~/Desktop/xbindkeysrc.txt

Refer: https://www.linuxuprising.com/2019/11/how-to-bind-mouse-buttons-to-keyboard.html

Install the tools:

sudo apt install xbindkeys x11-utils xdotool

Grab the mouse button codes:

xev | grep button

Next, focus the small window that pops up and watch the terminal output. Now press the mouse button for which you want to grab the code. After pressing the button you should see its code in the terminal where you ran xev, e.g.:

Results

Left Scroll Wheel Click
state 0x10, button 6, same_screen YES

Right Scroll Wheel Click
state 0x10, button 7, same_screen YES

Grab the keystrokes that we'll later send using a mouse button (skip if you want to bind a command / script / program to a mouse button)

Run the following command:

xev | sed -ne '/^KeyPress/,/^$/p'

For [Ctrl]+[w], results

KeyPress event, serial 37, synthetic NO, window 0x3200001,
    root 0x5a9, subw 0x0, time 1609319, (114,64), root:(200,166),
    state 0x10, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 37, synthetic NO, window 0x3200001,
    root 0x5a9, subw 0x0, time 1609946, (114,64), root:(200,166),
    state 0x14, keycode 25 (keysym 0x77, w), same_screen YES,
    XLookupString gives 1 bytes: (17) ""
    XmbLookupString gives 1 bytes: (17) ""
    XFilterEvent returns: False

Note down the keycode, keysim or name of the key. You can use any of the 3, e.g. for the first key above you can use either 37, 0xffe3, or Control_L. In this article I'll use the key name (e.g. Control_L for left control key) since they are easier to read.

Create the xbindkeys configuration (in ~/.xbindkeysrc).

You may either create an empty ~/.xbindkeysrc file, or generate a sample configuration file using this command:

xbindkeys -d > ~/.xbindkeysrc

Next, open ~/.xbindkeysrc with your favorite text editor. Note that .xbindkeysrc is a hidden file in your home directory so you'll need to press Ctrl + h (to show hidden files and folders) to see it in your file manager.

To bind a mouse button to a key combination, paste the following at the end of the ~/.xbindkeysrc file (it may already contain some key binds, it may contain the sample configuration or it can be empty - it doesn't matter):

"xdotool key 'KEY-COMBINATION'"
       b:MOUSE-BUTTON-CODE

Where:

  • KEY-COMBINATION are the keystrokes you got under step 3 (separate the keys with a + sign)
  • MOUSE-BUTTON-CODE is the mouse button code that you got under step 2

Example:

# NOTE: MAP LEFT SCROLL WHEEL CLICK TO CLOSE TAB
"xdotool key 'Control_L+w'"
        b:6

# NOTE: MAP LEFT SCROLL WHEEL CLICK TO CLOSE WINDOW
"xdotool key 'Control_L+W'"
        b:7

This remaps the mouse button 8 (which for my mouse is the button that can be used as a back button in a web browser for example) to Control_L+Alt_L+Down which in GNOME Shell is used to switch to workspace down.

To bind a command, script or program to a mouse button, use this in the ~/.xbindkeysrc file:

"COMMAND"
       b:MOUSE-BUTTON-CODE

Here:

  • COMMAND is a command, script or program
  • MOUSE-BUTTON-CODE is the mouse button code that you got under step 2

Example for running a program using a mouse button:

"firefox"
       b:8

This starts Firefox when pressing mouse button 9 (which for my mouse is the button that can be used as a back button in a web browser for example).

Start xbindkeys.

Now you can start xbindkeys using a terminal and typing:

xbindkeys

In case xbindkeys was running, you can get it to use the new configuration by issuing; however, I found I needed to just reboot.

xbindkeys --poll-rc

Map Escape Key to Caps Lock and Other Tweaks

Refer: https://dev.to/yuyabu/how-to-use-caps-lock-key-as-esc-on-ubuntu-18-1g7l

Gnome Tweaks as a "Keyboard & Mouse Section", "Addtional Layout Options"

Currently using two tweaks because my old USB keyboard for an iPad DOES NOT have an escape key.

Choose "Caps Lock behavior', "Make Caps Lock and addtional Escape"

Since Caps Lock is remapped also adding a tweak to make using both shift keys to enable Caps Lock, and one shift key to disable Caps Lock

"Miscellaneous Compatibility Options", "Both Shift together enables Caps Lock; one Shift key disbles it"

Cups Printer Management from Command Line

Refer: https://www-uxsup.csx.cam.ac.uk/pub/doc/suse/suse9.1/adminguide9.1/ch05s07.html

Sample Commands

Help

lpstat --help

General Status

lpstat -t

List of Printers

lstat -v

5.7.3.Using Command-Line Tools for CUPS Troubleshooting

Print jobs will be kept in the printer queue if you shut down the system while a job is being processed. This means a broken print job will still be there even after rebooting and you need to remove it from the queue manually with the commands mentioned above.

Other problems occur if there is some fault in the physical data link between the computer and the printer. The printer may then be unable to make sense of the data it receives and start spitting out lots of pages with garbage on them.

To make sure the printer stops working, first remove all paper from it (in the case of inkjet printers) or open the paper trays (laser printers).

At this point, the print job will often still be in the queue, because jobs are only removed from the queue when all data has been sent to the device. Check which queue is currently printing by entering

lpstat -o

Then remove the problematic print job wit

cancel queuename-jobnumber

Some data might still find their way to the printer in spite of the job having been deleted. To stop this, enter the command fuser -k /dev/lp0 (for a printer at the parallel port) or fuser -k /dev/usb/lp0 (for a USB printer). This kills any processes still using the printer device.

Do a complete reset of the printer by disconnecting it from power for some time. Then put in the paper and switch the printer back on.