Add file renaming script

This commit is contained in:
Akemi Izuko 2022-12-19 19:42:03 -07:00
parent 44dfd38077
commit 9ef5736174
No known key found for this signature in database
GPG key ID: 905D444F6A5E4BE4
4 changed files with 40 additions and 0 deletions

35
bin/rename_for_shell.sh Executable file
View file

@ -0,0 +1,35 @@
#!/usr/bin/env bash
print_help() {
cat <<HELP
Converts a given file name to something more sensible
USAGE: $(basename "$0") <file-name>
Removes characters that shouldn't be used in file names. Effectively leaves
/[0-9A-z-_.]/ with a few additional rules (like no leading hyphens)
HELP
}
if [[ -z "$1" ]]; then
print_help
exit 1
else
echo "$@" | awk '{
split($0, a, "")
for (i in a) {
c=a[i]
if (!length(name) && c == "-")
continue;
else if (c ~ /[0-9A-Za-z_.-\/]/)
name = name c
else if (c == " ")
name = name "_"
else if (c == ":" || c == ";")
name = name "-"
}
}
END { print name }'
fi

View file

@ -187,6 +187,7 @@ ctrl+q quit
ctrl+w quit ctrl+w quit
# E cycle edition # switch edition # E cycle edition # switch edition
# l ab-loop # set/clear A-B loop points # l ab-loop # set/clear A-B loop points
A ab-loop # set/clear A-B loop points
# L cycle-values loop-file "inf" "no" # toggle infinite looping # L cycle-values loop-file "inf" "no" # toggle infinite looping
# ctrl+c quit 4 # ctrl+c quit 4
# DEL script-binding osc/visibility # cycle OSC visibility between never, auto (mouse-move) and always # DEL script-binding osc/visibility # cycle OSC visibility between never, auto (mouse-move) and always

View file

@ -361,12 +361,15 @@ mode "mpv_global" {
bindsym j exec ~/.config/sway/mpv_keys.sh 'j' bindsym j exec ~/.config/sway/mpv_keys.sh 'j'
bindsym k exec ~/.config/sway/mpv_keys.sh 'k' bindsym k exec ~/.config/sway/mpv_keys.sh 'k'
bindsym l exec ~/.config/sway/mpv_keys.sh 'l' bindsym l exec ~/.config/sway/mpv_keys.sh 'l'
bindsym Left exec ~/.config/sway/mpv_keys.sh 'LEFT'
bindsym Right exec ~/.config/sway/mpv_keys.sh 'RIGHT'
bindsym space exec ~/.config/sway/mpv_keys.sh 'SPACE' bindsym space exec ~/.config/sway/mpv_keys.sh 'SPACE'
bindsym bracketleft exec ~/.config/sway/mpv_keys.sh '[' bindsym bracketleft exec ~/.config/sway/mpv_keys.sh '['
bindsym bracketright exec ~/.config/sway/mpv_keys.sh ']' bindsym bracketright exec ~/.config/sway/mpv_keys.sh ']'
bindsym minus exec ~/.config/sway/mpv_keys.sh '-' bindsym minus exec ~/.config/sway/mpv_keys.sh '-'
bindsym equal exec ~/.config/sway/mpv_keys.sh '=' bindsym equal exec ~/.config/sway/mpv_keys.sh '='
bindsym m exec ~/.config/sway/mpv_keys.sh 'm' bindsym m exec ~/.config/sway/mpv_keys.sh 'm'
bindsym A exec ~/.config/sway/mpv_keys.sh 'A'
bindsym return mode "default" bindsym return mode "default"
bindsym Ctrl+k mode "default" bindsym Ctrl+k mode "default"

View file

@ -302,6 +302,7 @@ nnoremap <space>; :fdmvcursor<cr>
" =================================================================== " ===================================================================
" Directory-local options, see :h vifm-'sort' " Directory-local options, see :h vifm-'sort'
autocmd DirEnter ~/Downloads setlocal sort=-mtime autocmd DirEnter ~/Downloads setlocal sort=-mtime
autocmd DirEnter /dev/shm setlocal sort=-mtime
" Tmux won't work with sixel at all. Alacritty is currently very unstable with " Tmux won't work with sixel at all. Alacritty is currently very unstable with
" it and flickers a lot. Set $TMUX for blurrier faster version. Quanity on " it and flickers a lot. Set $TMUX for blurrier faster version. Quanity on