Categories
Development Networking Server SysAdmin Technology

Dot files

My over-engineered Z shell configuration.

With inspiration from my friend, Chewrocca, and his dotfiles; and after reading an excellent article that he linked to, A simpler way to manage your dotfiles, I’ve cleaned up and released my dot files that serve as my Z shell configuration running on top of:

  • zplug — a next-generation plugin manager for zsh (that I use for loading Oh My Zsh plug-ins).
  • Powerlevel10k — a theme for Zsh that emphasizes speed, flexibility and out-of-the-box experience.
  • Byobu — an enhancement for the GNU Screen terminal multiplexer or tmux.

Prerequisites

With Homebrew:

brew install git rsync curl zsh jq

OR

With APT:

sudo apt-get install --yes git rsync curl zsh jq

Installation

Log on to your machine and run the following:

{

	git clone \
		--separate-git-dir=$HOME/.dotfiles \
		https://gitlab.com/ltgiv/dotfiles.git \
		tmpdotfiles \
		;

	rsync \
		--recursive \
		--verbose \
		--exclude '.git' \
		tmpdotfiles/ \
		$HOME/ \
		;

	rm -r tmpdotfiles

	zsh ~/.zshrc
}

Upgrading

Occasionally, I push updates. To ensure that you have the latest version, you can simply run the following command:

dotfiles pull

Optional

Software

Additional software to consider loading, which may or may not be available in package managers for your operating system:

  • exa — A modern replacement for ‘ls’.
  • FASD — Command-line productivity booster, offers quick access to files and directories, inspired by autojump, z and v.
  • FZF — A command-line fuzzy finder.
  • LSB — Linux Standard Base and Distribution Information.

Environment

I have an environment file located at ~/.env which is parsed by the dotenv plug-in. Mine looks like this:

# User identity
NAME_LONG="Louis T. Getterman IV"
NAME_SHORT="ltgiv"

# 1Password settings
OP_SERVER="my.1password.com"
OP_USERNAME="E-MAIL ADDRESS GOES HERE"
OP_SECRET="SECRET KEY GOES HERE"

# SSH keys to load from 1Password
OP_SSHKEYS="id_ed25519 id_ecdsa id_rsa"

# SSH Keys' lifetime in seconds
OP_SSHKEYLENGTH=14400

Usage

The following options then become available to you:

  • Environment variables
    • TERMIPLEXER — Preferred terminal multiplexer. Current options are:
      • tmux
      • screen
      • byobu
      • none
    • TMPDIR — Temporary directory.
    • ORIGSSHPATH — SSH binary path.
    • KERNEL — Operating System kernel (e.g. Linux or Darwin).
    • DISTROID — Distribution identification (e.g. Ubuntu or macOS).
    • DISTROVER — Distribution version.
    • IAMREMOTE — Boolean that indicates if working remotely (e.g. Mosh/SSH).
    • PATH — greatly expanded path to programs.
    • GOPATH — Path to Go language related.
    • SHELLSESSDIR — Path to temporary directory that lasts as long as the shell.
    • OPSESSPATH — Path to flat file that stores the current (if active) 1Password Session ID.
    • If you have installed Kelsey Hightower’s setup-network-environment installed, network interface addresses (e.g. EN0_IPV4)
      • You can view what’s available for your system with:
        cat "${TMPDIR}/network-environment"
  • Aliases
    • .. — go up 1 directory.
    • ... — go up 2 directories.
    • .... — go up 3 directories.
    • ll — modern listing with exa.
    • ytdluglier simplified filenames (useful for saving videos from Twitter when tweets are too long).
    • dotfiles — simplifies the use of Git for managing dotfiles.
    • tree — hierarchical listing that excludes Git.
    • top — uses htop instead.
    • ssh — uses Mosh instead.
    • sshCopyKey — Copy key to host.
    • sshRemoveHost — Remove known host.
    • secureshell — forces use of SSH when Mosh isn’t available at a remote endpoint.
    • seedboxes-quota — checks disk usage for open source software seeded across BitTorrent.
    • b64e — Base64 encoding.
    • b64d — Base64 decoding.
  • Functions
    • ex — compressed file expander that takes the name of the file to extract.
    • str_repeat — repeat characters. Positional arguments are:
      1. Character to repeat.
      2. Number of repetitions.
    • pdftitle — Change PDF title.
    • SSH
      • newKeyPair — Creates a new private and public SSH key echoes to STDOUT. Positional arguments are:
        1. Key type (e.g. dsa, ecdsa, ed25519, or rsa), default is ed25519.
        2. Key encoding (e.g. b64e), default is cat.
      • loadsshkeys — Load SSH keys (in my case, from 1Password).
      • loadedsshkeys — List loaded keys from SSH agent.
      • unloadsshkeys — Unload keys from SSH agent.
      • connectShell — Used as a wrapper for Mosh and SSH, and to load SSH keys when needed.
    • 1Password
      • opon — Enable 1Password.
      • opoff — Disable 1Password.
      • oppass — Get Password from 1Password for item’s Name or UUID.
      • opnote — Load a note from 1Password.
      • opsshkey — Retrieve Base64 encoded SSH key from 1Password where argument is name of item (e.g. id_ed25519)
      • oploadsshkey — Specific SSH key to load.
      • oploadsshkeys — Load (and decode) a Base64-encoded value from 1Password.
    • bcrypt — Create bcrypt-based hash of a string.
    • sshServerFingerPrints — List available hashes of a host’s keys.

Did this article save you time or money? I'd love a coffee!

Did you find this useful?
Please share with those who you believe would find this useful too!

Leave a Reply

Your email address will not be published. Required fields are marked *