Skip to content

Instantly share code, notes, and snippets.

View andykais's full-sized avatar

Andrew Kaiser andykais

View GitHub Profile
@andykais
andykais / dns_check.sh
Created August 26, 2015 02:00
check every hour if my dns manager has allowed github pages redirect, send a text message if it has
#!/bin/bash
#one hour (in seconds)
wait=$((60 * 60))
while true
do
dns=$(dig andykais.com +nostats +nocomments +nocmd)
if [[ $dns == *"github"* ]]
then
@andykais
andykais / roc.sh
Last active August 29, 2015 14:17
I use for run on change for any compiling program with nice output
#!/bin/sh
FORMAT=$(echo -e "\033[1;33m%w%f\033[0m written at $(date +'%r')")
"$@"
while inotifywait -qre close_write --format "$FORMAT" .
do
"$@"
done
@andykais
andykais / fire.sh
Last active August 29, 2015 14:17
I use with run on change to auto update a web app in the current directory
#!/bin/bash
xdotool search --name firefox key --window %@ F5
@andykais
andykais / chrome.sh
Last active August 29, 2015 14:17
chrome version of my run on change to auto update for web pages
#!/bin/bash
# the current version of chrome in linux requires focus on the window for xdotool
#this is a workaround to focus back to the editor after reloading the page
editor=`xdotool getwindowfocus`
xdotool search --onlyvisible --class "Chrome" windowfocus key 'ctrl+r'
xdotool windowfocus $editor
@andykais
andykais / screenshot.sh
Last active August 29, 2015 14:19
my bash code to prevent overwriting a file (and taking a screenshot with the filename)
#!/bin/bash
i="0"
FILE="/home/andrew/Pictures/screenshots/screenshot($i).png"
while [ -f $FILE ];
do
i=$[$i+1]
FILE="/home/andrew/Pictures/screenshots/screenshot($i).png"
done
@andykais
andykais / ranger.py
Last active August 29, 2015 14:19
after ranger quits, cd to the chosen directory.
ranger() {
tempfile='/tmp/chosendir'
/usr/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}"
test -f "$tempfile" &&
if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
cd -- "$(cat "$tempfile")"
fi
rm -f -- "$tempfile"
}
@andykais
andykais / mou.sh
Last active August 29, 2015 14:23
script for mounting the usb/hdd drives on my pi upon startup
#!/bin/bash
sudo blkid | grep sda | while read -r line
do
USB=$(echo $line | perl -pe 's/\:(.*)//')
TYPE=$(echo $line | perl -pe 's/(.*)TYPE=// and s/"//g')
DIR=$(echo $line | perl -pe 's/(.*)\/// and s/\:(.*)//')
@andykais
andykais / .bashrc
Created July 5, 2015 06:17
PS1 code to get colored folder and user info
PS1='$(if [ $? -eq 0 ]; then echo "\[\033[32m\]:)"; else echo "\[\033[31m\]:("; fi) ${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u : \[\033[01;34m\]$(echo $(pwd) | grep -o "/" | wc -l)/$(basename $(pwd))\[\033[00m\] - '
@andykais
andykais / .vimrc
Created July 8, 2015 15:28
get 256 color in gnome terminal
syntax enable
set background=dark
colorscheme solarized
if $COLORTERM == 'gnome-terminal'
set t_Co=256
endif
@andykais
andykais / moni.sh
Created August 22, 2015 16:43
used for setting up multiple monitors
#!/bin/bash
xrandr -q | grep 'connected' | awk '{print $1}' | while read line
do
if [ "$line" != "LVDS1" ]
then
xrandr --output $line --left-of LVDS1 --auto
fi