aboutsummaryrefslogtreecommitdiffstats
path: root/modules/file-management/yazi/file-chooser.sh
blob: 34103ce54ae3f0d2a01d9c8a63d04a52d8d5e229 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
# Launch yazi as a file/directory chooser and write the result to an output file.

# $1 toggles multiple selection
# $2 toggles directory select mode
# $3 toggles save file mode
# $4 is the initial directory path
# $5 is the output path file

# multiple="$1"
directory="$2"
# save="$3"
path="$4"
out="$5"

# Pick directory vs single/multiple file
if [ "$directory" = "1" ]; then
  # Outputs the final working directory path on exit
  exec yazi "$path" --cwd-file="$out"
else
  # Writes all selected file paths to the output file on exit
  exec yazi "$path" --chooser-file="$out"
fi