Merge branch 'master' of gitosis@majnematic.com:davesdots

This commit is contained in:
David Alexander Majnemer 2009-02-27 16:12:30 -06:00
commit 40fdc257e0
10 changed files with 58 additions and 19 deletions

View file

@ -1,8 +1,5 @@
#! /usr/bin/env perl
use strict;
use warnings;
# Generate the array
# Fill in the first 16 colors. The exact hex codes vary by terminal and device
@ -35,7 +32,6 @@ print "\n";
sub number_to_color {
use integer;
my $num = shift;
$num -= 16;

View file

@ -30,8 +30,11 @@ fix_term ()
screen?*)
fix_term screen
;;
putty?*)
fix_term putty
putty-vt100)
echo "vt100"
;;
putty-256color)
fix_term xterm-256color
;;
*)
echo "vt100"

View file

@ -61,6 +61,9 @@ extract ()
*.lzma)
lzma -dc "${1}" > `basename "${1%.*}"`
;;
*.7z)
7zr x "${1}"
;;
*)
echo "Unable to extract '"$1"'"
return 1

35
lock
View file

@ -1,10 +1,37 @@
#! /bin/sh
if [ `uname -s` = 'Darwin' ] ; then
# Yell if they are trying to lock remotely. This won't work.
# Even if it does, it's wrong.
if [ "${SSH_TTY}" ] && [ -z "${STY}" ] ; then
echo "You're doing it wrong. Don't try to lock a remote computer."
exit 1
fi
# Graphically locking on Macs is simple.
# If we're not in screen, attempt to graphically lock it.
if [ `uname -s` = 'Darwin' ] && [ -z "${STY}" ] ; then
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
exit
fi
# Handle non-graphical locking
if [ -z "${DISPLAY}" ] ; then
if [ -z "${STY}" ] ; then # not running screen
if ( command -v vlock >/dev/null 2>/dev/null ) ; then
vlock
exit
else
echo "You don't have vlock. Maybe try locking in screen."
fi
else
echo "You are in screen. Use 'C-a x' to lock"
fi
exit 1
fi
# Try to lock sanely on X11.
# Certain combinations of desktop managers and locking programs
# allow new sessions to be started.
KDE_LOCK='kdesktop_lock --forcelock || krunner_lock --forcelock || /usr/libexec/kde4/krunner_lock --forcelock || /usr/lib/kde4/libexec/krunner_lock --forcelock'
GNOME_LOCK='gnome-screensaver-command --lock'
XSCREEN_LOCK='xscreensaver-command -lock || xlock'
@ -22,13 +49,13 @@ elif ( ps -e | grep xdm >/dev/null 2>/dev/null ) ; then
eval $XSCREEN_LOCK 2>/dev/null && exit
fi
echo Could not decide what desktop manager you are using.
echo Trying fallback locking.
echo "Could not decide what desktop manager you are using."
echo "Trying fallback locking."
eval $KDE_LOCK 2>/dev/null && exit
gnome-screensaver >/dev/null 2>/dev/null
eval $GNOME_LOCK 2>/dev/null
xscreensaver & >/dev/null 2>/dev/null
eval $XSCREEN_LOCK 2>/dev/null && exit
echo Could not lock your screen.
echo "Could not lock your screen."
exit 1

View file

@ -21,7 +21,7 @@
fun! <SID>IsCommentStart(line)
" &comments isn't reliable
if &ft == "c" || &ft == "cpp"
if &ft == "c" || &ft == "cpp" || &ft == "java" || &ft == "scala"
return -1 != match(a:line, '/\*')
elseif &ft == "perl" " catch POD in Perl
return -1 != match(a:line, '^=\w')
@ -31,7 +31,7 @@ fun! <SID>IsCommentStart(line)
endfun
fun! <SID>IsCommentEnd(line)
if &ft == "c" || &ft == "cpp"
if &ft == "c" || &ft == "cpp" || &ft == "java" || &ft == "scala"
return -1 != match(a:line, '\*/')
elseif &ft == "perl" " catch POD
return -1 != match(a:line, '^=cut')

11
vimrc
View file

@ -160,9 +160,6 @@ if has('mouse')
endif
if has('autocmd')
" unhighlight search when idle
autocmd CursorHold * nohls | redraw
" always refresh syntax from the start
autocmd BufEnter * syntax sync fromstart
@ -248,8 +245,11 @@ map Y y$
vmap K k
" :W and :Q are annoying
cmap W w
cmap Q q
command! -nargs=0 -bang X x<bang>
command! -nargs=0 -bang Q q<bang>
command! -nargs=0 -bang W w<bang>
command! -nargs=0 -bang WQ wq<bang>
command! -nargs=0 -bang Wq wq<bang>
" just continue
nmap K K<cr>
@ -257,6 +257,7 @@ nmap K K<cr>
" Toggle numbers with F12
nmap <silent> <F12> :silent set number!<CR>
imap <silent> <F12> <C-O>:silent set number!<CR>
noremap <silent> <F4> :set hls!<CR>
" Don't force column 0 for #
inoremap # X<BS>#

View file

@ -42,4 +42,5 @@ main = do
`additionalKeysP`
[ ("M-p", shellPrompt defaultXPConfig { position = Top })
, ("M-b", sendMessage ToggleStruts)
, ("M-S-l", spawn "~/bin/lock")
]

View file

@ -1,6 +1,9 @@
# completion menu
zstyle ':completion:*' menu select=1
# change the order up
zstyle ':completion:*:(cd|mv|cp):*' tag-order local-directories directory-stack named-directories path-directories
# neat-o new features
zstyle ':completion:*' completer _expand _complete _prefix _correct _match _approximate

View file

@ -58,7 +58,12 @@ function title
# Use this for GNU Screen:
print -nR $'\ek'$2$'\e'"\\"
;;
xterm*|*rxvt*|cygwin|interix|Eterm|mlterm|kterm|aterm|putty*)
interix)
# Use this for interix as "2" makes it upset
shift
print -nR $'\e]0;'$@$'\a'
;;
xterm*|*rxvt*|cygwin|Eterm|mlterm|kterm|aterm|putty*)
# Use this one instead for everybody else:
shift
print -nR $'\e]1;'$@$'\a'

View file

@ -1,6 +1,6 @@
# utility.sh
# Miscellaneous Utility Functions
zstyle ':completion:*:*:extract:*' file-patterns '*.(tar|tar.gz|tgz|tar.Z|tar.bz2|tbz2|zip|ZIP|jar|gz|Z|z|bz2|rar|RAR|LHa|LHA|lha|lzh|a|deb|tar.lzma|lzma):Compressed\ Files *(-/):directories'
zstyle ':completion:*:*:extract:*' file-patterns '*.(tar|tar.gz|tgz|tar.Z|tar.bz2|tbz2|zip|ZIP|jar|gz|Z|z|bz2|rar|RAR|LHa|LHA|lha|lzh|a|deb|tar.lzma|lzma|7z):Compressed\ Files *(-/):directories'
# vim: set ft=sh ts=3 sw=3 et: