From 7d5beeab51627de9b68fb13b0359438da32dd6ac Mon Sep 17 00:00:00 2001 From: Kaleb Elwert Date: Thu, 6 Jul 2017 16:01:26 -0700 Subject: [PATCH] Add comments into each of the function files to make them easier to find --- modules/archive/functions/archive | 4 ++++ modules/archive/functions/lsarchive | 4 ++++ modules/archive/functions/unarchive | 4 ++++ modules/dpkg/functions/deb-clone | 4 ++++ modules/dpkg/functions/deb-history | 4 ++++ modules/dpkg/functions/deb-kbuild | 4 ++++ modules/git/functions/git-branch-current | 4 ++++ modules/git/functions/git-commit-lost | 4 ++++ modules/git/functions/git-dir | 4 ++++ modules/git/functions/git-hub-browse | 4 ++++ modules/git/functions/git-hub-shorten-url | 4 ++++ modules/git/functions/git-root | 4 ++++ modules/git/functions/git-stash-clear-interactive | 4 ++++ modules/git/functions/git-stash-dropped | 4 ++++ modules/git/functions/git-stash-recover | 4 ++++ modules/git/functions/git-submodule-move | 4 ++++ modules/git/functions/git-submodule-remove | 4 ++++ modules/node/functions/node-doc | 4 ++++ modules/node/functions/node-info | 4 ++++ modules/osx/functions/osx-ls-download-history | 4 ++++ modules/osx/functions/osx-rm-dir-metadata | 4 ++++ modules/osx/functions/osx-rm-download-history | 4 ++++ modules/osx/functions/pfd | 4 ++++ modules/osx/functions/pfs | 4 ++++ modules/osx/functions/ql | 4 ++++ modules/osx/functions/tab | 4 ++++ modules/pacman/functions/pacman-list-disowned | 4 ++++ modules/pacman/functions/pacman-list-explicit | 4 ++++ modules/perl/functions/perl-info | 4 ++++ modules/prompt/functions/promptpwd | 4 ++++ modules/python/functions/python-info | 4 ++++ modules/ruby/functions/ruby-app-root | 4 ++++ modules/ruby/functions/ruby-info | 4 ++++ modules/utility/functions/prep | 4 ++++ modules/utility/functions/psub | 4 ++++ modules/wakeonlan/functions/wake | 4 ++++ 36 files changed, 144 insertions(+) diff --git a/modules/archive/functions/archive b/modules/archive/functions/archive index ab0d56d..0e3bb61 100644 --- a/modules/archive/functions/archive +++ b/modules/archive/functions/archive @@ -6,6 +6,8 @@ # Matt Hamilton # +# 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 + +# } diff --git a/modules/archive/functions/lsarchive b/modules/archive/functions/lsarchive index 6b1b321..d2bd834 100644 --- a/modules/archive/functions/lsarchive +++ b/modules/archive/functions/lsarchive @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function lsarchive { + local verbose if (( $# == 0 )); then @@ -53,3 +55,5 @@ while (( $# > 0 )); do shift done + +# } diff --git a/modules/archive/functions/unarchive b/modules/archive/functions/unarchive index fac77ff..c9ed148 100644 --- a/modules/archive/functions/unarchive +++ b/modules/archive/functions/unarchive @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function unarchive { + local remove_archive local success local file_name @@ -78,3 +80,5 @@ while (( $# > 0 )); do (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" shift done + +# } diff --git a/modules/dpkg/functions/deb-clone b/modules/dpkg/functions/deb-clone index a284c96..a767bd3 100644 --- a/modules/dpkg/functions/deb-clone +++ b/modules/dpkg/functions/deb-clone @@ -6,6 +6,8 @@ # Sorin Ionescu # +# 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" + +# } diff --git a/modules/dpkg/functions/deb-history b/modules/dpkg/functions/deb-history index 3737679..a1369de 100644 --- a/modules/dpkg/functions/deb-history +++ b/modules/dpkg/functions/deb-history @@ -7,6 +7,8 @@ # Sorin Ionescu # +# function deb-history { + case "$1" in (install) zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*) @@ -34,3 +36,5 @@ Commands: EOF ;; esac + +# } diff --git a/modules/dpkg/functions/deb-kbuild b/modules/dpkg/functions/deb-kbuild index bdf7801..a84a9b6 100644 --- a/modules/dpkg/functions/deb-kbuild +++ b/modules/dpkg/functions/deb-kbuild @@ -6,9 +6,13 @@ # Sorin Ionescu # +# function deb-kbuild { + make-kpkg clean MAKEFLAGS='' time fakeroot make-kpkg \ --append-to-version '-custom' \ --revision "$(date +"%Y%m%d")" \ kernel_image \ kernel_headers + +# } diff --git a/modules/git/functions/git-branch-current b/modules/git/functions/git-branch-current index 944ffe2..cadb6f6 100644 --- a/modules/git/functions/git-branch-current +++ b/modules/git/functions/git-branch-current @@ -5,6 +5,8 @@ # Sorin Ionescu # +# 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 return 1 fi + +# } diff --git a/modules/git/functions/git-commit-lost b/modules/git/functions/git-commit-lost index 75ab571..62789ac 100644 --- a/modules/git/functions/git-commit-lost +++ b/modules/git/functions/git-commit-lost @@ -5,6 +5,8 @@ # Sorin Ionescu # +# 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 return 1 @@ -18,3 +20,5 @@ git fsck 2> /dev/null \ --no-walk \ --stdin \ --pretty=format:${_git_log_oneline_format} + +# } diff --git a/modules/git/functions/git-dir b/modules/git/functions/git-dir index 7e16ca8..fdb515c 100644 --- a/modules/git/functions/git-dir +++ b/modules/git/functions/git-dir @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function git-dir { + local git_dir="${$(git rev-parse --git-dir):A}" if [[ -n "$git_dir" ]]; then @@ -14,3 +16,5 @@ else print "$0: not a repository: $PWD" >&2 return 1 fi + +# } diff --git a/modules/git/functions/git-hub-browse b/modules/git/functions/git-hub-browse index 549a544..4e7c314 100644 --- a/modules/git/functions/git-hub-browse +++ b/modules/git/functions/git-hub-browse @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function git-hub-browse { + if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 @@ -56,3 +58,5 @@ else print "$0: not a Git repository or remote not set" >&2 return 1 fi + +# } diff --git a/modules/git/functions/git-hub-shorten-url b/modules/git/functions/git-hub-shorten-url index d37b04e..78f2d7b 100644 --- a/modules/git/functions/git-hub-shorten-url +++ b/modules/git/functions/git-hub-shorten-url @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function git-hub-shorten-url { + local url="$1" if [[ "$url" == '-' ]]; then @@ -20,3 +22,5 @@ if (( $+commands[curl] )); then else print "$0: command not found: curl" >&2 fi + +# } diff --git a/modules/git/functions/git-root b/modules/git/functions/git-root index 712e4fe..f749457 100644 --- a/modules/git/functions/git-root +++ b/modules/git/functions/git-root @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function git-root { + local root="$(git rev-parse --show-toplevel 2> /dev/null)" if [[ -n "$root" ]]; then @@ -14,3 +16,5 @@ else print "$0: not a repository work tree: $PWD" >&2 return 1 fi + +# } diff --git a/modules/git/functions/git-stash-clear-interactive b/modules/git/functions/git-stash-clear-interactive index e45165c..71468aa 100644 --- a/modules/git/functions/git-stash-clear-interactive +++ b/modules/git/functions/git-stash-clear-interactive @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function git-stash-clear-interactive { + if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 @@ -20,3 +22,5 @@ if [[ -f "$(git-dir)/refs/stash" ]]; then fi fi fi + +# } diff --git a/modules/git/functions/git-stash-dropped b/modules/git/functions/git-stash-dropped index 5158070..2a0b7a9 100644 --- a/modules/git/functions/git-stash-dropped +++ b/modules/git/functions/git-stash-dropped @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function git-stash-dropped { + if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 @@ -20,3 +22,5 @@ git fsck --unreachable 2> /dev/null \ --merges \ --no-walk \ --stdin + +# } diff --git a/modules/git/functions/git-stash-recover b/modules/git/functions/git-stash-recover index 6add26f..5cc949a 100644 --- a/modules/git/functions/git-stash-recover +++ b/modules/git/functions/git-stash-recover @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function git-stash-recover { + if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 @@ -16,3 +18,5 @@ for commit in "$@"; do git update-ref \ -m "$(git log -1 --pretty="format:%s" "$commit")" refs/stash "$commit" done + +# } diff --git a/modules/git/functions/git-submodule-move b/modules/git/functions/git-submodule-move index 34c5e44..ec6048e 100644 --- a/modules/git/functions/git-submodule-move +++ b/modules/git/functions/git-submodule-move @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function git-submodule-move { + if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 @@ -30,3 +32,5 @@ git-submodule-remove "$src" git submodule add "$url" "$dst" return 0 + +# } diff --git a/modules/git/functions/git-submodule-remove b/modules/git/functions/git-submodule-remove index 852b9cd..2490e78 100644 --- a/modules/git/functions/git-submodule-remove +++ b/modules/git/functions/git-submodule-remove @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function git-submodule-remove { + if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then print "$0: not a repository work tree: $PWD" >&2 return 1 @@ -25,3 +27,5 @@ rm -rf "${1}" rm -rf "$(git-dir)/modules/${1}" return 0 + +# } diff --git a/modules/node/functions/node-doc b/modules/node/functions/node-doc index 24f5641..b1a048b 100644 --- a/modules/node/functions/node-doc +++ b/modules/node/functions/node-doc @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function node-doc { + if [[ -z "$BROWSER" ]]; then print "$0: no web browser defined" >&2 return 1 @@ -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}" + +# } diff --git a/modules/node/functions/node-info b/modules/node/functions/node-info index e4cd52d..22ac31b 100644 --- a/modules/node/functions/node-info +++ b/modules/node/functions/node-info @@ -6,6 +6,8 @@ # Zeh Rizzatti # +# 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" fi + +# } diff --git a/modules/osx/functions/osx-ls-download-history b/modules/osx/functions/osx-ls-download-history index 5727c1b..ba6a40c 100644 --- a/modules/osx/functions/osx-ls-download-history +++ b/modules/osx/functions/osx-ls-download-history @@ -5,9 +5,13 @@ # Sorin Ionescu # +# 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' fi done + +# } diff --git a/modules/osx/functions/osx-rm-dir-metadata b/modules/osx/functions/osx-rm-dir-metadata index 0a91ced..f15f4ed 100644 --- a/modules/osx/functions/osx-rm-dir-metadata +++ b/modules/osx/functions/osx-rm-dir-metadata @@ -5,7 +5,11 @@ # Sorin Ionescu # +# function osx-rm-dir-metadata { + find "${@:-$PWD}" \( \ -type f -name '.DS_Store' -o \ -type d -name '__MACOSX' \ \) -print0 | xargs -0 rm -rf + +# } diff --git a/modules/osx/functions/osx-rm-download-history b/modules/osx/functions/osx-rm-download-history index 3837709..c6a368c 100644 --- a/modules/osx/functions/osx-rm-download-history +++ b/modules/osx/functions/osx-rm-download-history @@ -5,9 +5,13 @@ # Sorin Ionescu # +# function osx-rm-download-history { + local db for db in ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV*; do if grep -q 'LSQuarantineEvent' < <(sqlite3 "$db" .tables); then sqlite3 "$db" 'DELETE FROM LSQuarantineEvent; VACUUM' fi done + +# } diff --git a/modules/osx/functions/pfd b/modules/osx/functions/pfd index a4d4b68..4153769 100644 --- a/modules/osx/functions/pfd +++ b/modules/osx/functions/pfd @@ -5,8 +5,12 @@ # Sorin Ionescu # +# function pfd { + osascript 2>/dev/null < # +# function pfs { + osascript 2>&1 <&1 < # +# function ql { + if (( $# > 0 )); then qlmanage -p "$@" &> /dev/null fi + +# } diff --git a/modules/osx/functions/tab b/modules/osx/functions/tab index e0f2dc2..114c92e 100644 --- a/modules/osx/functions/tab +++ b/modules/osx/functions/tab @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function tab { + local command="cd \\\"$PWD\\\"" (( $# > 0 )) && command="${command}; $*" @@ -50,3 +52,5 @@ EOF end tell EOF } + +# } diff --git a/modules/pacman/functions/pacman-list-disowned b/modules/pacman/functions/pacman-list-disowned index a097c9d..9c8f56a 100644 --- a/modules/pacman/functions/pacman-list-disowned +++ b/modules/pacman/functions/pacman-list-disowned @@ -6,6 +6,8 @@ # Sorin Ionescu # +# 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" + +# } diff --git a/modules/pacman/functions/pacman-list-explicit b/modules/pacman/functions/pacman-list-explicit index 2967834..7c9b08f 100644 --- a/modules/pacman/functions/pacman-list-explicit +++ b/modules/pacman/functions/pacman-list-explicit @@ -6,6 +6,8 @@ # Sorin Ionescu # +# function pacman-list-explicit { + pacman --query --explicit --info \ | awk ' BEGIN { @@ -18,3 +20,5 @@ pacman --query --explicit --info \ print $2 } ' + +# } diff --git a/modules/perl/functions/perl-info b/modules/perl/functions/perl-info index 2c396ea..b42e23d 100644 --- a/modules/perl/functions/perl-info +++ b/modules/perl/functions/perl-info @@ -6,6 +6,8 @@ # JINNOUCHI Yasushi # +# function perl-info { + local version local version_format local version_formatted @@ -28,3 +30,5 @@ if [[ -n "$version" ]]; then zformat -f version_formatted "$version_format" "v:$version" perl_info[version]="$version_formatted" fi + +# } diff --git a/modules/prompt/functions/promptpwd b/modules/prompt/functions/promptpwd index d7659f9..bf6e227 100644 --- a/modules/prompt/functions/promptpwd +++ b/modules/prompt/functions/promptpwd @@ -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 fi print "$ret_directory" + +# } diff --git a/modules/python/functions/python-info b/modules/python/functions/python-info index 6a8c758..a616814 100644 --- a/modules/python/functions/python-info +++ b/modules/python/functions/python-info @@ -6,6 +6,8 @@ # Sorin Ionescu # +# 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" fi + +# } diff --git a/modules/ruby/functions/ruby-app-root b/modules/ruby/functions/ruby-app-root index ea35be6..ef28c5b 100644 --- a/modules/ruby/functions/ruby-app-root +++ b/modules/ruby/functions/ruby-app-root @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function ruby-app-root { + local root_dir="$PWD" while [[ "$root_dir" != '/' ]]; do @@ -16,3 +18,5 @@ while [[ "$root_dir" != '/' ]]; do done return 1 + +# } diff --git a/modules/ruby/functions/ruby-info b/modules/ruby/functions/ruby-info index ebf0f7f..d53435b 100644 --- a/modules/ruby/functions/ruby-info +++ b/modules/ruby/functions/ruby-info @@ -6,6 +6,8 @@ # Sorin Ionescu # +# function ruby-info { + local version local version_format local version_formatted @@ -28,3 +30,5 @@ if [[ -n "$version" ]]; then zformat -f version_formatted "$version_format" "v:$version" ruby_info[version]="$version_formatted" fi + +# } diff --git a/modules/utility/functions/prep b/modules/utility/functions/prep index 23028ec..d6448ae 100644 --- a/modules/utility/functions/prep +++ b/modules/utility/functions/prep @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function prep { + local usage pattern modifiers invert usage="$( @@ -50,3 +52,5 @@ pattern="$1" shift perl -n -l -e "print if ${invert:+not} m/${pattern//\//\\/}/${modifiers}" "$@" + +# } diff --git a/modules/utility/functions/psub b/modules/utility/functions/psub index ffc0108..af191fd 100644 --- a/modules/utility/functions/psub +++ b/modules/utility/functions/psub @@ -5,6 +5,8 @@ # Sorin Ionescu # +# function psub { + local usage pattern replacement modifiers usage="$( @@ -51,3 +53,5 @@ replacement="$2" repeat 2 shift perl -i'.orig' -n -l -e "s/${pattern//\//\\/}/${replacement//\//\\/}/${modifiers}; print" "$@" + +# } diff --git a/modules/wakeonlan/functions/wake b/modules/wakeonlan/functions/wake index 5259c95..6f7d6c5 100644 --- a/modules/wakeonlan/functions/wake +++ b/modules/wakeonlan/functions/wake @@ -6,6 +6,8 @@ # Sorin Ionescu # +# 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 fi wakeonlan -f "$config_file" + +# }