Skip to content

Instantly share code, notes, and snippets.

@CharlieHawker
Created August 3, 2016 09:25
Show Gist options
  • Save CharlieHawker/3d27ace8e8b1c5359c3141d8db33dc2d to your computer and use it in GitHub Desktop.
Save CharlieHawker/3d27ace8e8b1c5359c3141d8db33dc2d to your computer and use it in GitHub Desktop.
Useful bash aliases
# Export variables from a .env file
alias setup_env_vars='export $(cat .env | xargs)'
# Display human-readable subdirectory sizes
alias subdirsizes="ls -AF | grep \/ | sed 's/\ /\\\ /g' | xargs du -sh"
# Heroku - Restore postgres backup to given database name
herokuPgBackupRestore() {
dbname=${1?param missing - database name}
heroku pg:backups capture
curl -o latest.dump `heroku pg:backups public-url`
pg_restore --no-acl --no-owner --clean -U postgres --dbname $dbname latest.dump
rm latest.dump
}
alias restore_heroku_backup=herokuPgBackupRestore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment