fix vimv and ebook

This commit is contained in:
Tyrel Souza 2023-04-07 11:46:30 -04:00
parent d026ba76d6
commit 24d36645f6
No known key found for this signature in database
GPG Key ID: F3614B02ACBE438E
4 changed files with 22 additions and 8 deletions

View File

@ -1,17 +1,18 @@
#!/bin/bash #!/usr/bin/env bash
set -eu
# Lists the current directory's files in Vim, so you can edit it and save to rename them # Lists the current directory's files in Vim, so you can edit it and save to rename them
# USAGE: vimv [file1 file2] # USAGE: vimv [file1 file2]
# https://github.com/thameera/vimv # https://github.com/thameera/vimv
declare -r FILENAMES_FILE="$(mktemp --tmpdir vimv.XXX)" declare -r FILENAMES_FILE=$(mktemp "${TMPDIR:-/tmp}/vimv.XXX")
trap '{ rm -f "${FILENAMES_FILE}" ; }' EXIT trap '{ rm -f "${FILENAMES_FILE}" ; }' EXIT
if [ $# -ne 0 ]; then if [ $# -ne 0 ]; then
src=( "$@" ) src=( "$@" )
else else
IFS=$'\r\n' GLOBIGNORE='*' command eval 'src=($(/bin/ls))' IFS=$'\r\n' GLOBIGNORE='*' command eval 'src=($(ls))'
fi fi
for ((i=0;i<${#src[@]};++i)); do for ((i=0;i<${#src[@]};++i)); do
@ -20,18 +21,23 @@ done
${EDITOR:-vi} "${FILENAMES_FILE}" ${EDITOR:-vi} "${FILENAMES_FILE}"
IFS=$'\r\n' GLOBIGNORE='*' command eval 'dest=($(cat "${FILENAMES_FILE}"))' IFS=$'\r\n' GLOBIGNORE='*' command eval 'dest=($(cat "${FILENAMES_FILE}"))'
count=0 if (( ${#src[@]} != ${#dest[@]} )); then
echo "WARN: Number of files changed. Did you delete a line by accident? Aborting.." >&2
exit 1
fi
declare -i count=0
for ((i=0;i<${#src[@]};++i)); do for ((i=0;i<${#src[@]};++i)); do
if [ "${src[i]}" != "${dest[i]}" ]; then if [ "${src[i]}" != "${dest[i]}" ]; then
mkdir -p "`dirname "${dest[i]}"`" mkdir -p "$(dirname "${dest[i]}")"
if git ls-files --error-unmatch "${src[i]}" > /dev/null 2>&1; then if git ls-files --error-unmatch "${src[i]}" > /dev/null 2>&1; then
git mv "${src[i]}" "${dest[i]}" git mv "${src[i]}" "${dest[i]}"
else else
mv "${src[i]}" "${dest[i]}" mv "${src[i]}" "${dest[i]}"
fi fi
((count++)) ((++count))
fi fi
done done

View File

@ -11,6 +11,7 @@ if status is-interactive
source ~/.config/fish/shell_funcs.fish source ~/.config/fish/shell_funcs.fish
source ~/.config/fish/shell_aliases.fish source ~/.config/fish/shell_aliases.fish
source ~/.config/fish/everquote.fish source ~/.config/fish/everquote.fish
source "$HOME/.cargo/env"
set PATH $PATH ~/.cargo/bin
end end

View File

@ -9,6 +9,7 @@
# Terminals # Terminals
bat bat
ctags ctags
dosbox
exa exa
fzf fzf
fd fd
@ -36,5 +37,8 @@
}; };
}; };
nixpkgs.config = {
allowUnfree = true;
};
} }

View File

@ -21,6 +21,9 @@
../_common/fonts.nix ../_common/fonts.nix
]; ];
}; };
nixpkgs.config = {
allowUnfree = true;
};
}; };
} }