Skip to content

Instantly share code, notes, and snippets.

@Gen2ly
Gen2ly / md2wp
Created Jul 9, 2012
Convert Markdown to Wordpress blogging format
View md2wp
#!/bin/bash
# Convert Markdown to Wordpress blogging format
# Required program(s)
req_progs=(ascii2uni pandoc)
for p in ${req_progs[@]}; do
hash "$p" 2>&- || \
{ echo >&2 " Required program \"$p\" not installed."; exit 1; }
done
@Gen2ly
Gen2ly / cb-in
Created Jun 7, 2012
Copy file or pipe to Xorg clipboard
View cb-in
#!/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 / mp
Created Jun 22, 2012
Common makepkg building tasks
View mp
#!/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 / cb-out
Created Jun 7, 2012
Paste contents of Xorg clipboard to a file from the command line
View cb-out
#!/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 / externalmonitor
Created May 31, 2012
Toggle between laptop and external monitor
View externalmonitor
#!/bin/bash
# Toggle between laptop and external monitor
# Required program(s)
req_progs=(bc)
for p in ${req_progs[@]}; do
hash "$p" 2>&- || \
{ echo >&2 " Required program \"$p\" not installed."; exit 1; }
done
@Gen2ly
Gen2ly / vim2html
Created May 31, 2012
Create HTML code from Vim syntax highlighting (for use in coloring scripts)
View vim2html
#!/bin/bash
# Create HTML-colored code from Vim syntax highlighting
filename=$@
background=light
colorscheme=beauty256
#colorscheme=simple256
#colorscheme=peaksea
# Display usage if no parameters given
@Gen2ly
Gen2ly / memtop
Created Aug 2, 2012
Display the top application memory users
View memtop
#!/bin/bash
# Display the top applications of memory usage
# http://www.cyberciti.biz/faq/linux-check-memory-usage/#comment-51021
while read command percent rss; do
if [[ "${command}" != "COMMAND" ]]; then
rss="$(bc <<< "scale=2;${rss}/1024")"
fi
printf " %-26s%-8s%s\n" "${command}" "${percent}" "${rss} MB" \
| sed 's/COMMAND/PROGRAM/' | sed 's/RSS MB/#MEM/'
@Gen2ly
Gen2ly / bckfile
Created Dec 24, 2013
Backup files with sequential numbering and optional tag
View bckfile
#!/bin/sh
# Backup files with sequential numbering and optional tag
# Display usage if given the incorrect number of parameters
if [ $# -ne 2 -a $# -ne 3 ]; then
echo "${0##*/} [file] [dir] [*tag]- Backup files with sequential numbering, opt. tag"
exit 1; fi
# Test if first and second parameters are a file and a directory
if [ ! -e "$1" ]; then
View gt
#!/bin/bash
# Create temporary file(s) and open in gedit
# Program required: gedit test
hash gedit 2>&- || { echo " Program required \"gedit\" not installed"; exit 1; }
# Display usage
if [[ $1 == -h ]]; then
echo "gt [name*] [name*]... - create temporary file(s) and open in gedit"
exit 1; fi
@Gen2ly
Gen2ly / lnk
Created Jul 5, 2013
Link shortcut
View lnk
#!/bin/bash
# Link shortcut
# Display usage if incorrect number of parameters given
if [ $# != 2 ]; then
echo " ${0##*/} <source> <link> - ln shortcut"
exit 1; fi
# Source absolute path
if [ ! -e "$1" ]; then