Skip to content

Latest commit

 

History

History
231 lines (163 loc) · 13.3 KB

README.md

File metadata and controls

231 lines (163 loc) · 13.3 KB

Support-CLI - Part_1: Intro

Assumption: you either:

  • (a) have to drop text in a terminal to do something OR
  • (b) want to learn command line tools.

In either case what you'll see is something that approximates off-peak 70s tech.
And, it's kinda painful.

We're going to help, some.

One reason 'the terminal' is difficult is also why it's popular: (in spirit) it's all hotkeys, all the time. It trades the curated, slow drip of information a gui gives for access to nearly everything that can be done at once. It trades familiarity and deciperhability for speed and freedom. Whether that enhances or diminishes your sense of flow depends on your use case.

Another reason 'the terminal' is difficult is that the defaults that ship with computers are little changed from the 70s. That we can help with.

  • A sea of monospaced ascii characters is displayed in a single color. The unparseable field an artist would cast to deflect a viewer's attention..
    • We'll Add color and simple icons.
  • File navigation is tied to rote memorization that predates modern search norms.
    • We'll add fuzzy-finders and quick-jump functionality.
  • Many of the default commands are unecessarilly slow on modern architectures (e.g. for searching through files).
    • New analogues have been written that are many times faster and can use modern computer features.
  • And the vintage shell language(s), while now valued only for terseness and efficiency, spring from a time when they had to balance other needs. The syntax of more complex commands is often clunky and awkward.
    • New analogues with streamlined syntax exist. Understanding that for very complicated actions a modern scripting language should be used instead of shell commands.

Colors in basic terminal display:

Bog Standard Enhanced - lt
(Displayed: exa & starship)

Fuzzy Finding and Intuitive Leaps :

  • standard (tab) behavior gif
  • fzf behavior gif
  • zoxide behavior gif
    (Displayed: zoxide & fzf)

Fast, Simple Syntax Searching

fd proteins ripgrep Little Women - folk
(Displayed: fd and ripgrep)

Smart Searching :

Fuzzy Find Insert - viu Fuzzy Find inserts - cd Fuzzy find inserts - text editor
(Displayed: fzf using viu, exa, and bat for previewing)

Improved Documentation and Quick Searches

man   help page highlighting quick use look up - tldr Common actions searches - navi
(Displayed: bat, tealdeer, and navi)

And Sundry other elements

syntax correction Starship Info ...
(Displayed: ZSH syntax checker & starship)


Support-CLI - Part_2: What You Need

You don't need a lot. But three soft needs are:

  1. have git and a github account (so you can clone this repo)
  2. have a recent mac OS (intel processors should use the "intel" branch of this repo, otherwise use "main").
  3. know how to view "hidden" files on your computer.

There are workarounds for all of the above, but they won't be addressed here.


Support-CLI - Part_3: Prepping for Install

We already mentioned that you need a github account, but in case you skipped down here: get a github account. Next, we're going to use the unofficial package manager for Mac: Brew. If you don't already have it installed, just follow the instructions at that link. (They should involve entering a single command, which will download and install Brew. )

Now before going further, check:

  1. That git is installed:
git --version
  1. That brew is installed:
brew --version
  1. That you have a github account and are set-up to use it:
cd ~/Desktop
git clone [email protected]:ethanmsl/CloneMeToCheckThatYouCan.git

