blob: dff50c91cf3d3ecf5ec72a3f8035795c06ae5719 (
plain)
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
|
#!/bin/sh
# If the user is doing something ambiguous, like selecting a bunch of files,
# moving the cursor off of those files, then doing an action, this will ask
# what they mean to target, then output either 'cursor' or 'selected'.
# Usage: targets "$BBCURSOR" "$@"
cursor="$1"
shift
if [ $# -gt 0 ]; then
for f in "$@"; do
if [ "$f" = "$cursor" ]; then
intended='Selected files'
break
fi
done
else
intended='Cursor file'
fi
[ -z "$intended" ] && intended="$(printf '%s\0' 'Cursor file' 'Selected files' 'Both' | bbpick 'Which do you mean? ')"
case "$intended" in
Cursor*) echo cursor ;;
Selected*) echo selected ;;
Both) echo both ;;
esac
|