From dc1388bc75113e35d29079e777333648e27d8346 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 7 Mar 2010 15:54:28 +0100 Subject: include/ → helpers/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helpers/conflicts | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ helpers/mimetypes | 27 +++++++++++++++++++++++++++ include/conflicts | 48 ------------------------------------------------ include/mimetypes | 27 --------------------------- 4 files changed, 75 insertions(+), 75 deletions(-) create mode 100755 helpers/conflicts create mode 100755 helpers/mimetypes delete mode 100755 include/conflicts delete mode 100755 include/mimetypes diff --git a/helpers/conflicts b/helpers/conflicts new file mode 100755 index 0000000..fb40aef --- /dev/null +++ b/helpers/conflicts @@ -0,0 +1,48 @@ +#!/usr/bin/env zsh +## vim:ft=zsh +## Look for conflicting aliases and commands in ~/bin +## Since aliases are usually loaded from zshrc, which is not sourced +## for zsh script execution, the recommended usage is +## source .../conflicts +## in a running, interactive zsh + +typeset file dir alias +typeset PKG_DIR=$HOME/packages +typeset -a sfpath spath conflict + +is_in_path () { + typeset -i ret=1 + typeset dir + typeset file=$1 + shift + for dir in $@; { + if [[ -e $dir/$file ]] { + ret=0 + echo $dir/$file + } + } + return $ret +} + +sfpath=(${fpath:#$HOME*}) +spath=(${path:#$HOME*}) + +for file in $PKG_DIR/{*/provides/zsh/completions/*(N),zsh/etc/completions/*(N)}; { + conflict=($(is_in_path ${file:t} $sfpath)) + if (( ? == 0 )) { + echo "conflict: $file <-> ${(j:, :)conflict}" + } +} + +for file in $PKG_DIR/*/bin/*(N); { + conflict=($(is_in_path ${file:t} $spath)) + if (( ? == 0 )) { + echo "conflict: $file <-> ${(j:, :)conflict}" + } +} + +for alias in ${(k)aliases}; { + if [[ -n $commands[$alias] ]] && [[ $aliases[$alias] != (sudo |noglob |)$alias* ]]; then + echo "conflicting alias: $alias" + fi +} diff --git a/helpers/mimetypes b/helpers/mimetypes new file mode 100755 index 0000000..425d2b5 --- /dev/null +++ b/helpers/mimetypes @@ -0,0 +1,27 @@ +#!/usr/bin/env zsh +typeset -a audio video image +eval $(perl -ne 'if (/^mime_\w+\=\(/ or $found == 1) { $found = 1; print } if (/^\)/ and $found == 1) {$found = 0}' ~/.zshrc) + +while read mime extensions; do + [[ $mime == audio/* ]] && audio+=(${(s/ /)extensions}) + [[ $mime == video/* ]] && video+=(${(s/ /)extensions}) + [[ $mime == image/* ]] && image+=(${(s/ /)extensions}) +done < /etc/mime.types + +audio=(${(i)audio}) +video=(${(i)video}) +image=(${(i)image}) + +for mimetype in $audio; { + [[ ${mime_audio[(I)$mimetype]} == 0 ]] && echo "mime_audio+=$mimetype" +} +for mimetype in $video; { + [[ ${mime_video[(I)$mimetype]} == 0 ]] && echo "mime_video+=$mimetype" +} +for mimetype in $image; { + [[ ${mime_image[(I)$mimetype]} == 0 ]] && echo "mime_image+=$mimetype" +} + +echo "mime_audio=($audio)" +echo "mime_video=($video)" +echo "mime_image=($image)" diff --git a/include/conflicts b/include/conflicts deleted file mode 100755 index fb40aef..0000000 --- a/include/conflicts +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env zsh -## vim:ft=zsh -## Look for conflicting aliases and commands in ~/bin -## Since aliases are usually loaded from zshrc, which is not sourced -## for zsh script execution, the recommended usage is -## source .../conflicts -## in a running, interactive zsh - -typeset file dir alias -typeset PKG_DIR=$HOME/packages -typeset -a sfpath spath conflict - -is_in_path () { - typeset -i ret=1 - typeset dir - typeset file=$1 - shift - for dir in $@; { - if [[ -e $dir/$file ]] { - ret=0 - echo $dir/$file - } - } - return $ret -} - -sfpath=(${fpath:#$HOME*}) -spath=(${path:#$HOME*}) - -for file in $PKG_DIR/{*/provides/zsh/completions/*(N),zsh/etc/completions/*(N)}; { - conflict=($(is_in_path ${file:t} $sfpath)) - if (( ? == 0 )) { - echo "conflict: $file <-> ${(j:, :)conflict}" - } -} - -for file in $PKG_DIR/*/bin/*(N); { - conflict=($(is_in_path ${file:t} $spath)) - if (( ? == 0 )) { - echo "conflict: $file <-> ${(j:, :)conflict}" - } -} - -for alias in ${(k)aliases}; { - if [[ -n $commands[$alias] ]] && [[ $aliases[$alias] != (sudo |noglob |)$alias* ]]; then - echo "conflicting alias: $alias" - fi -} diff --git a/include/mimetypes b/include/mimetypes deleted file mode 100755 index 425d2b5..0000000 --- a/include/mimetypes +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env zsh -typeset -a audio video image -eval $(perl -ne 'if (/^mime_\w+\=\(/ or $found == 1) { $found = 1; print } if (/^\)/ and $found == 1) {$found = 0}' ~/.zshrc) - -while read mime extensions; do - [[ $mime == audio/* ]] && audio+=(${(s/ /)extensions}) - [[ $mime == video/* ]] && video+=(${(s/ /)extensions}) - [[ $mime == image/* ]] && image+=(${(s/ /)extensions}) -done < /etc/mime.types - -audio=(${(i)audio}) -video=(${(i)video}) -image=(${(i)image}) - -for mimetype in $audio; { - [[ ${mime_audio[(I)$mimetype]} == 0 ]] && echo "mime_audio+=$mimetype" -} -for mimetype in $video; { - [[ ${mime_video[(I)$mimetype]} == 0 ]] && echo "mime_video+=$mimetype" -} -for mimetype in $image; { - [[ ${mime_image[(I)$mimetype]} == 0 ]] && echo "mime_image+=$mimetype" -} - -echo "mime_audio=($audio)" -echo "mime_video=($video)" -echo "mime_image=($image)" -- cgit v1.2.3