(That last check will do a test clone of an itty-bitty repo -- if it succeeded there should be a folder called CloneMeToCheckThatYouCan on your desktop now, with a single text file congratulating you. You can just delete that folder after. [All the git machinery associatted with it lives hidden in the folder you cloned, so there's nothing else to clean up.])

If any of those checks gave you guff then something isn't set-up.
Check with a friend, coworker, or the interwebs.
Once you're good on all three of the above you can productively proceed!


Support-CLI - Part_4: Downloads!

We're going to download everything except this repo. (Just get it all ready.) To do that we're just going to give brew a long list of the names of what we want. Brew will download them and download anything each one of them needs.
Easy peasy.

Install our new Terminal (Emulator).

(They're sometimes called "... emulators" because "terminal" can also mean the physical objects people used a half-ish century ago.)

We're going to install a terminal called "Wezterm". It's fast, configurable, and has great support for many things (font icon extensions, font ligatures, using mac option key effectively, image protocols, large color range ... post-70's stuff). And other stuff we won't discuss here.

brew install --cask wezterm

Install Terminal and Shell Enhancements.

Bunch of stuff. Easy-peasy. Might take a second to download it all. Be prepared for lots of scrolling text. (Don't worry about it, but you can always uninstall and reinstall if you ever want to watch closely.)

brew install starship zsh-autosuggestions zsh-syntax-highlighting bat choose-rust git-delta exa fd fzf navi ripgrep sd tealdeer viu zoxide eth-p/software/bat-extras-batman

Optional: Install Fonts

Terminals are all text almost all the time. Having some choice in fonts is nice. We're going to download some here so they're there if you want later. You can skip this step and everything else will work fine. NOTE: if we were using almost any terminal except Wezterm we would have to download special patched fonts with icons in them. Wezterm provides those. If you switch terminal emulators sometime just know that you might need special fonts.

brew tap homebrew/cask-fonts
brew install --cask font-anonymous-pro font-hack font-iosevka font-iosevka-slab font-major-mono-display font-syne-mono font-victor-mono

You can also add other fonts of your choice later. Just note that almost all terminals assume fixed width fonts. So make sure the font you're using is compatible with a terminal. (Typically, anything labelled a "programming", "terminal", or "monospace" font will work. :)


Support-CLI - Part_5: Cloning & Symlinking

Okay, here's the skinny. A lot of your configuration files are just strewn about the place by default. Frankly, it's annoying. And makes keeping track of (and version controlling) them hard. What we're going to do is put all the config files we care about in a folder called .config and then tell the computer where we put them so everyone's happy.

There's three steps.

Step 1: freeze any files that would compete with us and put them neatly in a folder as backups. (should you desire to revert the actions done today!)

cd ~
mkdir z-backup-and-froze
mv .zshrc z-backup-and-froze/
mv .zshenv z-backup-and-froze/
mv .zprofile z-backup-and-froze/
mv .zlogin z-backup-and-froze/
mv .zlogout z-backup-and-froze/

(NOTE: you'll likely get multiple No such file or directory responses. That's fine, it's unlikely you'd have all of those files. As long you issued the above commands in your home directory cd ~ you're all set.)

Step 2: check if you have a .config file already for some reason and whether any folders with the same name as ours exist.

cd ~
ls -a .config

Ideally, you'll get ls: .config: No such file or directory as a response. Alternatively, you'll get a list of contents of some pre-existing folder. As long as none of those names match the names of what's in our folder .gitignore .git wezterm starship zsh README.md then you'll be fine. Otherwise, talk to a friend before proceeding.

Step 3: clone our repo into your home folder
Assuming there was no .config directory when you checked in the previous step, run:

cd ~
git clone -b main [email protected]:ethanmsl/Support-CLI.git .config

(NOTE: that's the command for downloading the main branch of this repo. If you want something else, e.g. the intel branch, but for some reason are reading the instructions to the main branch, you'll want to switch out the "main" for "<someothername>".)

if there was a pre-existing .config directory

Alternately, if there is an existing .config folder with no conflicting files that is not currently git versioned you would instead do this:

git init
git remote add main [email protected]:ethanmsl/Support-CLI.git
git fetch
git checkout main

Step 4: tell the computer where everything is.

ln -s ~/.config/zsh/.zshenv ~/.zshenv

Among the files you downloaded is a file (.zshenv) that will tell the shell where lots of stuff is (e.g. the .config folder). If that file is in an alternate location the computer can't find it without reading the location from it.... Catch-22. So we're creating a "symlink" that, effectively, makes the file accessible from both locations at once. The computer will find it in its twinned location, then read it, then find all the rest of our stuff. :)


Support-CLI - Part_6: Touch Ups

Way to go! That was pretty much everything.
Two small commands and you can play away.

  1. tldr is an awesome way to get a quick reminder of commands, but it needs to download its files from the internet, so just run:
tldr --update
  1. fzf is a really useful tool with some complicated shell integration options. Now that all our files are in place we're going to leverage them. Run the following command and say Y when it asks you if you want the three pictured options:
$(brew --prefix)/opt/fzf/install

fzf options install



Primary CLI Learning Reference:

Helpful Resources:

  • ExplainShell: feed it a command and get it broken down! Useful for basic command arguments and context. (won't parse more involved syntax of arguments to things like sed nor is it familiar with newer commands like sd; still useful for deciphering many commands you might come across, especially in install instructions)
  • TLDR Pages - we installed a CLI tool to do this (e.g. type tldr mkdir), but if you don't have that at hand these pages are great!
  • SC: Unix Summary: just an overview of the Software Carpentry lessons above. Good for a quick reminder peak.
  • Software Carpentry: Extra Unix Shell Material a dive into deeper lessons for those that want them. Covers things like using SSH, shell variables, and file permissions.