Refactor bin scripts
This commit is contained in:
parent
639fa8e1c2
commit
573bf2722f
4
bin/2png
4
bin/2png
|
@ -1,11 +1,11 @@
|
|||
#!/usr/bin/env zsh
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Creates pngs from PSD (and AI) files. Requires imagemagick (and ghostscript
|
||||
# for ai files)
|
||||
|
||||
# Usage: 2png *.{psd,ai}
|
||||
|
||||
[[ ! -d _png ]] && mkdir -p _png;
|
||||
[[ -d _png ]] || mkdir -p _png;
|
||||
|
||||
for f in $1
|
||||
do
|
||||
|
|
2
bin/calc
2
bin/calc
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
bc -l <<< "$@"
|
||||
# usage:
|
||||
# bc 25 + 25
|
||||
# calc 25 + 25
|
||||
# => 50
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
|
||||
# Lists the contents of archives.
|
||||
#
|
||||
# Adapted from a script by Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
|
||||
if (( $# == 0 ))
|
||||
then
|
||||
if (($# == 0)); then
|
||||
cat >&2 <<EOF
|
||||
usage: $0 [-option] [file ...]
|
||||
|
||||
|
@ -16,22 +15,19 @@ Report bugs to <sorin.ionescu@gmail.com>.
|
|||
EOF
|
||||
fi
|
||||
|
||||
if [[ "$1" == "-v" || "$1" == "--verbose" ]]
|
||||
then
|
||||
if [[ $1 = -v || $1 = --verbose ]]; then
|
||||
verbose=0
|
||||
shift
|
||||
fi
|
||||
|
||||
while (( $# > 0 ))
|
||||
do
|
||||
if [[ ! -s "$1" ]]
|
||||
then
|
||||
while (($# > 0)); do
|
||||
if [[ ! -s $1 ]]; then
|
||||
>&2 echo "$0: file not valid: $1"
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
case "${1:l}" in
|
||||
case ${1:l} in
|
||||
*.tar.gz|*.tgz) tar t${verbose:+v}vzf "$1" ;;
|
||||
*.tar.bz2|*.tbz|*.tbz2) tar t${verbose:+v}jf "$1" ;;
|
||||
*.tar.xz|*.txz) tar --xz --help &> /dev/null \
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
find_this="$1"; shift
|
||||
replace_with="$1"; shift
|
||||
|
||||
items=$(ag -l --nocolor "$find_this" "$@")
|
||||
items=( $(ag -l --nocolor "$find_this" "$@") )
|
||||
temp="${TMPDIR:-/tmp}/replace_tmp.$$"
|
||||
for item in $items; do
|
||||
for item in ${items[@]}; do
|
||||
sed "s/$find_this/$replace_with/g" "$item" > "$temp" && mv "$temp" "$item"
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue