Skip to content

Instantly share code, notes, and snippets.

@mattward
mattward / countf
Created March 31, 2016 10:11
Count files in the given directories
#!/bin/bash
script_name=`basename $0`
if [[ "$1" == "--help" ]]; then
echo "Usage ${script_name} [subdirectory1 [subdirectory2]...]"
echo "Counts the files in the specified directories, or in all subdirectories if none specified"
exit 1
fi
@mattward
mattward / sleep-delay
Created March 21, 2016 09:30
Set Macbook "deep sleep" threshold between Apple's default time (1 hr 10 mins) and a longer time (3 hrs)
#!/bin/bash
script_name=`basename $0`
function show_usage {
echo "Sets the time delay before the Mac goes into 'deep sleep'."
echo " Usage: $script_name time"
echo " Where time is 'default' or 'long'."
exit 1
}
@mattward
mattward / config
Last active November 16, 2022 10:01
Template for SSH config: ~/.ssh/config
################################################################################
# File: SSH client configuration
# Author: Matt Ward
################################################################################
Host wopr
HostName wopr.example.com
IdentityFile ~/.ssh/id_wopr
User mward
@mattward
mattward / .bashrc
Last active March 19, 2019 15:03
Useful .bashrc bits and bobs
# My lovely PS1 prompt, e.g. "matt@ziggy:~$ "
# The prompt is green but my input is white. Works best on a black background.
# PS1 is a shell variable not an environment variable - do not export
PS1='\[\e[0;32m\]\u@\h:\W\$\[\e[m\] '
# Show your *public* ip address
alias myip='curl -s -S http://checkip.amazonaws.com'
# Copy your *public* ip address to the clipboard (Mac OS only)
alias myip-clip='echo -n $(myip) | pbcopy'