-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbpp.sh
More file actions
executable file
·51 lines (44 loc) · 1.14 KB
/
bpp.sh
File metadata and controls
executable file
·51 lines (44 loc) · 1.14 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
#!/bin/bash
# alias bpp='source ~/bin/bpp.sh !$'
# alternate: alias bpp='f() { history -200 | grep $1 | grep -v "bpp" | tail | grep --color $1 };f'
MAX_HISTORY=1000
NUMBER_CHOICES=10
#pattern=$2
#pattern="'$*'"
pattern="$*"
fancy_history_grep () {
history $MAX_HISTORY | grep "$pattern" | grep -v 'bpp ' | tail -n $NUMBER_CHOICES
if true; then
echo -n "Make your choice: "
read choice
if [[ "$choice" == "" || "$choice" -le 0 ]]
then
echo "exiting"
else
command=!$choice
FILENAME="/Users/cvonkrogh/bin/BPP_COMMAND_$choice"
rm -f $FILENAME
touch $FILENAME
echo "# generated by bpp.sh" >> $FILENAME
echo "set -o histexpand" >> $FILENAME
echo "set -o history" >> $FILENAME
echo "$command" >> $FILENAME
source $FILENAME
rm -f $FILENAME
fi
fi
return
}
if [ "$pattern" == "" -o "$pattern" == '!$' ]
then
echo ""
echo "Usage:"
echo " $ bpp mvn c"
echo " $ bpp \"mvn \""
echo ""
# { printf "ls"; } | source /dev/stdin # this works !
# { printf '!506'; } | source /dev/stdin # this does not work !
else
pattern=${pattern:3}
fancy_history_grep "$pattern"
fi