small pixel drawing of a pufferfish dotfiles

Add select bin scripts
j3s j3s@cyberia.club
Tue, 26 Nov 2019 09:22:35 -0600
commit

7482308e9599baa5fcae02d49f0e9c923be8be5d

parent

9d9217a09d769eeaf6d2a86a3200fa339e0033bc

A bin/MACC02VK5ECHTD7/how

@@ -0,0 +1,63 @@

+#!/bin/sh + +clone_url="ssh://git@git.bestbuy.com/~jesse.olson/howdocs-test.git" + +if [ ! "$#" -gt 0 ]; then + echo "Need a string to search for!" + exit 1 +fi + +# check for fzf & ripgrep-all, install if unfound +if ! fzf --version > /dev/null 2>&1; then + echo "fzf required. Install fzf via brew y/n? " + read -r + if [ "$REPLY" = "y" ]; then + brew install fzf + else + exit 1 + fi +fi + +if ! rg --version > /dev/null 2>&1; then + echo "ripgrep required. Install ripgrep via brew y/n? " + read -r + if [ "$REPLY" = "y" ]; then + brew install ripgrep + else + exit 1 + fi +fi + +# maybe todo: if there are staged changes, ask user to push them? + +# clone/update repository +if [ -d ~/howdocs ]; then + (cd ~/howdocs && git pull) +else + echo 'First run detected. Cloning repo...' + git clone "$clone_url" ~/howdocs +fi + +# fzf the directory +result=$(rg -S --files-with-matches --no-messages "$1" ~/howdocs \ + | fzf --preview "highlight -O ansi -l {} 2> /dev/null \ + | rg --colors 'match:bg:yellow' --ignore-case --pretty --context 10 '$1' \ + || rg --ignore-case --pretty --context 10 '$1' {}") + +if [ "$result" = "" ]; then + echo 'no documents found' + exit 1 +fi + +# open up relevant file in vim for copy+pasting +if [ "$EDITOR" ]; then + "$EDITOR" "$result" +else + vim "$result" +fi + +# if file changed, save & commit changes & push +if ! (cd ~/howdocs && git diff-index --quiet HEAD --); then + echo "detected howdoc changes; pushing them:" + (cd ~/howdocs && git add --all && git commit -m '[Automated Commit]' && git push) +fi
A bin/MACC02VK5ECHTD7/j

@@ -0,0 +1,6 @@

+#!/bin/sh + +local query="$1" +shift 2> /dev/null +local ip=$(awless list instances --filter state=running,name="$query" "$@" --format json | jq -r '.[] | [.PrivateIP] | .[]' | head -n1) +/usr/local/bin/ssh "$ip"
A bin/MACC02VK5ECHTD7/jmass

@@ -0,0 +1,12 @@

+#!/bin/bash +query="$1" +shift 2> /dev/null +ips=$(awless list instances --filter state=running,name="$query" "$@" --format json | jq -r '.[] | [.PrivateIP] | .[]') +tmux new-window 'ssh-trash-test' + +while IFS= read -r i + do tmux split-window "ssh $i" + tmux select-layout tiled +done <<< "$ips" + +tmux setw synchronize-panes on
A bin/darkdepths/make-vm

@@ -0,0 +1,33 @@

+#!/bin/bash + +if [[ $1 == "" || $1 == "--help" || $1 == "-h" ]]; then + echo "Usage: make-vm [vm-name] [options]" + echo "some options:" + echo " mem=<number-in-megabytes>" + echo " cpu=<cores>" + echo " disk=<gbytes>" + echo " env=<public|private>" + exit 1 +fi + +name="$1" +env="private" +disk="8" # in gb +mem="512" # in mb +cpu="1" # in cores + +if [[ -e /vm/$name.xml || -e /dev/vg0/$name.disk ]]; then + echo 'vm/disk already exists' + exit 1 +fi + +echo "Carving $disk GB lv in /dev/vg0/$name.disk" +lvcreate -n "$name.disk" --size 8G vg0 + +echo "createing writing /vm/$name.xml" +touch "/vm/$name.xml" +virt-install -n $name -r 8192 \ + $name $cpus $type $variant $disk $location $graphics $bus $network + +qemu-system-x86_64 -hda /vm/vdisk.img -m 1024 -enable-kvm -netdev user,id=user.0 -device e1000,netdev=user.0 -soundhw ac97 -no-acpi -daemonize -usb -usbdevice tablet +
A bin/n

@@ -0,0 +1,7 @@

+#!/bin/sh + +notefile="$HOME/sync/notes.md" +printf '\n' >> "$notefile" +date +"%Y-%m-%d %H:%M" >> "$notefile" +printf -- "----------------" >> "$notefile" +vim "+normal Go" +startinsert "$notefile"
A bin/short-pwd

@@ -0,0 +1,5 @@

+#!/bin/sh + +term=$(printf "$PWD" | sed -E 's|(\.?[^/])([^/]+)\/|\1/|g') + +printf "\033[01;90m$term\e[0m"