-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathsman.rc
More file actions
47 lines (41 loc) · 690 Bytes
/
sman.rc
File metadata and controls
47 lines (41 loc) · 690 Bytes
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
# vim: set ft=sh:
s() {
if [[ ${1} == "run" ]] || [[ ${1} == "r" ]]; then
eval "$(sman "$@")"
else
sman "$@"
fi
}
_escaped_string(){
if [[ "$1" =~ ^[-:_[:alnum:]]*$ ]];
then
echo "$1"
elif [[ "$1" =~ ^[^\']*$ ]];
then
echo "'$1'"
else
echo "\"$1\""
fi
}
_history_command(){
if [[ ! -z $BASH_VERSION ]];
then
echo "history -s"
elif [[ ! -z $ZSH_VERSION ]];
then
echo "print -s"
fi
}
_append_history(){
local command
for arg; do
local output=$(_escaped_string "$arg")
if [[ ! -z $command ]];
then
command="$command $output"
else
command="$output"
fi
done
$(_history_command) "$command"
}