|
Revision 1357, 1.4 kB
(checked in by alpt, 1 year ago)
|
Online help added: ] --help, ][ --help
|
- Property svn:executable set to
*
|
| Line | |
|---|
| 1 |
#!/bin/bash |
|---|
| 2 |
# |
|---|
| 3 |
# closebracket: a fast shell shortcut definer |
|---|
| 4 |
# http://www.freaknet.org/alpt/src/utils/closebracket/ |
|---|
| 5 |
# |
|---|
| 6 |
# Closebracket let you define multiple shell actions in a single command to |
|---|
| 7 |
# speed up the typing of the most repetitive shell commands. |
|---|
| 8 |
# The command name of Closebracket is `]' and `][', that's because these |
|---|
| 9 |
# characters are near the "Enter" key and it is easy to type them fast. |
|---|
| 10 |
# |
|---|
| 11 |
# All the actions are defined in $CB_CONF |
|---|
| 12 |
# |
|---|
| 13 |
# This source code is free software; you can redistribute it and/or |
|---|
| 14 |
# modify it under the terms of the GNU General Public License as published |
|---|
| 15 |
# by the Free Software Foundation; either version 2 of the License, |
|---|
| 16 |
# or (at your option) any later version. |
|---|
| 17 |
# |
|---|
| 18 |
#(c) Copyright 2006 AlpT (@freaknet.org) |
|---|
| 19 |
# |
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
CB_CONF="$CLOSEBRACKET_DIR/closebracket.conf" |
|---|
| 23 |
|
|---|
| 24 |
if [ -z "${CB_ACTION[1]}" ] |
|---|
| 25 |
then |
|---|
| 26 |
source $CB_CONF |
|---|
| 27 |
source $FILE_EXTENSIONS_LIST |
|---|
| 28 |
fi |
|---|
| 29 |
|
|---|
| 30 |
case $1 in |
|---|
| 31 |
I) SACT=('true' ${CB_ACTION[@]}); shift;; |
|---|
| 32 |
II) SACT=('true' ${CB_ACTION_II[@]}); shift;; |
|---|
| 33 |
*) echo "Don't use the cb script directly!" |
|---|
| 34 |
exit;; |
|---|
| 35 |
esac |
|---|
| 36 |
|
|---|
| 37 |
case $1 in -h|--help) HELP=1; shift;; |
|---|
| 38 |
*) HELP="";; |
|---|
| 39 |
esac |
|---|
| 40 |
|
|---|
| 41 |
cb_idx=1 |
|---|
| 42 |
com="${SACT[$cb_idx]}" |
|---|
| 43 |
|
|---|
| 44 |
while [ ! -z "$com" ] |
|---|
| 45 |
do |
|---|
| 46 |
if [ ! -z "$HELP" ]; then |
|---|
| 47 |
eval '$com"_help" "$@"' | sed -e 's/^/\n* /' |
|---|
| 48 |
eval '$com"_exp" "$@"' | sed -e 's/^/ /' |
|---|
| 49 |
else |
|---|
| 50 |
eval '$com "$@"' |
|---|
| 51 |
fi |
|---|
| 52 |
if [ "$?" -eq "$CB_OK" ] |
|---|
| 53 |
then |
|---|
| 54 |
break |
|---|
| 55 |
fi |
|---|
| 56 |
((cb_idx++)) |
|---|
| 57 |
com="${SACT[$cb_idx]}" |
|---|
| 58 |
done |
|---|