@ -6,6 +6,8 @@
# Matt Hamilton <m@tthamilton.com>
#
# function archive {
local archive_name dir_to_archive _gzip_bin _bzip2_bin
if (( $# != 2 )); then
@ -65,3 +67,5 @@ case "${archive_name}" in
(*.lzma) print "\n.lzma is only useful for single files, and does not capture permissions. Use .tar.lzma" ;;
(*) print "\nunknown archive type for archive: ${archive_name}" ;;
esac
# }
@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
# function lsarchive {
local verbose
if (( $# == 0 )); then
@ -53,3 +55,5 @@ while (( $# > 0 )); do
shift
done
# function unarchive {
local remove_archive
local success
local file_name
@ -78,3 +80,5 @@ while (( $# > 0 )); do
(( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1"
# function deb-clone {
local clone_script="${0}.sh"
local package_list=$(
perl \
@ -23,3 +25,5 @@ rm "$clone_script"
print '#!/bin/sh\n' > "$clone_script"
print "aptitude install ${package_list}\n" >> "$clone_script"
chmod +x "$clone_script"
@ -7,6 +7,8 @@
# function deb-history {
case "$1" in
(install)
zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*)
@ -34,3 +36,5 @@ Commands:
EOF
;;
@ -6,9 +6,13 @@
# function deb-kbuild {
make-kpkg clean
MAKEFLAGS='' time fakeroot make-kpkg \
--append-to-version '-custom' \
--revision "$(date +"%Y%m%d")" \
kernel_image \
kernel_headers
# function git-branch-current {
if ! git rev-parse 2> /dev/null; then
print "$0: not a repository: $PWD" >&2
return 1
@ -18,3 +20,5 @@ if [[ -n "$ref" ]]; then
else
fi
# function git-commit-lost {
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2
@ -18,3 +20,5 @@ git fsck 2> /dev/null \
--no-walk \
--stdin \
--pretty=format:${_git_log_oneline_format}
# function git-dir {
local git_dir="${$(git rev-parse --git-dir):A}"
if [[ -n "$git_dir" ]]; then
@ -14,3 +16,5 @@ else
# function git-hub-browse {
@ -56,3 +58,5 @@ else
print "$0: not a Git repository or remote not set" >&2
# function git-hub-shorten-url {
local url="$1"
if [[ "$url" == '-' ]]; then
@ -20,3 +22,5 @@ if (( $+commands[curl] )); then
print "$0: command not found: curl" >&2
# function git-root {
local root="$(git rev-parse --show-toplevel 2> /dev/null)"
if [[ -n "$root" ]]; then
# function git-stash-clear-interactive {
@ -20,3 +22,5 @@ if [[ -f "$(git-dir)/refs/stash" ]]; then
# function git-stash-dropped {
@ -20,3 +22,5 @@ git fsck --unreachable 2> /dev/null \
--merges \
--stdin
# function git-stash-recover {
@ -16,3 +18,5 @@ for commit in "$@"; do
git update-ref \
-m "$(git log -1 --pretty="format:%s" "$commit")" refs/stash "$commit"
# function git-submodule-move {
@ -30,3 +32,5 @@ git-submodule-remove "$src"
git submodule add "$url" "$dst"
return 0
# function git-submodule-remove {
@ -25,3 +27,5 @@ rm -rf "${1}"
rm -rf "$(git-dir)/modules/${1}"
# function node-doc {
if [[ -z "$BROWSER" ]]; then
print "$0: no web browser defined" >&2
@ -12,3 +14,5 @@ fi
# TODO: Make the sections easier to use.
"$BROWSER" "http://nodejs.org/docs/$(node --version | sed 's/-.*//')/api/all.html#${1}"
# Zeh Rizzatti <zehrizzatti@gmail.com>
# function node-info {
local version
local version_format
local version_formatted
@ -24,3 +26,5 @@ if [[ "$version" != (none|) ]]; then
zformat -f version_formatted "$version_format" "v:$version"
node_info[version]="$version_formatted"
@ -5,9 +5,13 @@
# function osx-ls-download-history {
local db
for db in ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV*; do
if grep -q 'LSQuarantineEvent' < <(sqlite3 "$db" .tables); then
sqlite3 "$db" 'SELECT LSQuarantineDataURLString FROM LSQuarantineEvent'
@ -5,7 +5,11 @@
# function osx-rm-dir-metadata {
find "${@:-$PWD}" \( \
-type f -name '.DS_Store' -o \
-type d -name '__MACOSX' \
\) -print0 | xargs -0 rm -rf
# function osx-rm-download-history {
sqlite3 "$db" 'DELETE FROM LSQuarantineEvent; VACUUM'
@ -5,8 +5,12 @@
# function pfd {
osascript 2>/dev/null <<EOF
tell application "Finder"
return POSIX path of (target of first window as text)
end tell
# function pfs {
osascript 2>&1 <<EOF
tell application "Finder" to set the_selection to selection
if the_selection is not {}
@ -13,3 +15,5 @@ osascript 2>&1 <<EOF
end repeat
end if
@ -5,6 +5,10 @@
# function ql {
if (( $# > 0 )); then
qlmanage -p "$@" &> /dev/null
# function tab {
local command="cd \\\"$PWD\\\""
(( $# > 0 )) && command="${command}; $*"
@ -50,3 +52,5 @@ EOF
}
# function pacman-list-disowned {
local tmp="${TMPDIR:-/tmp}/pacman-disowned-$UID-$$"
local db="$tmp/db"
local fs="$tmp/fs"
@ -20,3 +22,5 @@ find /bin /etc /lib /sbin /usr \
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
comm -23 "$fs" "$db"
# function pacman-list-explicit {
pacman --query --explicit --info \
| awk '
BEGIN {
@ -18,3 +20,5 @@ pacman --query --explicit --info \
print $2
'
# JINNOUCHI Yasushi <delphinus@remora.cx>
# function perl-info {
@ -28,3 +30,5 @@ if [[ -n "$version" ]]; then
perl_info[version]="$version_formatted"
@ -1,6 +1,8 @@
# prompt setup function common to many prompts
# moved to external function to reduce code redundancy
# function promptpwd {
setopt localoptions extendedglob
local current_pwd="${PWD/#$HOME/~}"
@ -18,3 +20,5 @@ else
print "$ret_directory"
# function python-info {
local virtualenv_format
local virtualenv_formatted
@ -19,3 +21,5 @@ if [[ -n "$VIRTUAL_ENV" ]]; then
zformat -f virtualenv_formatted "$virtualenv_format" "v:${VIRTUAL_ENV:t}"
python_info[virtualenv]="$virtualenv_formatted"
# function ruby-app-root {
local root_dir="$PWD"
while [[ "$root_dir" != '/' ]]; do
@ -16,3 +18,5 @@ while [[ "$root_dir" != '/' ]]; do
# function ruby-info {
ruby_info[version]="$version_formatted"
# function prep {
local usage pattern modifiers invert
usage="$(
@ -50,3 +52,5 @@ pattern="$1"
perl -n -l -e "print if ${invert:+not} m/${pattern//\//\\/}/${modifiers}" "$@"
# function psub {
local usage pattern replacement modifiers
@ -51,3 +53,5 @@ replacement="$2"
repeat 2 shift
perl -i'.orig' -n -l -e "s/${pattern//\//\\/}/${replacement//\//\\/}/${modifiers}; print" "$@"
# function wake {
local config_file="$HOME/.wakeonlan/$1"
if [[ ! -s "$config_file" ]]; then
print "$0: invalid device file: $1" >&2
@ -18,3 +20,5 @@ if (( ! $+commands[wakeonlan] )); then
wakeonlan -f "$config_file"