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 ab0d56da..0e3bb616 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 6b1b321a..d2bd8341 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 fac77ff6..c9ed1488 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 a284c96f..a767bd32 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 37376790..a1369dea 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 bdf7801e..a84a9b6d 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 944ffe25..cadb6f63 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 75ab5716..62789ac9 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 7e16ca81..fdb515c5 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 549a544a..4e7c314e 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 d37b04eb..78f2d7ba 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 712e4fe6..f7494572 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 e45165c4..71468aa0 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 51580703..2a0b7a94 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 6add26fd..5cc949a7 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 34c5e44a..ec6048e6 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 852b9cdb..2490e78c 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 24f56414..b1a048bd 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 e4cd52d0..22ac31bd 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 5727c1b3..ba6a40c7 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 0a91cedb..f15f4ed6 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 38377098..c6a368ca 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 a4d4b686..41537698 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 e0f2dc24..114c92ee 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 a097c9db..9c8f56a0 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 2967834f..7c9b08f3 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 2c396ea5..b42e23d7 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 d7659f9c..bf6e227d 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 6a8c7589..a616814c 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 ea35be60..ef28c5b0 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 ebf0f7fe..d53435b4 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 23028ec4..d6448aeb 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 ffc01088..af191fde 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 5259c95b..6f7d6c5a 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" + +# }