Convert Any Man Page to PDF πŸ“„

Here’s a quick way to convert any man page into a PDF document for easier viewing, searching, and sharing:

# install necessary package
sudo apt-get install ghostscript

# script to convert a man page into a PDF
man -t tmux | ps2pdf - tmux.pdf

After you create the PDF document, use your PDF viewer of choice.


I’m using Windows Subsystem for Linux (WSL), so I call Adobe Acrobat directly to open the PDF:

/mnt/c/Program\ Files/Adobe/Acrobat\ DC/Acrobat/Acrobat.exe  tmux.pdf


But I also created a symbolic link to Acrobat.exe, then called it that way:

# create symbolic link 'adobe' to 'Acrobat.exe'
 ln -s /mnt/c/Program\ Files/Adobe/Acrobat\ DC/Acrobat/Acrobat.exe /bin/adobe

# view 'tmux.pdf'
adobe tmux.pdf

Demo

Backup Your Git Repository: Lazy Man Method

Intro

You don’t need to learn or use Github for “simple” Git repository backups 😎

This method only backs up the repository itself, it is not a valid Disaster Recovery Strategy.

If the folder you are backing up to is on the same disk and your original repo, and the disk itself fails…you’re still up a creek without a paddle.

If you are trying to implement Disaster Recovery for your repo, make the sure the folder/volume/mount-point/whatever you are backing up to, is itself, being backed up “offline”.

“Offline” meaning a separate disk/thumb drive/Dropbox/whatever.. 😁

However, this method is great for quickly backing up your repo if you want to experiment and test git techniques.

It’s always wise to do a quick backup before you put on the lab coat:

Image Credit: https://www.carlroth.com/com/en/protective-gowns/protective-gowns-kimtech-science-a7-lab-coat/p/2146.1

Solution

Here are the steps I took to do a local backup of my git repository:

# cd to the folder of your Git Repo
mkdir /tmp/bashScripts
cp -r .git/ /tmp/bashScripts
cd /tmp/bashScripts
git restore *

Full Demo

Optimize Your Vim Statusline

Intro

Constantly asking Vim which file you are editing is disruptive to your workflow.

Especially after the 20th time of asking..πŸ˜΅β€πŸ’«

Here’s a great way to have Vim always tell you which file you are in; instead of stopping to ask.

Vim Options

Here are the commands to change and reset the defaults for laststatus and statusline from Command-line Mode, respectively:

# change the defaults
:set laststatus=2
:set statusline=buf\ %n:\ %F\ %m%r\ %=%l,%c\ \ \ \ \ \ \ \ %p%%

# reset to defaults
:set statusline= laststatus=1

#view buffer list
:ls

Here’s how to view the filename and buffer number from Normal Mode:

# view file name: control-g
^g

# view file name AND buffer number: 2 control-g
2 ^g

**Remember, you have to exit Insert Mode and go into Normal Mode first, with the Esc key

How To Create SSH Keys For Authentication

Overview

Creating and using SSH keys for authentication requires 3 minimum steps

  1. Generate Your Public-Private Key Pair
  2. Transfer Your Public Key To The Remote Host(s)
  3. Test Your Private Key

Commands To Run:

ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub user1@remotehost
ssh user1@remotehost

Demonstration

Here’s my YouTube short explaining this process:

And here’s a long form video demonstrating this process:

TBA

Extra Information

  • SSH key authentication uses asymmetric encryption:
    • Public Key encrypts
    • Private Key decrypts
  • Your Public Key is safe to give to anyone, anywhere. Hence it’s name.
  • Your Private Key must be safeguarded.
    • If any copies exist, assume your identity is compromised and refresh your key pair.

Git Range Notation “..”

Here’s how NOT to read the following:Β 

git log master..origin/master

“Show me all commits from branch ‘master’ to branch ‘origin/master’ that are reachable”

Here’s the CORRECT WAY to read it:

“Show me all commits from branch ‘master’ to branch ‘origin/master’ that are UNREACHABLE”

That command will tell you what – if any – commits you WOULD merge in if you ran:

git checkout master
git merge origin/master

If you’re a Linux SYSADMIN and want to get started with Git,

Here’s my in progress Git playlist:

Edit Multiple Files in VIM – Part 2

Notes from video:

# Notes for my YouTube video:
# https://youtu.be/o6cZ8fFBj-M


###################
#
# Command-Line Mode
#
###################

##
:split 
:split [FILENAME]
:vertical split 
:vertical split [FILENAME]

##
# Close window with cursor
:close

##
# override all warnings with "!"
# and hide buffer
:close! 

##
# close all windows AND 
# exit the Vim program
:quitall

##
# override warning with "!"
# and discad ALL changes THEN
# exit Vim program
:quitall! 



##############
#
# Normal Mode
#
##############

##
# increase window width
^w >
[NUMBER] ^w >

##
# decrease window width
^w <
[NUMBER] ^w <

##
# increase window height
^w +
[NUMBER] ^w +

##
# decrease window height
^w -
[NUMBER] ^w -

##
# set all windows equal
^w =

##
# rotate windows
^w r

##
# move cursor in a 
# particular direction 
^w [ARROW KEY]

You can also get the most current version of the above via git:

git clone https://gist.github.com/3d380d4bbd54c0c36d144ededb7c3591.git vimBuffers2
cd vimBuffers2