-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnaav
executable file
·93 lines (82 loc) · 2.52 KB
/
naav
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
file_option=$1
source_folder=$2
search_itam=$3
usage() {
echo "Usage: $(basename "$0") [-h|--help] [-v|--version] [-f <source_folder> <search_item>] [-d <source_folder> <search_item>]"
echo " -h, --help Display this help message"
echo " -v, --version Display version information"
echo " -f Find file in the specified folder"
echo " -d Find directory in the specified folder"
exit 1
}
# Function to display version
version() {
echo "$(basename "$0") version 0.1"
exit 1
}
# Check if no options are provided
if [[ -z "$file_option" ]]; then
usage
fi
# Parse command-line options
case "$file_option" in
-h|--help)
usage
;;
-v|--version)
version
;;
esac
if [[ "$file_option" == "-f" ]]; then
output=$(find /$source_folder -name $search_itam -type f 2>/dev/null)
IFS=$'\n' read -rd '' -a directories <<<"$output"
select dir in "${directories[@]}"; do
if [ -n "$dir" ]; then
#cat "$dir"
#exec $SHEL
echo "You selected $dir. How would you like to open it?"
PS3="Enter your choice: "
options=("vim" "nano" "cat" "Exit")
select opt in "${options[@]}"; do
case $opt in
"vim")
vim "$dir"
break
;;
"nano")
nano "$dir"
break
;;
"cat")
cat "$dir"
break
;;
"Exit")
break
;;
*)
echo "Invalid option."
;;
esac
done
break
else
echo "Invalid selection."
fi
done
elif [[ "$file_option" == "-d" ]]; then
output=$(find /$source_folder -name $search_itam -type d 2>/dev/null)
IFS=$'\n' read -rd '' -a directories <<<"$output"
select dir in "${directories[@]}"; do
if [ -n "$dir" ]; then
cd "$dir"
exec $SHELL
break
else
echo "Invalid selection."
fi
done
else
exit
fi