summaryrefslogtreecommitdiff
path: root/include/conflicts
blob: b42e15619c5a8dd2dcc343d98e4da72f24d4add1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/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

autoload check_com
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 check_com -c $alias && [[ $aliases[$alias] != (sudo |noglob |)$alias* ]]; then
		echo "conflicting alias: $alias"
	fi
}