summaryrefslogtreecommitdiff
path: root/helpers/conflicts
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-03-07 15:54:28 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2010-03-07 15:54:28 +0100
commitdc1388bc75113e35d29079e777333648e27d8346 (patch)
tree1e428ce5365ce6213ba433a4bab277406ca27150 /helpers/conflicts
parentfa76dcb81282ff961bb398aef36a959f0a7c6a5f (diff)
include/ → helpers/
Diffstat (limited to 'helpers/conflicts')
-rwxr-xr-xhelpers/conflicts48
1 files changed, 48 insertions, 0 deletions
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
+}