-
Notifications
You must be signed in to change notification settings - Fork 2
/
.completions
60 lines (47 loc) · 1.81 KB
/
.completions
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
50
51
52
53
54
55
56
57
58
59
60
# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
[ -e "$HOME/.ssh/config" ] && complete -o default -o nospace -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2)" scp sftp ssh
# Add tab completion for `defaults read|write NSGlobalDomain`
complete -W "NSGlobalDomain" defaults
# Add case-insensitive `killall` tab completion of running apps
_complete_running_processes ()
{
local LC_ALL='C'
local IFS=$'\n'
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=()
# do not attempt completion if we're specifying an option
[[ "$cur" == -* ]] && return 0
# Escape dots in paths for grep
cur=${cur//\./\\\.}
COMPREPLY=( $(ps axc | tail -n +2 | awk '{ print $5 }' | sort -u | grep -v "^[\-\(]" | grep -i "^$cur") )
}
complete -o bashdefault -o default -o nospace -F _complete_running_processes killall
# Add case-insensitive `kill` tab completion of running apps
_complete_running_processes_pids ()
{
local re
local LC_ALL='C'
local IFS=$'\n'
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=()
# do not attempt completion if we're specifying an option
[[ "$cur" == -* ]] && return 0
# Escape dots in paths for grep
cur=${cur//\./\\\.}
if [[ $cur != *[!0-9]* ]]; then
# search by PID
re="^$cur"
else
# search by process name
re="^[0-9]+ # $cur[^$]"
fi
COMPREPLY=( $(ps axc | tail -n +2 | awk '{print $1 " # " $5}' | sort -u | grep -v "^[\-\(]" | egrep -i "$re") )
}
complete -o bashdefault -o default -o nospace -F _complete_running_processes_pids kill
# If possible, add tab completion for many more commands
if [ -f /opt/local/share/doc/git-core/contrib/completion/git-completion.bash ]; then
. /opt/local/share/doc/git-core/contrib/completion/git-completion.bash
fi
if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then
. /opt/local/etc/profile.d/bash_completion.sh
fi