Refactor bin scripts

This commit is contained in:
Henrik Lissner 2016-11-21 23:58:53 -05:00
parent 639fa8e1c2
commit 573bf2722f
4 changed files with 11 additions and 15 deletions

View file

@ -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

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash
bc -l <<< "$@"
# usage:
# bc 25 + 25
# calc 25 + 25
# => 50

View file

@ -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 \

View file

@ -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