Zsh: Turn machklein.sh into a function and name it mksmol

This commit is contained in:
tastytea 2022-03-18 23:11:27 +01:00
parent ecaa328333
commit b43d99f9a1
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
3 changed files with 18 additions and 13 deletions

View File

@ -80,6 +80,8 @@ alias wget_leech='wget --no-directories --page-requisites --span-hosts'
alias cat='cat-highlight' alias cat='cat-highlight'
alias machklein='mksmol'
# OS specific settings. # OS specific settings.
case $(lsb_release -i -s 2> /dev/null) in case $(lsb_release -i -s 2> /dev/null) in
Gentoo) Gentoo)

View File

@ -1,5 +1,5 @@
#!/bin/zsh #!/bin/zsh
# Various functions, to be sourced. # Various small functions
# Get backtrace from gdb. # Get backtrace from gdb.
function gdb_get_backtrace() function gdb_get_backtrace()
@ -51,3 +51,18 @@ function cat-highlight()
\cat $@ \cat $@
fi fi
} }
# Makes all files in DIR lower case. Works with Non-ASCII characters.
function mksmol()
{
if [[ ${ARGC} -ne 1 ]]; then
echo "usage: ${0} DIR" >&2
return 1
fi
local dir="${1}"
for file in "${dir}"/*; do
newfile="${file:l}"
[[ "${file}" != "${newfile}" ]] && mv "${file}" "${newfile}" || :
done
}

View File

@ -1,12 +0,0 @@
#!/bin/zsh
if [[ -z "${1}" ]]; then
echo "usage: ${0} DIR" >&2
exit 1
fi
dir="${1}"
for file in "${dir}"/*; do
newfile="${file:l}"
[[ "${file}" != "${newfile}" ]] && mv "${file}" "${newfile}" || echo -n
done