Tealdeer Pages

This is for configuring tealdeer, a command-line help system.

  • The expected folder in this repository to put these pages is dingehaufen/tealdeer/pages/.
  • The default location that tealdeer will look for the pages is \(~/.local/share/tealdeer/pages/~\) so maybe symlink it there.
  • The pages that come with tealdeer are at \(~/.cache/tealdeer/tldr-pages/pages/\) (look here for examples)

Patches

These are patches which extend existing help pages rather than replacing them. If you want to add a new command or replace the existing tealdeer help you would use pages instead (they go in the same folder, there's just a different file-name convention).

Screen

Name the Screen

- Give the screen a name

`<Ctrl-a> A`

Ghostscript (gs)

This is for ghost script.

Black and White PDF

This is to convert a PDF's text and vector images to Black and White to make it easier to read when printed. From a Ask Ubunt (Stack Exchange) answer.

In the cases I've tried this doesn't convert raster images.

- Convert PDF text to black and white (not grayscale)

`gs -sDEVICE=pdfwrite -dBlackText -dBlackVector -dNOPAUSE -dBATCH -sOutputFile={{output-file-name}} {{pdf-input-file-name}}`

Compress For Ebook

This adds some extra flags to the compression help that comes with tealdeer.

- Reduce PDF File Size, possibly more than the version up above

`gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -dDetectDuplicateImages -dCompressFonts=true -sOutputFile={{output-file-name}} {{input-file-name}}`
  • See : Optimizing PDFs - From the Ghostscript Blog. This notes that DetectDuplicateImages is actually on by default so you only need to use it if you want to turn it off, but I didn't read that until after using it. It might make sense to experiment with it on and off. The same might go for the CompatibilityLevel.

Virtual Fish

Check The Environment

This adds the build-state for the virtual-environments managed by virtualfish.

- List Environments and the Current State (do they need to be rebuilt?):

`vf ls --details`

Rebuild the Environment

This is the command to use after an Ubuntu upgrade where they change the python version and all the virtual environments are broken.

- Rebuild the current environment (e.g. after Ubuntu changes pip):

`vf upgrade --rebuild`

You can also rebuild a specific environment (not necessarily the one you're in).

- Rebuild a specific environment

`vf upgrade --rebuild {{virtualenv-name}}`

If the environments are broken by an update, pipx is likely broken too, run this too, maybe:

  • pipx reinstall-all
  • pip install setuptools --upgrade

pdfjam

Resize to Letter

- Resize PDF document to letter-paper size

`pdfjam {{input-file}} --paper letter --outfile {{output-file-name}}`

`pdfjam {{input-file}} --papersize 8.5in,11in --outfile {{output-file-name}}`

Emacs

Open File With Sudo

Got this from a Stack Overflow Question. The user's question is asking for an alternative way to do this, but the answers tell him that it's the best way to do it after all (he thought it was using SSH but it uses a sub-shell).

- Open a (local) file with sudo.

`C-x C-f /sudo::/path/to/file`

Use a Different Init.el

This is to use a different init.el file (presumably for debugging).

- Use a different initialization file when starting up:

`emacs --init-directory={{path/to/directory-with-init/}}`

Image Magick

Remove PDF Background

This assumes a image "density" for the background and converts the pages to images so the output file will likely be much larger. It might be best to use this for printing and then deleting the converted PDF.

- Remove background of PDF assuming the image density

`magick convert -density 300 {{path/to/input.pdf}} -white-threshold 80% {{path/to/output.pdf}}`

I also tried removing the background color specifically but doing that eats into everything that sits above the background as well (removes the anti-aliasing overlap, I assume).

PDF TK

Export Bookmarks

Export bookmarks from a PDF. I normally use cpdf for bookmarks, but in the case of Wanderhome, when I reduced the resolution to get a smaller PDF it removed the bookmarks so I had to copy them from the original and for some reason cpdf couldn't dump them, but pdftk could.

Pdftk uses a human-readable format that isn't compatible with cpdf. For Example:

BookmarkBegin
BookmarkTitle: wanderhome.pdf
BookmarkLevel: 1
BookmarkPageNumber: 0
BookmarkBegin
BookmarkTitle: Copyright
BookmarkLevel: 2
BookmarkPageNumber: 0
BookmarkBegin
BookmarkTitle: Table of Contents
BookmarkLevel: 2
BookmarkPageNumber: 0

Taken from PDFLabs Export and Import PDF Bookmarks.

- Export existing bookmarks from a pdf (UTF-8 Version)

`pdftk {{input.pdf}} dump_data_utf8 output {{bookmarks.txt}}`

Import Bookmarks

Import bookmarks dumped from another PDF. The prompt for this was that I reduced the resolution/size of a pdf and lost the bookmarks in the original and restored them by copying them over.

- Import pdftk-formatted bookmarks (from dump_data_utf8)

`pdftk {{to-update.pdf}} update_info_utf8 {{bookmarks.txt}} output {{updated.pdf}}`

Pages

These are pages - whatever you put in a page file will be the starting point for the tealdeer entry - these will either start a new tealdeer entry or will clobber any exsting one that came with tealdeer. The thing that tells tealdeer that it's a page and not a patch is that the filename ends with page.md instead of patch.md. Otherwise the contents look the same.

MakeMKV Command Line

The makemkvcon command has a --help output, which is somewhat vague. I got the information for this from a developers text file usage.txt on makemkv.com/developers. Normally I use the GUI but sometimes it crashes due to errors specific to the GUI so the command line interface is useful to work around those cases.

List Drives

This lists the drives as makemkvcon sees them.

- List drives - DRV:index,visible,enabled,flags,drive name,disc name

`makemkvcon --robot --cache=1 info disc:9999`
Option Description
--robot Meant for automation, tells the program to output the information to the screen
--cache=1 Reduce the cache size (optional)
info The sub-command to print information
disc:9999 Show discs (not files, etc.)

The output looks something like:

MSG:1005,0,1,"MakeMKV v1.18.2 linux(x64-release) started","%1 started","MakeMKV v1.18.2 linux(x64-release)"
DRV:0,2,999,1,"DVD+R-DL HL-DT-ST DVDRAM GSA-T50N RQ01 KWF9AEJ1028","MAD_MAX_FURY_ROAD","/dev/sr0"

With more lines below it. The second line is the one I'm interested in. It has the format:

DRV:index,visible,enabled,flags,drive name,disc name

This table shows what their text file says the fields mean.

Field Description
DRV This is a drive
index The number we'll use to refer to the drive
visible 1 if drive is present
enabled 1 if drive is accessible
flags media flags (see AP_DskFsFlagXXX in apdefs.h)
drive name drive name string
disc name disc name string

Looking at the sample output, it has 2 for "visible" and 999 for "enabled", which doesn't match the expected values so I just ignore everything but the drive name to find the right entry in the output and the index for use in invoking makemkvcon.

Copy Disc As MKV Files

- Save disk to the current directory as MKV files

`makemkvcon mkv disc:{{index}} all .`

- Save disk to another directory as MKV files

`makemkvcon mkv disc:{{index}} all {{/absolute-path-to-folder/}}`

The sample shows the output being copied to c:\folder which is a DOS format (I think). It didn't seem to work when I used a relative path (other than the current directory) so I assume you need to use the full path starting from /home/.