Add chext zsh function
This commit is contained in:
parent
c56c2473a6
commit
4d5a0b8f6e
2 changed files with 29 additions and 0 deletions
0
home/.config/asd
Normal file
0
home/.config/asd
Normal file
|
@ -300,3 +300,32 @@ clock() {
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Change file extension made easy
|
||||||
|
chext() {
|
||||||
|
file="$1"
|
||||||
|
new_ext="$2"
|
||||||
|
dest="${file%.*}.$new_ext"
|
||||||
|
|
||||||
|
help() {
|
||||||
|
printf "Change file extension\nUsage: chext file new_extension\nFor example: chext my_script.sh zsh"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||||
|
help
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $# -lt 2 ]; then
|
||||||
|
help
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e "$1" ]; then
|
||||||
|
echo "$file: no such file or directory"
|
||||||
|
help
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mv "$file" "$dest"
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue