CLI Commands

scripts and aliases for the command line

I'm starting over with my collection of helpers and aliases for the command line. I don't do a lot with them. Partially that's because I hadn't picked a place to put them. We'll see if storing them here encourages more of them.

ads-off
update /etc/hosts to blackhole ad domains
#!/bin/bash

sudo sed -i -E 's/^# 0.0.0.0/0.0.0.0/g' "/etc/hosts"
ads-on
update /etc/hosts turn off ad domain blackholes
#!/bin/bash

sudo sed -i -E 's/^0.0.0.0/# 0.0.0.0/g' "/etc/hosts"
bsync
start browser-sync in the current directory
#!/bin/bash

browser-sync . --port 3993 --watch --index "index.html" --no-notify --no-inject-changes --reload-debounce --no-ghost-mode
commit Commit message goes here.
does git add -A to add all files in the repo, then git commit -m"TEXT". Uses "${*}". Standard quoting rules apply.
#!/bin/bash

git add -A
git commit -m "${*}"
dt
alias for cd ~/Desktop
#!/bin/bash

cd ~/Desktop
glog
pretty output from git log (currently not making newlines properly)
#!/bin/bash

# Grab the initial output from git log and reverse it.
INITIAL_OUTPUT=$(git log --decorate --oneline --abbrev-commit --graph --all --color=always | sed '1!G;h;$!d') 
# Loop through it line by line
while read THE_LINE
do
  # Just output it if it's a commit (identifed by a "*")
  if [[ "$THE_LINE" =~ '\*' ]]; then
    echo "$THE_LINE"
  # Otherwise, flip the "/" and "\" characters
  else
    # Figure out which way to flip
    if [[ "$THE_LINE" =~ '/' ]]; then
      echo "$THE_LINE" | sed 's/\//\\/g;'
    else
      echo "$THE_LINE" | sed 's/\\/\//g;'
    fi
  fi
done <<< $INITIAL_OUTPUT
l
alias for ls -lh
#!/bin/bash

ls -lh
la
alias for ls -lah
#!/bin/bash

ls -lah
ll
alias for ls -lh
#!/bin/bash

ls -lh
new-site new-site-name
create a new site repo from the ssb-template, clone it down, move into it and create a dev branch
#!/bin/bash

gh repo new "$1" --public -p ssb-template --clone && \
cd "$1" && \
git checkout -b dev && \
netlify init &&
netlify open
nv (or nv FILENAME)
because typing nvim is too many characters
#!/bin/bash

nvim "$1"
push
deployment: merges dev into main for the current repo, pushes main, then switches back to dev
#!/bin/bash

MESSAGE="${*}"
ALT_MESSAGE="Deployment: ${date}"

STATUS=$(git status | sed -n '$p' | tr -d '\n')
if [ "$STATUS" == "nothing to commit, working tree clean" ]; then
  if [ "$MESSAGE" == "" ]; then
    git checkout main && \
    git merge --no-ff dev -m "$ALT_MESSAGE" && \
    git push && \
    git checkout dev
  else 
    git checkout main && \
    git merge --no-ff dev -m "$MESSAGE" && \
    git push && \
    git checkout dev
  fi
else 
  echo "ERROR: There are uncomitted changes"
fi
push-aws
deploys alanwsmith.com
#!/bin/bash

cd /Users/alan/Documents/Neopoligen/alanwsmith.com && \
git add . && \
git commit -m"Updates" && \
git push
rgfiles
list files with ripgrep matches instead of lines
#!/bin/bash

rg -l "$1" *
sl
alias for ls -lh
#!/bin/bash

ls -lh
status
alias for git status
#!/bin/bash

git status
ta session-name
alias for tmux a -t session-name
#!/bin/bash

tmux a -t "$1"
tmls
alias for tmux ls
#!/bin/bash

tmux ls