diff --git a/bin/SC b/bin/SC deleted file mode 100755 index 648da29..0000000 --- a/bin/SC +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -e - -FILENAME="/Users/tyrel/tmp/screenshot.png" -screencapture -io $FILENAME - -sleep 1 - -MD5=($(md5 -q "$FILENAME")) -fname=$MD5.png -scp -rp "$FILENAME" vps:/www/tyrelsouza.com/screenshots/$fname; -osascript -e "display notification \"Uploaded $FILENAME to https://tyrelsouza.com/screenshots/$fname\" with title \"Tyrel Upload\"" -echo -ne https://tyrelsouza.com/screenshots/$fname | pbcopy -rm "$FILENAME" diff --git a/bin/emax b/bin/emax index 3c6f214..59a8036 100755 --- a/bin/emax +++ b/bin/emax @@ -1,2 +1,6 @@ #!/bin/bash -$(/Applications/Emacs.app/Contents/MacOS/Emacs "$@") & + +APPS=/Applications +if [ -d "$APPS" ]; then + $(/Applications/Emacs.app/Contents/MacOS/Emacs "$@") & +fi diff --git a/bin/gochk b/bin/gochk new file mode 100755 index 0000000..b1e50dc Binary files /dev/null and b/bin/gochk differ diff --git a/bin/goland.sh b/bin/goland.sh new file mode 100755 index 0000000..b8849ac --- /dev/null +++ b/bin/goland.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +/bin/bash -l '/home/tyrel/src/GoLand-2019.3/bin/goland.sh' %f diff --git a/bin/golangci-lint b/bin/golangci-lint new file mode 100755 index 0000000..8c1df39 Binary files /dev/null and b/bin/golangci-lint differ diff --git a/bin/killtransmission.sh b/bin/killtransmission.sh new file mode 100755 index 0000000..d29f225 --- /dev/null +++ b/bin/killtransmission.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +killall transmission-gtk diff --git a/bin/pre-commit b/bin/pre-commit deleted file mode 120000 index 9e87488..0000000 --- a/bin/pre-commit +++ /dev/null @@ -1 +0,0 @@ -/Users/tyrel/.pre-commit-venv/bin/pre-commit \ No newline at end of file diff --git a/bin/pycharm.sh b/bin/pycharm.sh new file mode 100755 index 0000000..27d12e8 --- /dev/null +++ b/bin/pycharm.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +/bin/bash -l '/home/tyrel/src/pycharm-2017.3.7/bin/pycharm.sh' %f diff --git a/bin/rubymine.sh b/bin/rubymine.sh new file mode 100755 index 0000000..100d834 --- /dev/null +++ b/bin/rubymine.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +/bin/bash -l '/home/tyrel/src/RubyMine-2019.3/bin/rubymine.sh' %f diff --git a/bin/sc b/bin/sc new file mode 100755 index 0000000..9b21616 --- /dev/null +++ b/bin/sc @@ -0,0 +1,103 @@ +#!/usr/bin/env bash +# Take a screenshot of a selected area and upload it somewhere. +# +# Requires: +# * scrot +# * xclip + +### CHANGE THESE FUNCTIONS: + +upload() { + # Given a filepath and a target name, upload the screenshot + chmod +r "$1" + scp "$1" "tyrelsouza.com:/www/tyrel.pw/s/$2" +} + +url() { + # Given a target name, echo the expected URL of the uploaded screenshot + echo "https://tyrel.pw/s/$1" +} + +### (End) + +screenshot() { + if $(which maim &> /dev/null); then + maim -s $1 || return -1 + elif $(which scrot &> /dev/null); then + scrot -s $1 || return -1 + elif $(which screencapture &> /dev/null); then + screencapture -i $1 || return -1 + else + echo "No screenshot utility found. Install scrot." + return -1 + fi +} + +clipboard() { + if $(which xclip &> /dev/null); then + echo $1 | xclip -r -selection clipboard + elif $(which pbcopy &> /dev/null); then + echo $1 | pbcopy + else + echo "No clipboard utility found. Install xclip." + return -1 + fi +} + +notify() { + if $(which osascript &> /dev/null); then + osascript -e "display notification \"$2\" with title \"$1\"" + elif $(which notify-send &> /dev/null); then + notify-send "$1" "$2" + else + echo "Notification not supported, skipped: $1: $2" + return -1 + fi +} + +fail() { + echo "$2" + exit $1 +} + +# Fail early +set -e + +# If a path is given, use that instead of taking a screenshot +target="$1" + +name="$(date '+%d')" +tmppath="$(mktemp -t ss.XXXX.png)" || fail 1 "failed to allocate a temporary file" + +# Make it hard to guess +random_string=$(head -c512 /dev/urandom | shasum | head -c4) + +# Compose full filename +filename="${name}_${random_string}.png" + +if [[ "${target}" ]]; then + cp -p "${target}" "${tmppath}" +else + # Take the screenshot + screenshot "${tmppath}" || fail 2 "failed to take screenshot" +fi + +# Clear clipboard +clipboard " " + +# Upload it +url=$(url "${filename}") +echo "Uploading: $url" +upload "${tmppath}" "${filename}" && rm "${tmppath}" || fail 3 "failed to upload ${tmppath}" + +# Copy to clipboard +clipboard "${url}" +echo "Copied to clipboard." + +# Clean up +if [[ -f "${tmppath}" ]]; then + rm "${tmppath}" +fi + +notify "Uploaded Screenshot" "${url}" + diff --git a/bin/scf b/bin/scf new file mode 100755 index 0000000..863a779 --- /dev/null +++ b/bin/scf @@ -0,0 +1,103 @@ +#!/usr/bin/env bash +# Take a screenshot of a selected area and upload it somewhere. +# +# Requires: +# * scrot +# * xclip + +### CHANGE THESE FUNCTIONS: + +upload() { + # Given a filepath and a target name, upload the screenshot + chmod +r "$1" + scp "$1" "tyrelsouza.com:/www/tyrel.pw/s/$2" +} + +url() { + # Given a target name, echo the expected URL of the uploaded screenshot + echo "https://tyrel.pw/s/$1" +} + +### (End) + +screenshot() { + if $(which maim &> /dev/null); then + maim $1 || return -1 + elif $(which scrot &> /dev/null); then + scrot -s $1 || return -1 + elif $(which screencapture &> /dev/null); then + screencapture -i $1 || return -1 + else + echo "No screenshot utility found. Install scrot." + return -1 + fi +} + +clipboard() { + if $(which xclip &> /dev/null); then + echo $1 | xclip -r -selection clipboard + elif $(which pbcopy &> /dev/null); then + echo $1 | pbcopy + else + echo "No clipboard utility found. Install xclip." + return -1 + fi +} + +notify() { + if $(which osascript &> /dev/null); then + osascript -e "display notification \"$2\" with title \"$1\"" + elif $(which notify-send &> /dev/null); then + notify-send "$1" "$2" + else + echo "Notification not supported, skipped: $1: $2" + return -1 + fi +} + +fail() { + echo "$2" + exit $1 +} + +# Fail early +set -e + +# If a path is given, use that instead of taking a screenshot +target="$1" + +name="$(date '+%d')" +tmppath="$(mktemp -t ss.XXXX.png)" || fail 1 "failed to allocate a temporary file" + +# Make it hard to guess +random_string=$(head -c512 /dev/urandom | shasum | head -c4) + +# Compose full filename +filename="${name}_${random_string}.png" + +if [[ "${target}" ]]; then + cp -p "${target}" "${tmppath}" +else + # Take the screenshot + screenshot "${tmppath}" || fail 2 "failed to take screenshot" +fi + +# Clear clipboard +clipboard " " + +# Upload it +url=$(url "${filename}") +echo "Uploading: $url" +upload "${tmppath}" "${filename}" && rm "${tmppath}" || fail 3 "failed to upload ${tmppath}" + +# Copy to clipboard +clipboard "${url}" +echo "Copied to clipboard." + +# Clean up +if [[ -f "${tmppath}" ]]; then + rm "${tmppath}" +fi + +notify "Uploaded Screenshot" "${url}" + diff --git a/bin/startup_i3.sh b/bin/startup_i3.sh new file mode 100755 index 0000000..8f5038c --- /dev/null +++ b/bin/startup_i3.sh @@ -0,0 +1,4 @@ +#!/bin/bash +xrandr --output DP-4 --right-of DP-2 +xrandr --output DP-4 --rotate left + diff --git a/bin/subl b/bin/subl deleted file mode 120000 index 0170a20..0000000 --- a/bin/subl +++ /dev/null @@ -1 +0,0 @@ -/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl \ No newline at end of file diff --git a/bin/update-neovim.sh b/bin/update-neovim.sh new file mode 100755 index 0000000..b83bcfe --- /dev/null +++ b/bin/update-neovim.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +sudo rm -rf /opt/nightlies/neovim +git clone https://github.com/neovim/neovim /opt/nightlies/neovim +cd /opt/nightlies/neovim +git checkout stable +make -j4 +sudo make install diff --git a/bin/vimv b/bin/vimv index b0d5d19..3c78afb 100755 --- a/bin/vimv +++ b/bin/vimv @@ -1,18 +1,17 @@ -#!/usr/bin/env bash -set -eu +#!/bin/bash # Lists the current directory's files in Vim, so you can edit it and save to rename them # USAGE: vimv [file1 file2] # https://github.com/thameera/vimv -declare -r FILENAMES_FILE=$(mktemp "${TMPDIR:-/tmp}/vimv.XXX") +declare -r FILENAMES_FILE="$(mktemp --tmpdir vimv.XXX)" trap '{ rm -f "${FILENAMES_FILE}" ; }' EXIT if [ $# -ne 0 ]; then src=( "$@" ) else - IFS=$'\r\n' GLOBIGNORE='*' command eval 'src=($(ls))' + IFS=$'\r\n' GLOBIGNORE='*' command eval 'src=($(ls))' fi for ((i=0;i<${#src[@]};++i)); do @@ -21,9 +20,9 @@ done ${EDITOR:-vi} "${FILENAMES_FILE}" -IFS=$'\r\n' GLOBIGNORE='*' command eval 'dest=($(cat "${FILENAMES_FILE}"))' +IFS=$'\r\n' GLOBIGNORE='*' command eval 'dest=($(cat "${FILENAMES_FILE}"))' -declare -i count=0 +count=0 for ((i=0;i<${#src[@]};++i)); do if [ "${src[i]}" != "${dest[i]}" ]; then mkdir -p "`dirname "${dest[i]}"`" @@ -32,7 +31,7 @@ for ((i=0;i<${#src[@]};++i)); do else mv "${src[i]}" "${dest[i]}" fi - ((++count)) + ((count++)) fi done diff --git a/jobs/tidelift.sh b/jobs/tidelift.sh index d1d007d..0a5cebf 100644 --- a/jobs/tidelift.sh +++ b/jobs/tidelift.sh @@ -5,3 +5,12 @@ function pulldep() { bundle bundle exec rake db:migrate } + +function tide() { + for var in "$@" + do + open -a iTerm ~/code/tidelift/$var + settitle $var + done +} +