Move maker functions to mkrs
This commit is contained in:
parent
fec0cd6f68
commit
776bc1ef2a
4 changed files with 84 additions and 30 deletions
|
@ -1,11 +0,0 @@
|
||||||
#!/bin/zsh
|
|
||||||
# vim:ft=zsh
|
|
||||||
|
|
||||||
mkcmod ()
|
|
||||||
{
|
|
||||||
if [[ $1 == "" ]]; then
|
|
||||||
echo "Usage: $0 mod_name"
|
|
||||||
else
|
|
||||||
touch $1.{c,h}
|
|
||||||
fi
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
#!/bin/zsh
|
|
||||||
# vim:ft=zsh
|
|
||||||
|
|
||||||
# make a Maildir directory
|
|
||||||
mkmdir ()
|
|
||||||
{
|
|
||||||
if [[ $1 == "" ]]; then
|
|
||||||
echo "Usage: $0 mdir_name"
|
|
||||||
else
|
|
||||||
mkdir -p $1/{new,cur,tmp}
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
80
zsh/func/mkrs
Normal file
80
zsh/func/mkrs
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
#!/bin/zsh
|
||||||
|
# vim:ft=zsh
|
||||||
|
|
||||||
|
[[ -e $HOME/.shell-functions ]] && source $HOME/.shell-functions
|
||||||
|
|
||||||
|
mkcodemod()
|
||||||
|
{
|
||||||
|
local opts='cmph'
|
||||||
|
local funcname=$0
|
||||||
|
|
||||||
|
_usage() { echo "Usage: $funcname [-$opts] mod_name [mod_name] ..." 1>&2 }
|
||||||
|
|
||||||
|
if [[ ${#@} -lt 2 ]]; then
|
||||||
|
echo "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
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Make a Maildir directory.
|
||||||
|
mkmdir()
|
||||||
|
{
|
||||||
|
if [[ -z $1 || $1 == "" ]]; then
|
||||||
|
echo "Usage: $0 mdir_name"
|
||||||
|
else
|
||||||
|
mkdir -p $1/{new,cur,tmp}
|
||||||
|
fi
|
||||||
|
}
|
10
zshrc
10
zshrc
|
@ -185,14 +185,12 @@ zstyle ':completion:*' expand 'yes'
|
||||||
# function path
|
# function path
|
||||||
fpath=($HOME/.zsh/func $fpath)
|
fpath=($HOME/.zsh/func $fpath)
|
||||||
|
|
||||||
# Wikipedia lookup, courtesy of msanders@github
|
|
||||||
autoload wiki
|
|
||||||
# Make a Maildir
|
|
||||||
autoload mkmdir
|
|
||||||
# Generate a password
|
# Generate a password
|
||||||
|
print_info_sub "Loading pw module"
|
||||||
autoload pw
|
autoload pw
|
||||||
# Make a C module (.c and .h pair)
|
# Maker module -- various functions for makin' stuff
|
||||||
autoload mkcmod
|
print_info_sub "Loading mkrs module"
|
||||||
|
autoload mkrs
|
||||||
|
|
||||||
# Go up $1 directories, where $1 is an integer (saves me from having to type ../
|
# Go up $1 directories, where $1 is an integer (saves me from having to type ../
|
||||||
# ad nauseum)
|
# ad nauseum)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue