Skip to content

Commit

Permalink
restructured for stow install
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestomasino committed Nov 11, 2016
1 parent 1866557 commit 4c383b6
Show file tree
Hide file tree
Showing 54 changed files with 39,828 additions and 130 deletions.
File renamed without changes.
File renamed without changes.
Empty file removed bash/.scripts
Empty file.
Binary file added bin/BrowserStackTunnel.jar
Binary file not shown.
10 changes: 10 additions & 0 deletions bin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## bin scripts intended for ~/bin

### Dependencies ###

- safe-reattach-to-user-namespace requires `attach-to-user-namespace`
- brew install attach-to-user-namespace
- weather requires `jq`
- [jq](http://stedolan.github.io/jq/)
- speedread requires `perl 5.16.0`
- http://perlbrew.pl/ (then install 5.16.0 or later)
Binary file added bin/adb
Binary file not shown.
57 changes: 57 additions & 0 deletions bin/b
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
# vim: set filetype=ruby:
# b - browse Chrome bookmarks with fzf

[ $(uname) = Darwin ] || exit 1
which fzf > /dev/null 2>&1 || brew reinstall --HEAD fzf || exit 1

ruby -x "$0" |
fzf-tmux -u 30% --ansi --multi |
awk 'BEGIN { FS = "\t" } { print $2 }' |
xargs open

exit $?

#!ruby
# encoding: utf-8

require 'json'
FILE = '~/Library/Application Support/Google/Chrome/Default/Bookmarks'
CJK = /\p{Han}|\p{Katakana}|\p{Hiragana}|\p{Hangul}/

def build parent, json
name = [parent, json['name']].compact.join('/')
if json['type'] == 'folder'
json['children'].map { |child| build name, child }
else
{ name: name, url: json['url'] }
end
end

def just str, width
str.ljust(width - str.scan(CJK).length)
end

def trim str, width
len = 0
str.each_char.each_with_index do |char, idx|
len += char =~ CJK ? 2 : 1
return str[0, idx] if len > width
end
str
end

width = `tput cols`.strip.to_i / 2
json = JSON.load File.read File.expand_path FILE
items = json['roots']
.values_at(*%w(bookmark_bar synced other))
.compact
.map { |e| build nil, e }
.flatten

items.each do |item|
name = trim item[:name], width
puts [just(name, width),
item[:url]].join("\t\x1b[36m") + "\x1b[m"
end

4 changes: 4 additions & 0 deletions bin/colors
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
for c in {0..255} ; do
echo "\033[38;05;${c}m \\\033[38;05;${c}m"
done
Binary file added bin/fastboot
Binary file not shown.
129 changes: 129 additions & 0 deletions bin/fzf-tmux
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#!/usr/bin/env bash
# fzf-tmux: starts fzf in a tmux pane
# usage: fzf-tmux [-u|-d [HEIGHT[%]]] [-l|-r [WIDTH[%]]] [--] [FZF OPTIONS]

args=()
opt=""
skip=""
swap=""
close=""
term=""
while [ $# -gt 0 ]; do
arg="$1"
case "$arg" in
-)
term=1
;;
-w*|-h*|-d*|-u*|-r*|-l*)
if [ -n "$skip" ]; then
args+=("$1")
shift
continue
fi
if [[ "$arg" =~ ^.[lrw] ]]; then
opt="-h"
if [[ "$arg" =~ ^.l ]]; then
opt="$opt -d"
swap="; swap-pane -D ; select-pane -L"
close="; tmux swap-pane -D"
fi
else
opt=""
if [[ "$arg" =~ ^.u ]]; then
opt="$opt -d"
swap="; swap-pane -D ; select-pane -U"
close="; tmux swap-pane -D"
fi
fi
if [ ${#arg} -gt 2 ]; then
size="${arg:2}"
else
shift
if [[ "$1" =~ ^[0-9]+%?$ ]]; then
size="$1"
else
[ -n "$1" -a "$1" != "--" ] && args+=("$1")
shift
continue
fi
fi

if [[ "$size" =~ %$ ]]; then
size=${size:0:((${#size}-1))}
if [ -n "$swap" ]; then
opt="$opt -p $(( 100 - size ))"
else
opt="$opt -p $size"
fi
else
if [ -n "$swap" ]; then
if [[ "$arg" =~ ^.l ]]; then
[ -n "$COLUMNS" ] && max=$COLUMNS || max=$(tput cols)
else
[ -n "$LINES" ] && max=$LINES || max=$(tput lines)
fi
size=$(( max - size ))
[ $size -lt 0 ] && size=0
opt="$opt -l $size"
else
opt="$opt -l $size"
fi
fi
;;
--)
# "--" can be used to separate fzf-tmux options from fzf options to
# avoid conflicts
skip=1
;;
*)
args+=("$1")
;;
esac
shift
done

if [ -z "$TMUX_PANE" ]; then
fzf "${args[@]}"
exit $?
fi

set -e

# Build arguments to fzf
[ ${#args[@]} -gt 0 ] && fzf_args=$(printf '\\"%s\\" ' "${args[@]}"; echo '')

# Clean up named pipes on exit
id=$RANDOM
fifo1=/tmp/fzf-fifo1-$id
fifo2=/tmp/fzf-fifo2-$id
fifo3=/tmp/fzf-fifo3-$id
cleanup() {
rm -f $fifo1 $fifo2 $fifo3
}
trap cleanup EXIT SIGINT SIGTERM

fail() {
>&2 echo "$1"
exit 1
}
fzf="$(which fzf 2> /dev/null)" || fzf="$(dirname "$0")/fzf"
[ -x "$fzf" ] || fail "fzf executable not found"

envs=""
[ -n "$FZF_DEFAULT_OPTS" ] && envs="$envs FZF_DEFAULT_OPTS=$(printf %q "$FZF_DEFAULT_OPTS")"
[ -n "$FZF_DEFAULT_COMMAND" ] && envs="$envs FZF_DEFAULT_COMMAND=$(printf %q "$FZF_DEFAULT_COMMAND")"

mkfifo $fifo2
mkfifo $fifo3
if [ -n "$term" -o -t 0 ]; then
tmux set-window-option -q synchronize-panes off \;\
split-window $opt "cd $(printf %q "$PWD");$envs"' sh -c "'$fzf' '"$fzf_args"' > '$fifo2'; echo \$? > '$fifo3' '"$close"'"' $swap
else
mkfifo $fifo1
tmux set-window-option -q synchronize-panes off \;\
split-window $opt "$envs"' sh -c "'$fzf' '"$fzf_args"' < '$fifo1' > '$fifo2'; echo \$? > '$fifo3' '"$close"'"' $swap
cat <&0 > $fifo1 &
fi
cat $fifo2
[ "$(cat $fifo3)" = '0' ]

9 changes: 9 additions & 0 deletions bin/git-by-day
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Generates changelog day by day
echo "CHANGELOG"
echo ----------------------
git log --no-merges --format="%cd" --date=short | sort -u -r | while read DATE ; do
echo -e "\033[38;05;226m [$DATE] \033[0m"
GIT_PAGER=cat git log --no-merges --format=" * %s (%Cgreen%an%Creset)" --since="$DATE 00:00:00" --until="$DATE 24:00:00"
done

13 changes: 13 additions & 0 deletions bin/git-by-day-md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# Generates changelog day by day
echo "CHANGELOG"
echo ----------------------
git log --no-merges --format="%cd" --date=short | sort -u -r | while read DATE ; do
echo
echo -e "####$DATE####"
echo
GIT_PAGER=cat git log --no-merges --format=" * %s (\`%an\`)" --since="$DATE 00:00:00" --until="$DATE 09:00:00"
GIT_PAGER=cat git log --no-merges --format=" * __%s__ (\`%an\`)" --since="$DATE 09:00:01" --until="$DATE 17:30:00"
GIT_PAGER=cat git log --no-merges --format=" * %s (\`%an\`)" --since="$DATE 17:30:01" --until="$DATE 24:00:00"
done

Loading

0 comments on commit 4c383b6

Please sign in to comment.