mirror of
https://github.com/hydroxycarbamide/dotfiles.git
synced 2025-05-07 21:39:07 -04:00
Add nnn
This commit is contained in:
parent
0ef5de12ac
commit
c0889285ff
58 changed files with 5175 additions and 0 deletions
32
dot_config/nnn/plugins/executable_bulknew
Normal file
32
dot_config/nnn/plugins/executable_bulknew
Normal file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# Description: Allows for creation of multiple files/dirs simultaneously
|
||||
# Creates a tmp file to write each entry in 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"
|
Loading…
Add table
Add a link
Reference in a new issue