Skip to content

Instantly share code, notes, and snippets.

View jcanfield's full-sized avatar
💭
If I do not respond quickly, try me on Twitter at @creativeboulder.

Joshua Canfield jcanfield

💭
If I do not respond quickly, try me on Twitter at @creativeboulder.
View GitHub Profile
@jcanfield
jcanfield / new-macos-setup.sh
Created November 25, 2017 02:35 — forked from siathalysedI/new-macos-setup.sh
Things to setup/install on a new macOS
#!/bin/bash
# change default shell to zsh (asks for password)
chsh -s /bin/zsh
# install xcode command line tools
xcode-select --install
# download my custom .zshrc
curl https://gist.githubusercontent.com/simonhaenisch/382eab0cfa3435dad7e177a49fe198fc/raw/.zshrc > ~/.zshrc
@jcanfield
jcanfield / .bash_profile
Created November 25, 2017 02:33 — forked from stephenll/.bash_profile
.bash_profile file on Mac OS X
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases.
# Much of this was originally copied from:
# http://natelandau.com/my-mac-osx-bash_profile/
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
color_0 = ffff ffff ffff
color_1 = 4949 4848 3e3e
color_2 = 6666 d9d9 efef
color_3 = 6b6b c7c7 2b2b
color_4 = fdfd 9797 1f1f
color_5 = f9f9 2626 7272
color_6 = 94bc 5925 ffff
color_7 = 7575 7171 5e5e
color_8 = e6e6 dbdb 7474
color_9 = a6a6 e2e2 2e2e
@jcanfield
jcanfield / sweep-20170617.log
Created June 16, 2017 19:21
Sophos CLI `sweep` on MacOS Sierra (Segmentation fault: 11)
$ sudo sweep -di -dn /
Password:
Sophos Anti-Virus
Version 9.6.1 [Darwin/AMD64]
Virus data version 5.40, May 2017
Includes detection for 13427651 viruses, trojans and worms
Copyright (c) 1989-2017 Sophos Limited. All rights reserved.
System time 13:08:55, System date 16 June 2017
Command line qualifiers are: -di -dn
@jcanfield
jcanfield / googl.sh
Created June 11, 2017 07:33 — forked from trentm/googl.sh
Bash function to use the goo.gl URL shortener on stdin. See <https://developers.google.com/url-shortener/v1/getting_started> TODO: pbcopy it too if that command is available
# echo URL | googl
function googl {
local url=$(cat <&0)
(
set -e pipefail;
echo "{}" \
| json -e "this.longUrl='$url'" \
| curl -sf https://www.googleapis.com/urlshortener/v1/url \
-H 'Content-Type: application/json' -d@- \
| json id
@jcanfield
jcanfield / goo.gl.sh
Created June 11, 2017 07:28 — forked from buchanansc/goo.gl.sh
Bash: goo.gl # Shorten a URL using the Google URL Shortener service (http://goo.gl).
#!/usr/bin/env bash
# Usage: goo.gl [URL]
#
# Shorten a URL using the Google URL Shortener service (http://goo.gl).
goo.gl() {
[[ ! $1 ]] && { echo -e "Usage: goo.gl [URL]\n\nShorten a URL using the Google URL Shortener service (http://goo.gl)."; return; }
curl -qsSL -m10 --connect-timeout 10 \
'https://www.googleapis.com/urlshortener/v1/url' \
-H 'Content-Type: application/json' \
-d '{"longUrl":"'${1//\"/\\\"}'"}' |
@jcanfield
jcanfield / .bash_aliases
Created June 11, 2017 00:02
Bash Aliases for HTPC Linux
### List of Bash Aliases
## Hard Drive and Directory space commands
alias ls-space='echo "Displaying Disk space used per directory..." && du -slh * | sort -h'
alias ls-hdspace='echo "Displaying Hard Drive space used and available" && df -H && echo "Script complete. Press Enter to continue"'
@jcanfield
jcanfield / rename-files_to-folder.sh
Last active June 11, 2017 00:23
Rename files in a folder to match folder name (useful for htpc usage)
#!/bin/bash
# SYPOPSIS: Rename files in folder to match folder.
# CREDIT: Unamed user on superuser or superadmin. If you find this, let me know and I will add you to the credits.
# UPCOMING: Allow for secondary input such as `rename-files-to-folder $MOVIENAME` so not to rename all movies in directory just one or two.
find * -type f -maxdepth 1 | while read file
do
dirname="$(dirname "$file")"
new_name="${dirname##*/}"
file_ext=${file##*.}
@jcanfield
jcanfield / move-show.sh
Created June 10, 2017 23:23
Move a TV Show or Movie directory to another folder or drive
#!/bin/bash
# SYNOPSIS: Move a TV Show or Movie directory to another folder or drive
# USAGE:
# NOTES: The Function cp_p was discovered on StackExchange at http://j.mp/1OOqAV1.
#cp_p()
#{
# strace -q -ewrite cp -- "${1}" "${2}" 2>&1 \
# | awk '{
# count += $NF
@jcanfield
jcanfield / rename-movie-titles.sh
Created June 10, 2017 23:19
Use bash and linux tools to rename files in a folder, to the folder name.
#!/bin/bash
# SYNOPSIS: Rename all files in folder to match folder name.
# Testing 1
# rename -vn 's:(/[^/]*)/[^/]*$:$1$1.mkv:' folder/*/*.mkv
# Testing 2
#for f in folder/*/*.mkv;do dn="${f%/*}";echo mv -v "$f" "${dn}/${dn##*/}.mkv";done
# Testing #3