-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbashfunctions.install
More file actions
107 lines (89 loc) · 2.59 KB
/
Copy pathbashfunctions.install
File metadata and controls
107 lines (89 loc) · 2.59 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#RESTORE='\033[0m'
#
#RED='\033[00;31m'
#GREEN='\033[00;32m'
#YELLOW='\033[00;33m'
#BLUE='\033[00;34m'
#PURPLE='\033[00;35m'
#CYAN='\033[00;36m'
#LIGHTGRAY='\033[00;37m'
#
#LRED='\033[01;31m'
#LGREEN='\033[01;32m'
#LYELLOW='\033[01;33m'
#LBLUE='\033[01;34m'
#LPURPLE='\033[01;35m'
#LCYAN='\033[01;36m'
#WHITE='\033[01;37m'
# Run udevadm info on a device file
udev_info()
{
udevadm info -a -p $(udevadm info -q path -n ${1})
}
udev_restart()
{
sudo udevadm control --reload-rules
sudo udevadm trigger --action=change
}
_pushd () {
command pushd "$@" > /dev/null
}
_popd () {
command popd "$@" > /dev/null
}
_gcc_select_set_default()
{
if [ -e "$1-$2" ] ; then
echo -e "${GREEN}✔${RESTORE} $1-$2 is now the default"
sudo ln -sf $1-$2 $1
else
echo -e "${RED}✘${RESTORE} $1-$2 is not installed"
fi
}
gcc_select()
{
if [ -z $1 ] ; then
echo "Sets the default version of gcc, g++, etc"
echo "Usage:"
echo " gcc-set-default-version <VERSION>"
return 0
fi
_pushd /usr/bin
for i in gcc cpp g++ gcov gccbug ; do
_gcc_select_set_default $i $1
done
_popd
}
# Auto complete for run primitive command
_run_primitive()
{
local cur prev opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
# Get a list of all primitive names
local primitives=$(for x in `find ${MERCURY_DIR}/software/Primitives -name "*.py" -not -name "__init__.py" | sed -r "s|$MERCURY_DIR/software/Primitives/(.*)\.py|\1|g" | tr / .`; do echo ${x}; done )
# The list of all other options
opts="--state_name --error_data --robot_config --shelf_map --verbose --simulate"
COMPREPLY=( $(compgen -W "${primitives} ${opts}" -- ${cur}) )
return 0
}
complete -F _run_primitive run_primitive
# Auto Complete for schroot command
_schroot()
{
local cur prev options
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
# Options should probably be autogenerated from the schroot build
# system, but using the current list is probably fine for now.
options="--help --version --list --info --config --location --quiet --verbose --chroot --all --all-chroots --all-sessions --directory --user --preserve-environment --automatic-session --begin-session --recover-session --run-session --end-session --session-name --force -h -V -l -i -q -v -c -a -d -u -p -b -r -e -n -f"
if [ "$prev" = "-c" ]; then
COMPREPLY=( $(compgen -W "$(schroot -a -l)" -- $cur) )
else
COMPREPLY=( $(compgen -W "$options" -- $cur) )
fi
return 0
}
complete -F _schroot schroot
# vim:syntax=sh