ZSH makers module
This commit is contained in:
parent
794b18099e
commit
216ff74d2a
3 changed files with 79 additions and 80 deletions
68
zsh/func/makers/mkcodemod
Normal file
68
zsh/func/makers/mkcodemod
Normal file
|
@ -0,0 +1,68 @@
|
|||
#!/bin/zsh
|
||||
# Create a code module
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
local opts='cmph'
|
||||
local funcname=$0
|
||||
|
||||
_usage() {
|
||||
print_info "Usage: $funcname [-$opts] mod_name [mod_name] ..." 1>&2
|
||||
}
|
||||
|
||||
if [[ ${#@} -lt 2 ]]; then
|
||||
print_error "Insufficient number of arguments" 1>&2
|
||||
_usage
|
||||
return -1
|
||||
fi
|
||||
|
||||
local opt
|
||||
local complete=0
|
||||
local srcext=''
|
||||
local headext=''
|
||||
local modtype=''
|
||||
|
||||
while getopts $opts opt; do
|
||||
[[ $complete -eq 1 ]] && return 2
|
||||
case $opt in
|
||||
c)
|
||||
modtype='C'
|
||||
srcext='c'
|
||||
headext='h'
|
||||
;;
|
||||
m)
|
||||
modtype='Objective-C'
|
||||
srcext='m'
|
||||
headext='h'
|
||||
;;
|
||||
p)
|
||||
modtype='Python'
|
||||
srcext='py'
|
||||
;;
|
||||
h)
|
||||
_usage
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
print_error "Invalid argument: $opt" 1>&2
|
||||
_usage
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
complete=1
|
||||
done
|
||||
|
||||
if [[ -z $opt ]]; then
|
||||
_usage
|
||||
return -1
|
||||
fi
|
||||
|
||||
print_info "Creating $modtype modules"
|
||||
for mod in $@[$OPTIND,${#@}]; do
|
||||
print_info_sub $mod
|
||||
[[ -n $srcext ]] && touch $mod.$srcext
|
||||
[[ -n $headext ]] && touch $mod.$headext
|
||||
done
|
||||
|
||||
unfunction _usage
|
||||
return 0
|
||||
|
11
zsh/func/makers/mkmdir
Normal file
11
zsh/func/makers/mkmdir
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/zsh
|
||||
# Make a Maildir directory
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
if [[ -z $1 || $1 == "" ]]; then
|
||||
echo "Usage: $0 [maildir]"
|
||||
exit 1
|
||||
else
|
||||
|
||||
mkdir -p $1/{new,cur,tmp}
|
||||
return $?
|
Loading…
Add table
Add a link
Reference in a new issue