Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
34a6943d73
5 changed files with 150 additions and 97 deletions
7
codetemplates/django/basic/.gitignore
vendored
Normal file
7
codetemplates/django/basic/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
*.log
|
||||||
|
*.pot
|
||||||
|
*.pyc
|
||||||
|
local_settings.py
|
||||||
|
|
||||||
|
env/
|
||||||
|
local.db
|
||||||
32
setup.sh
32
setup.sh
|
|
@ -13,16 +13,18 @@ typeset -A vimbundles
|
||||||
# fugitive "https://github.com/tpope/vim-fugitive.git" \
|
# fugitive "https://github.com/tpope/vim-fugitive.git" \
|
||||||
vimbundles=( \
|
vimbundles=( \
|
||||||
command-t "https://github.com/wincent/Command-T.git" \
|
command-t "https://github.com/wincent/Command-T.git" \
|
||||||
|
dash "https://github.com/rizzatti/dash.vim.git"
|
||||||
|
funcoo "git clone https://github.com/rizzatti/funcoo.vim.git" \
|
||||||
gundo "https://github.com/sjl/gundo.vim.git" \
|
gundo "https://github.com/sjl/gundo.vim.git" \
|
||||||
|
mw-utils "https://github.com/MarcWeber/vim-addon-mw-utils.git" \
|
||||||
repeat "https://github.com/tpope/vim-repeat" \
|
repeat "https://github.com/tpope/vim-repeat" \
|
||||||
snipmate "https://github.com/garbas/vim-snipmate.git" \
|
snipmate "https://github.com/garbas/vim-snipmate.git" \
|
||||||
tlib "https://github.com/tomtom/tlib_vim.git" \
|
|
||||||
mw-utils "https://github.com/MarcWeber/vim-addon-mw-utils.git" \
|
|
||||||
snipmate-snippets "https://github.com/honza/snipmate-snippets.git" \
|
snipmate-snippets "https://github.com/honza/snipmate-snippets.git" \
|
||||||
snipmate-zope "https://github.com/zedr/zope-snipmate-bundle.git" \
|
snipmate-zope "https://github.com/zedr/zope-snipmate-bundle.git" \
|
||||||
solarized "https://github.com/altercation/vim-colors-solarized.git" \
|
solarized "https://github.com/altercation/vim-colors-solarized.git" \
|
||||||
speeddating "https://github.com/tpope/vim-speeddating.git" \
|
speeddating "https://github.com/tpope/vim-speeddating.git" \
|
||||||
surround "https://github.com/tpope/vim-surround.git" \
|
surround "https://github.com/tpope/vim-surround.git" \
|
||||||
|
tlib "https://github.com/tomtom/tlib_vim.git" \
|
||||||
unimpaired "https://github.com/tpope/vim-unimpaired.git" \
|
unimpaired "https://github.com/tpope/vim-unimpaired.git" \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -35,31 +37,17 @@ print -P "%BSymlinking config files%b"
|
||||||
for dotfile in `ls $dfdir`
|
for dotfile in `ls $dfdir`
|
||||||
do
|
do
|
||||||
# metafiles; don't link them
|
# metafiles; don't link them
|
||||||
[ $dotfile = 'setup.sh' ] && continue
|
[[ $dotfile = 'setup.sh' ]] && continue
|
||||||
[ $dotfile = 'README.md' ] && continue
|
[[ $dotfile = 'README.md' ]] && continue
|
||||||
|
|
||||||
local dest="$HOME/.$dotfile"
|
local dest="$HOME/.$dotfile"
|
||||||
local action='skipped'
|
if [[! -L "$dest" ]]; then
|
||||||
|
action='Linking'
|
||||||
if [[ ! -L "$dest" ]]; then
|
|
||||||
action='linked'
|
|
||||||
else
|
|
||||||
action='skipped'
|
|
||||||
fi
|
|
||||||
filler=$(($COLUMNS - ${#dest} - ${#action} - 4))
|
|
||||||
spaces=''
|
|
||||||
for (( i=0; $i < $filler; i++ )); do spaces="$spaces "; done
|
|
||||||
|
|
||||||
echo -n " $dest"
|
|
||||||
if [[ $action == 'linked' ]]; then
|
|
||||||
ln -fs "$dfdir/$dotfile" "$dest"
|
ln -fs "$dfdir/$dotfile" "$dest"
|
||||||
action="%F{green}$action%f"
|
|
||||||
elif [[ $action == 'skipped' ]]; then
|
|
||||||
action="%F{yellow}$action%f"
|
|
||||||
else
|
else
|
||||||
action="%F{red}red%f"
|
action='Skipping'
|
||||||
fi
|
fi
|
||||||
print -P "$spaces$action"
|
printf " %8s: %s\n" $action $dest
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "touch $HOME/.hushlogin"
|
echo "touch $HOME/.hushlogin"
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ setlocal expandtab
|
||||||
|
|
||||||
let s:buf_filename = expand('%:t')
|
let s:buf_filename = expand('%:t')
|
||||||
if s:buf_filename != "SConscript" && s:buf_filename != "SConstruct"
|
if s:buf_filename != "SConscript" && s:buf_filename != "SConstruct"
|
||||||
setlocal textwidth=100
|
setlocal textwidth=80
|
||||||
setlocal colorcolumn=100
|
setlocal colorcolumn=80
|
||||||
else
|
else
|
||||||
setlocal textwidth=80
|
setlocal textwidth=80
|
||||||
setlocal colorcolumn=80
|
setlocal colorcolumn=80
|
||||||
|
|
|
||||||
|
|
@ -6,46 +6,72 @@
|
||||||
local funcname=$0
|
local funcname=$0
|
||||||
|
|
||||||
|
|
||||||
_usage() {
|
_usage_mkdjango() {
|
||||||
print_info "Usage: $funcname template_name project_name [optional destination directory]"
|
print_info "Usage: $funcname template_name project_name [optional destination directory]"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ ${#@} -lt 2 ]]; then
|
function mkdjango
|
||||||
|
{
|
||||||
|
if [[ ${#@} -lt 2 ]]; then
|
||||||
print_error "Need moar arguments" 1>&2
|
print_error "Need moar arguments" 1>&2
|
||||||
_usage
|
_usage_mkdjango
|
||||||
return -1
|
return -1
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
local tname=$1
|
|
||||||
local tdir="$HOME/.codetemplates/django/$tname"
|
|
||||||
local pname=$2
|
|
||||||
local dest=$3
|
|
||||||
|
|
||||||
if [[ ! -d "$tdir" ]]; then
|
|
||||||
print_error "Invalid template name: $tname" 1>&2
|
|
||||||
return -2
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
print_info "Making Django project '$pname' with template '$tname'"
|
|
||||||
if [[ -n "$dest" && ! -d "$dest" ]]; then
|
|
||||||
print_info_sub "Destination directory given but does not exist; creating $dest"
|
|
||||||
mkdir -p "$dest"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Determine what files might not be rendered by django-admin.py
|
|
||||||
local names=()
|
|
||||||
for f in `find "$tdir"`; do
|
|
||||||
# Pick up all dotfiles
|
|
||||||
if [[ -e "$f" && "`basename $f`" =~ "^\." ]]; then
|
|
||||||
names+=($f)
|
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
|
||||||
print_info_sub "Calling django-admin.py"
|
local template_name=$1
|
||||||
django-admin.py startproject --template="$tdir" --name=${(j.,.)names} $pname $dest
|
local template_dir="$HOME/.codetemplates/django/$template_name"
|
||||||
exitcode=$?
|
local project_name=$2
|
||||||
|
local project_dst=$3
|
||||||
|
|
||||||
unfunction _usage
|
if [[ ! -d "$template_dir" ]]; then
|
||||||
return $exitcode
|
print_error "Invalid template name: $template_name" 1>&2
|
||||||
|
return -2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$project_dst" ]]; then
|
||||||
|
if [[ ! -d "$project_dst" ]]; then
|
||||||
|
print_info_sub "Destination directory given but does not exist; " \
|
||||||
|
"will create $project_dst"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
project_dst="`pwd`/$project_name"
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_info "Making Django project '$project_name'"
|
||||||
|
print_info_sub "Template name: $template_name"
|
||||||
|
print_info_sub "Template directory: $template_dir"
|
||||||
|
print_info_sub "Project directory: $project_dst"
|
||||||
|
|
||||||
|
# Determine what files might not be rendered by django-admin.py
|
||||||
|
local missing_files=()
|
||||||
|
for f in `ls -A1 "$template_dir"`; do
|
||||||
|
# Pick up all dotfiles
|
||||||
|
if [[ -e "$f" && "$f" =~ "^\." ]]; then
|
||||||
|
missing_files+=("$f")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
print_info_sub "Missing files: ${(j., .)missing_files}"
|
||||||
|
|
||||||
|
mkdir -p "$project_dst"
|
||||||
|
|
||||||
|
print_info "Calling django-admin.py"
|
||||||
|
django-admin.py startproject --template="$template_dir" \
|
||||||
|
--name=${(j.,.)missing_files} \
|
||||||
|
"$project_name" \
|
||||||
|
"$project_dst"
|
||||||
|
exitcode=$?
|
||||||
|
if [[ $exitcode -ne 0 ]]; then
|
||||||
|
print_error "django-admin.py failed"
|
||||||
|
return $exitcode
|
||||||
|
fi
|
||||||
|
|
||||||
|
# print_info "Setting up Git repo"
|
||||||
|
# cd "$project_dir"
|
||||||
|
# git init
|
||||||
|
# git add * .*
|
||||||
|
# git commit -m 'Initial commit'
|
||||||
|
|
||||||
|
return $exitcode
|
||||||
|
}
|
||||||
|
|
||||||
|
mkdjango $@
|
||||||
|
|
|
||||||
62
zsh/func/pw
62
zsh/func/pw
|
|
@ -1,20 +1,49 @@
|
||||||
#!/bin/zsh
|
#!/bin/zsh
|
||||||
# vim:ft=zsh
|
# vim:ft=zsh
|
||||||
|
|
||||||
local ALPHA_SET='A-Za-z'
|
function _usage_pw
|
||||||
local NUMERIC_SET='0-9'
|
{
|
||||||
local SYM_SET='!@#$%^&*'
|
cat <<EOF
|
||||||
local XSYM_SET="${SYM_SET}.;:-+="
|
Usage: $1 [-c <num>] [-h] [-l <num>] [-s <set>]
|
||||||
local ALNUM_SET="${ALPHA_SET}${NUMERIC_SET}"
|
|
||||||
local ALL_SET="${ALNUM_SET}${SYM_SET}"
|
|
||||||
local XALL_SET="${ALNUM_SET}${XSYM_SET}"
|
|
||||||
|
|
||||||
local -i length=16 count=1
|
Password generator. Uses the system random data generator to produce passwords
|
||||||
local charset="$ALL_SET"
|
of the provided length.
|
||||||
|
|
||||||
while getopts 'c:l:s:' opt; do
|
Arguments:
|
||||||
|
-c Count. Number of passwords to generate. (default: 1)
|
||||||
|
-h Help. This message.
|
||||||
|
-l Length. Number of characters per password. (default: 16)
|
||||||
|
-s Character set. Set of characters from which each character of a
|
||||||
|
password is generated. (default: all)
|
||||||
|
|
||||||
|
alpha Uppercase and lowercase ASCII characters (A-Za-z)
|
||||||
|
num Numeric characters (0-9)
|
||||||
|
alnum The above two sets combined
|
||||||
|
sym Symbol set, including: ! @ # $ % ^ & *
|
||||||
|
xsym Extended symbols. Above plus . ; : - + =
|
||||||
|
all Alphanumeric and symbol sets above
|
||||||
|
xall Alphanumeric and extended symbol sets above
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function pw
|
||||||
|
{
|
||||||
|
local ALPHA_SET='A-Za-z'
|
||||||
|
local NUMERIC_SET='0-9'
|
||||||
|
local SYM_SET='!@#$%^&*'
|
||||||
|
local XSYM_SET="${SYM_SET}.;:-+="
|
||||||
|
local ALNUM_SET="${ALPHA_SET}${NUMERIC_SET}"
|
||||||
|
local ALL_SET="${ALNUM_SET}${SYM_SET}"
|
||||||
|
local XALL_SET="${ALNUM_SET}${XSYM_SET}"
|
||||||
|
|
||||||
|
local -i length=16 count=1
|
||||||
|
local charset="$ALL_SET"
|
||||||
|
|
||||||
|
while getopts 'c:hl:s:' opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
c) count=$OPTARG;;
|
c) count=$OPTARG;;
|
||||||
|
h) _usage_pw $0; return 0;;
|
||||||
l) length=$OPTARG;;
|
l) length=$OPTARG;;
|
||||||
s) case $OPTARG in
|
s) case $OPTARG in
|
||||||
alpha) charset="$ALPHA_SET";;
|
alpha) charset="$ALPHA_SET";;
|
||||||
|
|
@ -29,16 +58,19 @@ while getopts 'c:l:s:' opt; do
|
||||||
;;
|
;;
|
||||||
*) echo "Invalid argument: $opt" 1>&2; return -1;;
|
*) echo "Invalid argument: $opt" 1>&2; return -1;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
local cmd='tr -dc "$charset" < /dev/urandom | fold -w $length | head -n $count'
|
local cmd='tr -dc "$charset" < /dev/urandom | fold -w $length | head -n $count'
|
||||||
|
|
||||||
if [[ $SYS == 'darwin' ]]; then
|
if [[ $SYS == 'darwin' ]]; then
|
||||||
# The way OS X >=10.6 handles unicode characters causes tr to fail with an
|
# The way OS X >=10.6 handles unicode characters causes tr to fail with an
|
||||||
# 'Illegal byte sequence' error. Setting the locale here fixes that.
|
# 'Illegal byte sequence' error. Setting the locale here fixes that.
|
||||||
#
|
#
|
||||||
# See: http://nerdbynature.de/s9y/?176
|
# See: http://nerdbynature.de/s9y/?176
|
||||||
cmd="LC_CTYPE=C $cmd"
|
cmd="LC_CTYPE=C $cmd"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
|
}
|
||||||
|
|
||||||
|
pw $@
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue