-
Notifications
You must be signed in to change notification settings - Fork 11
/
file_chooser
executable file
·40 lines (33 loc) · 925 Bytes
/
file_chooser
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
#!/bin/bash
#
# based on
# [this script](https://stackoverflow.com/questions/31797364/rudimentary-file-explorer-using-dialog-boxes-with-fselect-bash)
# by Anubis Lockward
help() {
echo 'usage: file_chooser'
echo ' file_chooser --help'
echo
echo ' Opens a ncurses file selection dialog that'
echo ' allows you to navigate through the file system'
echo ' and to select a file.'
echo ' The full path of the file will be output to STDOUT'
echo
exit 1
}
[ "$1" == "--help" ] && help
set -e # stop on error
set -u # stop on undefined variable
set -o pipefail # stop part of pipeline failing
function fileChooser(){
dialog --clear \
--title "Please select file with space" \
--stdout --fselect "" 14 58
}
RESULT="$( fileChooser )"
while [ -d "$RESULT" ]
do
cd "$RESULT"
RESULT="$( fileChooser )"
done
# Print selection
realpath "$RESULT"