From 26ffc95f66633e04e63ddce54c6161c5ce80b6b7 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Thu, 7 May 2020 09:37:50 +1200 Subject: [PATCH 1/1] clean up functions no longer used --- .zsh/func/gitpub | 35 -------------------- .zsh/func/giturl | 79 --------------------------------------------- .zsh/func/idiotheke | 32 ------------------ .zsh/func/p | 25 -------------- .zsh/func/svngit | 51 ----------------------------- .zsh/func/urlencode | 16 --------- 6 files changed, 238 deletions(-) delete mode 100644 .zsh/func/gitpub delete mode 100644 .zsh/func/giturl delete mode 100755 .zsh/func/idiotheke delete mode 100644 .zsh/func/p delete mode 100644 .zsh/func/svngit delete mode 100644 .zsh/func/urlencode diff --git a/.zsh/func/gitpub b/.zsh/func/gitpub deleted file mode 100644 index d29230d..0000000 --- a/.zsh/func/gitpub +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# -# func/gitpub -# -# a convenient way to publicise a Git repository -# -# Copyright © 2008–2009 martin f. krafft -# Released under the terms of the Artistic Licence 2.0 -# -# Source repository: http://git.madduck.net/v/etc/zsh.git -# - -local oldpwd gitdir dest description tmpdir -oldpwd="$PWD" -gitdir="$(git rev-parse --git-dir)" -dest="$1"; shift -description="$@" -tmpdir="$(mktemp -d ${0##*/}.XXXXXX)" -trap "rm -rf $PWD/$tmpdir" EXIT - -cp -lr "$gitdir" "$tmpdir/gitdir" - -builtin cd "$tmpdir/gitdir" - -chmod -R a+rX . - -git config core.bare true -git config core.sharedrepository 2 -git config receive.denyNonFastforwards true - -echo "$description" >| description - -cd "$oldpwd" - -scp -r "$tmpdir/gitdir" "$dest" diff --git a/.zsh/func/giturl b/.zsh/func/giturl deleted file mode 100644 index 5f29ac0..0000000 --- a/.zsh/func/giturl +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/sh -# -# func/giturl -# -# A convenient way to display the gitweb URL of a commit-ish, as well as the -# base URL and tree. Also for each argument, the tree or blob URL is printed. -# -# Copyright © 2010 martin f. krafft -# Released under the terms of the Artistic Licence 2.0 -# Contributions from Yaroslav O. Halchenko -# -# Source repository: http://git.madduck.net/v/etc/zsh.git -# - -local branch remote remote_name -branch=$(git symbolic-ref -q HEAD); branch="${branch#refs/heads/}" -# Obtain remote which current branch tracks, origin if not known -remote_name=$(git config branch.$branch.remote || echo origin) -remote=$(git config --get remote.$remote_name.url) - -local part gitweb_base style commitkw -style=gitweb -commitkw=commitdiff # keyword for commit -- differ for github -argssep=: # separator for arguments of the query -case "$remote" in - madduck:pub/*|ssh://git.madduck.net/madduck/pub/*) - gitweb_base=http://git.madduck.net/v - part="${remote#madduck:pub/}" - part="${part#ssh://git.madduck.net/madduck/pub/}" - part="${part%.git}.git" - ;; - debian:*|*://git.debian.org/git/*|*://alioth.debian.org/git/*|*@git.debian.org/git/*) - gitweb_base=http://git.debian.org - part="${remote#debian:}" - part="${part#*://git.debian.org/git/}" - part="${part#*://alioth.debian.org/git/}" - part="${part#*@git.debian.org/git/}" - part="${part%.git}.git" - style=gitweb_old - ;; - github:*|*://github.com/*|*@github.com[/:]*) - gitweb_base=http://github.com - part="${remote#github:}" - part="${part#*://github.com/}" - part="${part#*@github.com[:/]}" - part="${part%.git}" - style=github - commitkw=commit - argssep= - ;; - *) - echo >&2 "E: I do not know how to translate $remote into a gitweb URL." - return 1 - ;; -esac - -local hash -hash=$(git rev-parse HEAD) - -case "$style" in - gitweb|github) - echo "$gitweb_base/$part" - echo "$gitweb_base/$part/$commitkw/$hash" - echo "$gitweb_base/$part/tree/HEAD" - for i in $@; do - [ -f "$i" ] && echo "$gitweb_base/$part/blob/HEAD${argssep}/$i" - [ -d "$i" ] && echo "$gitweb_base/$part/tree/HEAD${argssep}/$i" - done - ;; - gitweb_old) - echo "$gitweb_base/?p=$part" - echo "$gitweb_base/?p=$part;a=commitdiff;h=$hash" - echo "$gitweb_base/?p=$part;a=tree;h=HEAD" - for i in $@; do - [ -f "$i" ] && echo "$gitweb_base/?p=$part;a=blob;hb=HEAD;f=$i" - [ -d "$i" ] && echo "$gitweb_base/?p=$part;a=tree;hb=HEAD;f=$i" - done - ;; -esac diff --git a/.zsh/func/idiotheke b/.zsh/func/idiotheke deleted file mode 100755 index 5a0d5d6..0000000 --- a/.zsh/func/idiotheke +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -set -u - -if [ -n "${ZSH_VERSION:-}" ]; then - # don't execute trap on return from functions - setopt local_options posix_traps no_warn_create_global -fi - -RESOURCE=idiotheke.de -PASSWORD="$(pass $RESOURCE)" -LOGIN="$(echo "$PASSWORD" | sed -rne 's/login: //p')" -URL="$(echo "$PASSWORD" | sed -rne 's/url: //p')" -PASSWORD="${PASSWORD%% -*}" #first line only - -if [ -n "${1:-}" ]; then - ASKPASS="$(tempfile --prefix=askpass --mode=700)" - cleanup() { rm -f $ASKPASS; trap - 0; } - trap cleanup 0 - - echo '#!/bin/sh' >> $ASKPASS - echo "echo ${LOGIN}:${PASSWORD}" >> $ASKPASS - - wget --continue --use-askpass="$ASKPASS" "$@" - - cleanup - ! command -v unfunction >/dev/null || unfunction cleanup -else - LFTP_PASSWORD="$PASSWORD" lftp -e "open -u $LOGIN --env-password $URL" -fi - -unset RESOURCE LOGIN PASSWORD URL ASKPASS diff --git a/.zsh/func/p b/.zsh/func/p deleted file mode 100644 index 7a646df..0000000 --- a/.zsh/func/p +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/zsh -# -# func/p -# -# function to publish to a pastebin (using pastebinit) -# -# Copyright © 1994–2017 martin f. krafft -# Released under the terms of the Artistic Licence 2.0 -# -# Source repository: http://git.madduck.net/v/etc/zsh.git -# - -if [[ $# -gt 1 ]]; then - echo E: only one argument can be passed. >&2 - exit 1 -fi - -PERMATAG=$USER -PB=http://slexy.org -PBIT="pastebinit -b $PB -a $USER" - -FILE=- -[[ -n "$1" ]] && FILE="$1" - -eval $PBIT -i $FILE | sed -e s@/view/@/raw/@ diff --git a/.zsh/func/svngit b/.zsh/func/svngit deleted file mode 100644 index debbf53..0000000 --- a/.zsh/func/svngit +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# -# func/svngit -# -# one-time conversion of SVN repositories to Git repositories -# -# Copyright © 2006–2009 martin f. krafft -# Released under the terms of the Artistic Licence 2.0 -# -# Source repository: http://git.madduck.net/v/etc/zsh.git -# - -local svnrepo dest args -args=() - -for arg in "$@"; do - case "$arg" in - (svn+*|svn://|http://) - if [[ -z $svnrepo ]]; then - svnrepo="$arg" - else - echo "E: SVN repository multiply defined." >&2 - exit 1 - fi - ;; - (*) - if [[ -e $dest ]]; then - if [[ -d $dest ]] && [[ -z $svnrepo ]] && svn info $svnrepo >/dev/null 2>&1; then - svnrepo="$arg" - else - echo "E: destination $dest already exists." >&2 - exit 1 - fi - fi - if [[ -z $dest ]]; then - dest="$arg" - else - args+="$arg" - fi - ;; - esac -done - -git svn clone --no-metadata $args "$svnrepo" "$dest" - -cd "$dest/.git" - -test -d svn && rm -r svn -rm -rf **/git-svn* - -cd - diff --git a/.zsh/func/urlencode b/.zsh/func/urlencode deleted file mode 100644 index 5e4564f..0000000 --- a/.zsh/func/urlencode +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/zsh -# -# func/urlencode -# -# encode strings for use with URLs -# -# Copyright © 1994–2017 martin f. krafft -# Released under the terms of the Artistic Licence 2.0 -# -# Source repository: http://git.madduck.net/v/etc/zsh.git -# -# Based on http://www.michael-prokop.at/computer/config/.zshrc - -setopt localoptions extendedglob -input=( ${(s::)1} ) -print ${(j::)input/(#b)([^A-Za-z0-9_.!~*\'\(\)-])/%$(([##16]#match))} -- 2.39.5