Add comments into each of the function files to make them easier to find

main
Kaleb Elwert 7 years ago
parent a70bce3ea6
commit 7d5beeab51

@ -6,6 +6,8 @@
# Matt Hamilton <m@tthamilton.com> # Matt Hamilton <m@tthamilton.com>
# #
# function archive {
local archive_name dir_to_archive _gzip_bin _bzip2_bin local archive_name dir_to_archive _gzip_bin _bzip2_bin
if (( $# != 2 )); then 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" ;; (*.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}" ;; (*) print "\nunknown archive type for archive: ${archive_name}" ;;
esac esac
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function lsarchive {
local verbose local verbose
if (( $# == 0 )); then if (( $# == 0 )); then
@ -53,3 +55,5 @@ while (( $# > 0 )); do
shift shift
done done
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function unarchive {
local remove_archive local remove_archive
local success local success
local file_name local file_name
@ -78,3 +80,5 @@ while (( $# > 0 )); do
(( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1"
shift shift
done done
# }

@ -6,6 +6,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function deb-clone {
local clone_script="${0}.sh" local clone_script="${0}.sh"
local package_list=$( local package_list=$(
perl \ perl \
@ -23,3 +25,5 @@ rm "$clone_script"
print '#!/bin/sh\n' > "$clone_script" print '#!/bin/sh\n' > "$clone_script"
print "aptitude install ${package_list}\n" >> "$clone_script" print "aptitude install ${package_list}\n" >> "$clone_script"
chmod +x "$clone_script" chmod +x "$clone_script"
# }

@ -7,6 +7,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function deb-history {
case "$1" in case "$1" in
(install) (install)
zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*) zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*)
@ -34,3 +36,5 @@ Commands:
EOF EOF
;; ;;
esac esac
# }

@ -6,9 +6,13 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function deb-kbuild {
make-kpkg clean make-kpkg clean
MAKEFLAGS='' time fakeroot make-kpkg \ MAKEFLAGS='' time fakeroot make-kpkg \
--append-to-version '-custom' \ --append-to-version '-custom' \
--revision "$(date +"%Y%m%d")" \ --revision "$(date +"%Y%m%d")" \
kernel_image \ kernel_image \
kernel_headers kernel_headers
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function git-branch-current {
if ! git rev-parse 2> /dev/null; then if ! git rev-parse 2> /dev/null; then
print "$0: not a repository: $PWD" >&2 print "$0: not a repository: $PWD" >&2
return 1 return 1
@ -18,3 +20,5 @@ if [[ -n "$ref" ]]; then
else else
return 1 return 1
fi fi
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function git-commit-lost {
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2 print "$0: not a repository work tree: $PWD" >&2
return 1 return 1
@ -18,3 +20,5 @@ git fsck 2> /dev/null \
--no-walk \ --no-walk \
--stdin \ --stdin \
--pretty=format:${_git_log_oneline_format} --pretty=format:${_git_log_oneline_format}
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function git-dir {
local git_dir="${$(git rev-parse --git-dir):A}" local git_dir="${$(git rev-parse --git-dir):A}"
if [[ -n "$git_dir" ]]; then if [[ -n "$git_dir" ]]; then
@ -14,3 +16,5 @@ else
print "$0: not a repository: $PWD" >&2 print "$0: not a repository: $PWD" >&2
return 1 return 1
fi fi
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function git-hub-browse {
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2 print "$0: not a repository work tree: $PWD" >&2
return 1 return 1
@ -56,3 +58,5 @@ else
print "$0: not a Git repository or remote not set" >&2 print "$0: not a Git repository or remote not set" >&2
return 1 return 1
fi fi
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function git-hub-shorten-url {
local url="$1" local url="$1"
if [[ "$url" == '-' ]]; then if [[ "$url" == '-' ]]; then
@ -20,3 +22,5 @@ if (( $+commands[curl] )); then
else else
print "$0: command not found: curl" >&2 print "$0: command not found: curl" >&2
fi fi
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function git-root {
local root="$(git rev-parse --show-toplevel 2> /dev/null)" local root="$(git rev-parse --show-toplevel 2> /dev/null)"
if [[ -n "$root" ]]; then if [[ -n "$root" ]]; then
@ -14,3 +16,5 @@ else
print "$0: not a repository work tree: $PWD" >&2 print "$0: not a repository work tree: $PWD" >&2
return 1 return 1
fi fi
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function git-stash-clear-interactive {
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2 print "$0: not a repository work tree: $PWD" >&2
return 1 return 1
@ -20,3 +22,5 @@ if [[ -f "$(git-dir)/refs/stash" ]]; then
fi fi
fi fi
fi fi
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function git-stash-dropped {
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2 print "$0: not a repository work tree: $PWD" >&2
return 1 return 1
@ -20,3 +22,5 @@ git fsck --unreachable 2> /dev/null \
--merges \ --merges \
--no-walk \ --no-walk \
--stdin --stdin
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function git-stash-recover {
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2 print "$0: not a repository work tree: $PWD" >&2
return 1 return 1
@ -16,3 +18,5 @@ for commit in "$@"; do
git update-ref \ git update-ref \
-m "$(git log -1 --pretty="format:%s" "$commit")" refs/stash "$commit" -m "$(git log -1 --pretty="format:%s" "$commit")" refs/stash "$commit"
done done
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function git-submodule-move {
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2 print "$0: not a repository work tree: $PWD" >&2
return 1 return 1
@ -30,3 +32,5 @@ git-submodule-remove "$src"
git submodule add "$url" "$dst" git submodule add "$url" "$dst"
return 0 return 0
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function git-submodule-remove {
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
print "$0: not a repository work tree: $PWD" >&2 print "$0: not a repository work tree: $PWD" >&2
return 1 return 1
@ -25,3 +27,5 @@ rm -rf "${1}"
rm -rf "$(git-dir)/modules/${1}" rm -rf "$(git-dir)/modules/${1}"
return 0 return 0
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function node-doc {
if [[ -z "$BROWSER" ]]; then if [[ -z "$BROWSER" ]]; then
print "$0: no web browser defined" >&2 print "$0: no web browser defined" >&2
return 1 return 1
@ -12,3 +14,5 @@ fi
# TODO: Make the sections easier to use. # TODO: Make the sections easier to use.
"$BROWSER" "http://nodejs.org/docs/$(node --version | sed 's/-.*//')/api/all.html#${1}" "$BROWSER" "http://nodejs.org/docs/$(node --version | sed 's/-.*//')/api/all.html#${1}"
# }

@ -6,6 +6,8 @@
# Zeh Rizzatti <zehrizzatti@gmail.com> # Zeh Rizzatti <zehrizzatti@gmail.com>
# #
# function node-info {
local version local version
local version_format local version_format
local version_formatted local version_formatted
@ -24,3 +26,5 @@ if [[ "$version" != (none|) ]]; then
zformat -f version_formatted "$version_format" "v:$version" zformat -f version_formatted "$version_format" "v:$version"
node_info[version]="$version_formatted" node_info[version]="$version_formatted"
fi fi
# }

@ -5,9 +5,13 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function osx-ls-download-history {
local db local db
for db in ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV*; do for db in ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV*; do
if grep -q 'LSQuarantineEvent' < <(sqlite3 "$db" .tables); then if grep -q 'LSQuarantineEvent' < <(sqlite3 "$db" .tables); then
sqlite3 "$db" 'SELECT LSQuarantineDataURLString FROM LSQuarantineEvent' sqlite3 "$db" 'SELECT LSQuarantineDataURLString FROM LSQuarantineEvent'
fi fi
done done
# }

@ -5,7 +5,11 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function osx-rm-dir-metadata {
find "${@:-$PWD}" \( \ find "${@:-$PWD}" \( \
-type f -name '.DS_Store' -o \ -type f -name '.DS_Store' -o \
-type d -name '__MACOSX' \ -type d -name '__MACOSX' \
\) -print0 | xargs -0 rm -rf \) -print0 | xargs -0 rm -rf
# }

@ -5,9 +5,13 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function osx-rm-download-history {
local db local db
for db in ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV*; do for db in ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV*; do
if grep -q 'LSQuarantineEvent' < <(sqlite3 "$db" .tables); then if grep -q 'LSQuarantineEvent' < <(sqlite3 "$db" .tables); then
sqlite3 "$db" 'DELETE FROM LSQuarantineEvent; VACUUM' sqlite3 "$db" 'DELETE FROM LSQuarantineEvent; VACUUM'
fi fi
done done
# }

@ -5,8 +5,12 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function pfd {
osascript 2>/dev/null <<EOF osascript 2>/dev/null <<EOF
tell application "Finder" tell application "Finder"
return POSIX path of (target of first window as text) return POSIX path of (target of first window as text)
end tell end tell
EOF EOF
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function pfs {
osascript 2>&1 <<EOF osascript 2>&1 <<EOF
tell application "Finder" to set the_selection to selection tell application "Finder" to set the_selection to selection
if the_selection is not {} if the_selection is not {}
@ -13,3 +15,5 @@ osascript 2>&1 <<EOF
end repeat end repeat
end if end if
EOF EOF
# }

@ -5,6 +5,10 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function ql {
if (( $# > 0 )); then if (( $# > 0 )); then
qlmanage -p "$@" &> /dev/null qlmanage -p "$@" &> /dev/null
fi fi
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function tab {
local command="cd \\\"$PWD\\\"" local command="cd \\\"$PWD\\\""
(( $# > 0 )) && command="${command}; $*" (( $# > 0 )) && command="${command}; $*"
@ -50,3 +52,5 @@ EOF
end tell end tell
EOF EOF
} }
# }

@ -6,6 +6,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function pacman-list-disowned {
local tmp="${TMPDIR:-/tmp}/pacman-disowned-$UID-$$" local tmp="${TMPDIR:-/tmp}/pacman-disowned-$UID-$$"
local db="$tmp/db" local db="$tmp/db"
local fs="$tmp/fs" local fs="$tmp/fs"
@ -20,3 +22,5 @@ find /bin /etc /lib /sbin /usr \
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs" \( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
comm -23 "$fs" "$db" comm -23 "$fs" "$db"
# }

@ -6,6 +6,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function pacman-list-explicit {
pacman --query --explicit --info \ pacman --query --explicit --info \
| awk ' | awk '
BEGIN { BEGIN {
@ -18,3 +20,5 @@ pacman --query --explicit --info \
print $2 print $2
} }
' '
# }

@ -6,6 +6,8 @@
# JINNOUCHI Yasushi <delphinus@remora.cx> # JINNOUCHI Yasushi <delphinus@remora.cx>
# #
# function perl-info {
local version local version
local version_format local version_format
local version_formatted local version_formatted
@ -28,3 +30,5 @@ if [[ -n "$version" ]]; then
zformat -f version_formatted "$version_format" "v:$version" zformat -f version_formatted "$version_format" "v:$version"
perl_info[version]="$version_formatted" perl_info[version]="$version_formatted"
fi fi
# }

@ -1,6 +1,8 @@
# prompt setup function common to many prompts # prompt setup function common to many prompts
# moved to external function to reduce code redundancy # moved to external function to reduce code redundancy
# function promptpwd {
setopt localoptions extendedglob setopt localoptions extendedglob
local current_pwd="${PWD/#$HOME/~}" local current_pwd="${PWD/#$HOME/~}"
@ -18,3 +20,5 @@ else
fi fi
print "$ret_directory" print "$ret_directory"
# }

@ -6,6 +6,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function python-info {
local virtualenv_format local virtualenv_format
local virtualenv_formatted local virtualenv_formatted
@ -19,3 +21,5 @@ if [[ -n "$VIRTUAL_ENV" ]]; then
zformat -f virtualenv_formatted "$virtualenv_format" "v:${VIRTUAL_ENV:t}" zformat -f virtualenv_formatted "$virtualenv_format" "v:${VIRTUAL_ENV:t}"
python_info[virtualenv]="$virtualenv_formatted" python_info[virtualenv]="$virtualenv_formatted"
fi fi
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function ruby-app-root {
local root_dir="$PWD" local root_dir="$PWD"
while [[ "$root_dir" != '/' ]]; do while [[ "$root_dir" != '/' ]]; do
@ -16,3 +18,5 @@ while [[ "$root_dir" != '/' ]]; do
done done
return 1 return 1
# }

@ -6,6 +6,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function ruby-info {
local version local version
local version_format local version_format
local version_formatted local version_formatted
@ -28,3 +30,5 @@ if [[ -n "$version" ]]; then
zformat -f version_formatted "$version_format" "v:$version" zformat -f version_formatted "$version_format" "v:$version"
ruby_info[version]="$version_formatted" ruby_info[version]="$version_formatted"
fi fi
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function prep {
local usage pattern modifiers invert local usage pattern modifiers invert
usage="$( usage="$(
@ -50,3 +52,5 @@ pattern="$1"
shift shift
perl -n -l -e "print if ${invert:+not} m/${pattern//\//\\/}/${modifiers}" "$@" perl -n -l -e "print if ${invert:+not} m/${pattern//\//\\/}/${modifiers}" "$@"
# }

@ -5,6 +5,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function psub {
local usage pattern replacement modifiers local usage pattern replacement modifiers
usage="$( usage="$(
@ -51,3 +53,5 @@ replacement="$2"
repeat 2 shift repeat 2 shift
perl -i'.orig' -n -l -e "s/${pattern//\//\\/}/${replacement//\//\\/}/${modifiers}; print" "$@" perl -i'.orig' -n -l -e "s/${pattern//\//\\/}/${replacement//\//\\/}/${modifiers}; print" "$@"
# }

@ -6,6 +6,8 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
# function wake {
local config_file="$HOME/.wakeonlan/$1" local config_file="$HOME/.wakeonlan/$1"
if [[ ! -s "$config_file" ]]; then if [[ ! -s "$config_file" ]]; then
print "$0: invalid device file: $1" >&2 print "$0: invalid device file: $1" >&2
@ -18,3 +20,5 @@ if (( ! $+commands[wakeonlan] )); then
fi fi
wakeonlan -f "$config_file" wakeonlan -f "$config_file"
# }

Loading…
Cancel
Save