#!/usr/bin/env bash
-# For generic functions.
+cite about-plugin
+about-plugin generic and miscellaneous tools
ips ()
{
about display all ip addresses for this host
+ group base
ifconfig | grep "inet " | awk '{ print $2 }'
}
about checks whether a website is down for you, or everybody
param 1: website url
example '$ down4me http://www.google.com'
+ group base
curl -s "http://www.downforeveryoneorjustme.com/$1" | sed '/just you/!d;s/<[^>]*>//g'
}
myip ()
{
about displays your ip address, as seen by the Internet
+ group base
res=$(curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+')
echo -e "Your public IP is: ${echo_bold_green} $res ${echo_normal}"
}
about picks random line from file
param 1: filename
example '$ pickfrom /usr/share/dict/words'
+ group base
local file=$1
[ -z "$file" ] && reference $FUNCNAME && return
length=$(cat $file | wc -l)
param if unset, defaults to 4
example '$ pass'
example '$ pass 6'
+ group base
local i pass length=${1:-4}
pass=$(echo $(for i in $(eval echo "{1..$length}"); do pickfrom /usr/share/dict/words; done))
echo "With spaces (easier to memorize): $pass"
about preview markdown file in a browser
param 1: markdown file
example '$ pmdown README.md'
+ group base
if command -v markdown &>/dev/null
then
markdown $1 | browser
param path to create
example '$ mkcd foo'
example '$ mkcd /tmp/img/photos/large'
+ group base
mkdir -p "$*"
cd "$*"
}
lsgrep ()
{
about search through directory contents with grep
+ group base
ls | grep "$*"
}
about view man documentation in Preview
param 1: man page to view
example '$ pman bash'
+ group base
man -t "${1}" | open -f -a $PREVIEW
}
about download file and Preview it
param 1: download URL
example '$ pcurl http://www.irs.gov/pub/irs-pdf/fw4.pdf'
+ group base
curl "${1}" | open -f -a $PREVIEW
}
about display information about Ruby classes, modules, or methods, in Preview
param 1: Ruby method, module, or class
example '$ pri Array'
+ group base
ri -T "${1}" | open -f -a $PREVIEW
}
quiet ()
{
+ about 'what *does* this do?'
+ group base
$* &> /dev/null &
}
banish-cookies ()
{
about redirect .adobe and .macromedia files to /dev/null
+ group base
rm -r ~/.macromedia ~/.adobe
ln -s /dev/null ~/.adobe
ln -s /dev/null ~/.macromedia
{
about disk usage per directory, in Mac OS X and Linux
param 1: directory name
+ group base
if [ $(uname) = "Darwin" ]; then
if [ -n $1 ]; then
du -hd $1
about one thing todo
param if not set, display todo item
param 1: todo text
+ group base
if [[ "$*" == "" ]] ; then
cat ~/.t
else
about checks for existence of a command
param 1: command to check
example '$ command_exists ls && echo exists'
+ group base
type "$1" &> /dev/null ;
}
plugins-help ()
{
about list all plugins and functions defined by bash-it
- echo "bash-it Plugins Help-Message"
- echo
-
- set | grep "()" \
- | sed -e "/^_/d" | grep -v "BASH_ARGC=()" \
- | sed -e "/^\s/d" | grep -v "BASH_LINENO=()" \
- | grep -v "BASH_ARGV=()" \
- | grep -v "BASH_SOURCE=()" \
- | grep -v "DIRSTACK=()" \
- | grep -v "GROUPS=()" \
- | grep -v "BASH_CMDS=()" \
- | grep -v "BASH_ALIASES=()" \
- | grep -v "COMPREPLY=()" | sed -e "s/()//"
+ group base
+ printf '%s\n' "bash-it plugins help"
+ printf '\n'
+ typeset group
+ for group in $(all_groups)
+ do
+ printf '%s\n' "group: $group"
+ glossary $group
+ printf '\n'
+ done
}
# useful for administrators and configs
{
about back up file with timestamp
param filename
+ group base
local filename=$1
local filetime=$(date +%Y%m%d_%H%M%S)
cp ${filename} ${filename}_${filetime}
}
+
+all_groups ()
+{
+ about displays all unique metadata groups
+ group base
+ typeset func
+ typeset file=$(mktemp /tmp/composure.XXXX)
+ for func in $(typeset_functions)
+ do
+ typeset -f $func | metafor group >> $file
+ done
+ cat $file | sort | uniq
+ rm $file
+}