mirror of
https://github.com/jarun/nnn.git
synced 2024-11-16 16:13:16 +00:00
6147dc9a85
* Add plugin bulknew * Update documentation * Update dependencies * Add whitespace note
33 lines
766 B
Bash
Executable file
33 lines
766 B
Bash
Executable file
#!/usr/bin/env sh
|
|
|
|
# Description: Allows for creation of multiple files/directories at the same time.
|
|
# Plugin opens a temp file where each entry is to be written on a separate line
|
|
#
|
|
# Note: Only relative paths are supported. Absolute paths are ignored
|
|
# Leading and trailing whitespace in path names is also ignored
|
|
#
|
|
# Shell: POSIX compliant
|
|
# Author: KlzXS
|
|
|
|
EDITOR="${EDITOR:-vi}"
|
|
TMPDIR="${TMPDIR:-/tmp}"
|
|
|
|
printf "'f'ile / 'd'ir? "
|
|
read -r resp
|
|
|
|
if [ "$resp" = "f" ]; then
|
|
#shellcheck disable=SC2016
|
|
cmd='mkdir -p "$(dirname "{}")" && touch "{}"'
|
|
elif [ "$resp" = "d" ]; then
|
|
cmd='mkdir -p {}'
|
|
else
|
|
exit 1
|
|
fi
|
|
|
|
tmpfile=$(mktemp "$TMPDIR/.nnnXXXXXX")
|
|
$EDITOR "$tmpfile"
|
|
|
|
sed "/^\//d" "$tmpfile" | xargs -n1 -I{} sh -c "$cmd"
|
|
|
|
rm "$tmpfile"
|