-
Notifications
You must be signed in to change notification settings - Fork 0
/
test
executable file
·40 lines (34 loc) · 1.02 KB
/
test
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
#!/usr/bin/env bash
main(){
# Bind 'ctrl+n' to cycle through the buffer list. As
# the prompt uses bash's builtin 'readline', we're
# able to do whatever we like with it. Neat huh?
bind -x '"\C-n":cmd "/next"' &>/dev/null
bind -x '"\C-p":cmd "/prev"' &>/dev/null
bind 'TAB:menu-complete' &>/dev/null
bind 'set match-hidden-files off' &>/dev/null
bind 'set horizontal-scroll-mode on' &>/dev/null
dir="${TMPDIR:=/tmp}/budget"
cd "$dir" || exit 1
for file in income expense; do
mkdir -p "${dir}/${file}"
for f in add delete modify;{ :> ${file}/${f}; }
done
# Set readline's history file so that we can manage
# its history ourselves.
export HISTFILE=$PWD/hist
export HISTCONTROL=ignoreboth:erasedups
export INPUTRC=$BIRCH_INPUTRC
}
tst(){
case $1 in
income/add) echo "income add $(($2))" ;;
income/delete) echo "income del $(($2))" ;;
income/modify) echo "income mod $(($2))" ;;
esac
echo $(($1))
[[ "$1" -gt 0 ]] || return
history -s "$1"
}
main "$@"
while read -e; do set $REPLY; tst "$1" "$(($3))"; done