site

A custom static site generator written in C.
git clone https://unitehenry.com/git/site.git
Log | Files | Refs | README

whats-in-my-rc-2021.md (5417B)


      1 ---
      2 title: What's in My RC 2021
      3 description: A tour of my RC file in 2021.
      4 ---
      5 
      6 # What's in My RC 2021
      7 
      8 2021-05-29
      9 
     10 Welcome to a tour of my `.zshrc` file! I thought it would be fun to take a dive into the different tools I use to elevate my developer game.
     11 
     12 **If you want to see my whole config, I keep all my setup files on GitHub:** [https://github.com/unitehenry/config](https://github.com/unitehenry/config)
     13 
     14 ## Tools I Use
     15 
     16 Before we dive into my configuration, here are the tools I use that help me speed up my tasks as a developer:
     17 
     18 `fzf` | [Fuzzy File Finder](https://github.com/junegunn/fzf)
     19 
     20 `pandoc` | [Pandoc Document Converter](https://pandoc.org)
     21 
     22 `brew` | [MacOS Package Manager](https://brew.sh)
     23 
     24 ## The Variables
     25 
     26 ```
     27 # EDITOR
     28 export EDITOR="vi";
     29 export VISUAL="vi";
     30 
     31 # iCloud Directory
     32 export DOCS="/Users/henryunite/Library/Mobile Documents/com~apple~CloudDocs";
     33 
     34 # Work Directory
     35 export WORK="/Users/henryunite/Projects/bicycletransit";
     36 ```
     37 
     38 Pretty straightforward, but these are what I use to:
     39 
     40 *   Default editing to be opened in vim
     41 *   Reference my iCloud directory which I use to keep all my personal files
     42 *   A quick reference to where I keep all my work repositories, notes, projects
     43 
     44 ## Credentials
     45 
     46 ```
     47 # Credentials Fetcher
     48 function username() {
     49   export PASS_BACK_PATH=$(pwd);
     50   cd $DOCS/passwords;
     51   echo $(decrypt-file $(fzf) | grep "Username:" | cut -d ":" -f2) | pbcopy;
     52   cd $PASS_BACK_PATH && unset PASS_BACK_PATH;
     53 }
     54 
     55 function password() {
     56   export PASS_BACK_PATH=$(pwd);
     57   cd $DOCS/passwords;
     58   echo $(decrypt-file $(fzf) | grep "Password:" | cut -d ":" -f2) | pbcopy;
     59   cd $PASS_BACK_PATH && unset PASS_BACK_PATH;
     60 }
     61 ```
     62 
     63 There are so many chrome extensions, keychains, any ways to access your passwords. I personally encrypt my passwords in my cloud storage so I can access them by utilizing a `aes-256-cbc` decryption tool.
     64 
     65 ## File Formatting
     66 
     67 ```
     68 ## Code Formatter
     69 function format-file() {
     70   export FILENAME="$(basename $@)";
     71   export EXTENSION="${FILENAME##*.}";
     72 
     73   if [ $EXTENSION = 'py' ]
     74   then
     75     yapf --in-place $@;
     76     return 0;
     77   fi
     78 
     79   if [ $EXTENSION = 'php' ]
     80   then
     81     php-cs-fixer fix $@;
     82     rm .php_cs.cache;
     83     return 0;
     84   fi
     85 
     86   npx prettier --write --single-quote $@;
     87 
     88   unset FILENAME; unset EXTENSION;
     89 }
     90 ```
     91 
     92 File formatter that handles the languages I use on a day-to-day basis. It gets the job done for most file types including JSON, YAML, and even markdown.
     93 
     94 ## Spell Check
     95 
     96 ```
     97 ## Spellcheck
     98 function spellcheck-file() {
     99   npx spellchecker-cli --files $@;
    100 }
    101 ````
    102 
    103 When you're writing as much markdown documentation as me, you'll want an easy way to spell check your files.
    104 
    105 ## What the Commit
    106 
    107 ```
    108 ## What the Commit
    109 function wtf() { git commit -am "$(curl http://whatthecommit.com/index.txt)"; }
    110 ```
    111 
    112 This is a gimmick, but if you ever just want to commit file changes and you just don't know what to say in the commit message, [what the commit](http://whatthecommit.com/) is just a fun resource to get whacky commit messages.
    113 
    114 ## Cheat Sheet
    115 
    116 ```
    117 ## Cheat
    118 function cheat(){ curl https://cheat.sh/"$@"; }
    119 ```
    120 
    121 There are so many times I use a CLI tool and can't remember simple commands and options that it takes to perform certain tasks. Check out [cheat.sh](https://cheat.sh) if you're looking for an easy way to reference different CLI tools.
    122 
    123 ## Document Generation
    124 
    125 ```
    126 ## Generate Markdown
    127 function generate-doc() { 
    128   cp -rf . /tmp;
    129   if [ -n "$2" ]
    130   then
    131     pandoc -s $1 -c $2 -o "/tmp/$1.html";
    132   else
    133     pandoc -s $1 -o "/tmp/$1.html"; 
    134   fi
    135   open "/tmp/$1.html";
    136 }
    137 
    138 ## Generate Slide
    139 function generate-slide() {
    140   # https://revealjs.com/config/
    141   pandoc -t revealjs \
    142     -V progress="false" \
    143     -V navigationMode="linear" \
    144     -V transition="none" \
    145     -s $1 -o "/tmp/$1.html";
    146   cp -rf . /tmp;
    147   open "/tmp/$1.html";
    148 }
    149 ```
    150 
    151 I use markdown to write documentation all the time, but if I need to send a coworker a document or present a slide with content that is written in markdown, I'll use [pandoc](https://pandoc.org) to generate these intermediary file formats.
    152 
    153 It's really nice to leverage CSS when I want to make my documents look nice or need a clean way to look at markdown files.
    154 
    155 ## File Encryption
    156 
    157 ```
    158 ## Encrypt : aes-256-cbc
    159 function encrypt-file() {
    160   if [ -z $@ ]
    161   then
    162     echo -n "Enter Encrypt Phrase: "; read -s ENCRYPTINPUT; echo "\n";
    163     echo $ENCRYPTINPUT | openssl enc -aes-256-cbc;
    164     unset ENCRYPTINPUT;
    165   else
    166     openssl enc -aes-256-cbc -in $@;
    167   fi
    168 }
    169 
    170 ## Decrypt : aes-256-cbc
    171 function decrypt-file() {
    172   if [ -z $@ ]
    173   then
    174     openssl enc -d -aes-256-cbc;
    175   else
    176     openssl enc -aes-256-cbc -d -in $@;
    177   fi
    178 }
    179 ```
    180 
    181 It's nice to have a quick way to encrypt and decrypt files with sensitive information.
    182 
    183 ## Homebrew
    184 
    185 ```
    186 ## Homebrew Install Script
    187 function install-homebrew() { /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; }
    188 ```
    189 
    190 This is just in my configuration in the event that I just want to install [homebrew](https://brew.sh) without copying and pasting the install script from the website.
    191 
    192 If I have a new Mac I need to setup, it'll make the setup so much easier.
    193 
    194 ## Version Managers
    195 
    196 ```
    197 source ~/.nvmrc;
    198 source ~/.rvmrc;
    199 ```
    200 
    201 I've been using `nvm` and `rvm` to manage my node and ruby installations. They append rc scripts to load into your base rc file which I extract into their own designated files and load them in at the end.