Skip to content

Instantly share code, notes, and snippets.

@Gen2ly
Gen2ly / mp
Created June 22, 2012 20:07
Common makepkg building tasks
#!/bin/bash
# Common makepkg building tasks
mntr_info="Gen2ly <toddrpartridge@gmail.com>"
usage () {
echo " ${0##*/} <option> - common makepkg building tasks
b - build package (install dependencies if required)
m - update md5sums
r - remove previous build directories
@Gen2ly
Gen2ly / pm
Created June 18, 2012 14:32
References for common Arch Linux package management tasks
#!/bin/bash
# References for common Arch Linux package management tasks
# Required program(s)
req_progs=(pacaur)
for p in ${req_progs[@]}; do
hash "$p" 2>&- || \
{ echo >&2 " Required program \"$p\" not installed."; exit 1; }
done
@Gen2ly
Gen2ly / ghsync-gist
Created June 7, 2012 11:56
Create a github gist repository for sharing scripts/configs on blog
#!/bin/bash
# Create a github gist repository for sharing scripts/configs on blog
# Base directory, repository parent directory
base_dir=""$HOME"/"
repo_par=""$HOME"/.github-gist/"
# File list (File list order must match repository order)
files=('/home/todd/.scripts/others/ghsync-script'
'/home/todd/.scripts/vault/unity-effects'
@Gen2ly
Gen2ly / cb-out
Created June 7, 2012 10:59
Paste contents of Xorg clipboard to a file from the command line
#!/bin/bash
# Paste contents of Xorg clipboard to a file from the command line
filename=$@
pasteinfo="clipboard contents"
# Display usage if no parameters given
if [[ -z "$@" ]]; then
echo " ${0##*/} <filename> - paste contents of context-menu clipboard to file"
exit
@Gen2ly
Gen2ly / cb-in
Created June 7, 2012 10:59
Copy file or pipe to Xorg clipboard
#!/bin/bash
# Copy file or pipe to Xorg clipboard
# Required program(s)
req_progs=(xclip)
for p in ${req_progs[@]}; do
hash "$p" 2>&- || \
{ echo >&2 " Required program \"$p\" not installed."; exit 1; }
done
@Gen2ly
Gen2ly / bgcmd
Created June 7, 2012 02:55
Background a terminal command
#!/bin/bash
# Background a terminal command
# Add 'complete -cf bgcmd' to ~/.bashrc for command completion
nohup "$@" &> /dev/null &
@Gen2ly
Gen2ly / purge-memory
Created June 6, 2012 20:32
Free unused memory
#!/bin/bash
# Free unused memory
flush_mem () {
sudo sync
echo 3 | sudo tee /proc/sys/vm/drop_caches
}
echo -e "\nMemory usage before purge:\n" && free -m
@Gen2ly
Gen2ly / ff-restore
Created June 4, 2012 08:46
Create new profile and transfer settings (fixes certain
#!/bin/bash
# Create new profile and transfer settings (fixes certain
# problems when there are errors in Firefox settings).
ffsettingsdir=~/.mozilla/firefox/
# Setting files to restore (files to copy):
# (http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox)
files="content-prefs.sqlite
cookies.sqlite
formhistory.sqlite
@Gen2ly
Gen2ly / bckcfg
Created June 4, 2012 08:14
Backup configurations
#!/bin/bash
# Backup configurations
# Backup destination directory
#bckp_dest="/home/todd/Desktop"
bckp_dest="/run/media/todd/Backup/backup-configs"
# Backup name
comp="${HOSTNAME}" # Computer name
dist="arch" # Distro
@Gen2ly
Gen2ly / pack
Created June 3, 2012 02:36
Archive and compress file and folders
#!/bin/bash
# Archive and compress file and folders
# Display usage if no parameters given
if [[ -z "$@" ]]; then
#echo " ${0##*/} <file/dir> <*file/dir2> <*name>.tar.xz - archive file/folders"
echo " ${0##*/} <file/dir> <*file/dir2> - archive and compress files and dirs"
exit
fi