From 05bdddfae609c92cbfd77d1b2b808b48c8060b4b Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 26 Nov 2008 07:53:43 -0500 Subject: [PATCH] Began versioning my dotfiles. Excellent implementation idea from Steve Kemp. http://dotfiles.repository.steve.org.uk/ --- Makefile | 33 +++++++ _Xmodmap | 76 +++++++++++++++ _bash_logout | 7 ++ _bash_profile | 23 +++++ _bashrc | 158 +++++++++++++++++++++++++++++++ _emacs | 99 +++++++++++++++++++ _emacs-admin | 54 +++++++++++ _emacs.d/load/querty.el | 204 ++++++++++++++++++++++++++++++++++++++++ _gitconfig | 5 + _gnuplot | 3 + _hgrc | 3 + _screenrc | 21 +++++ _xinitrc | 57 +++++++++++ diff.sh | 43 +++++++++ fixup.sh | 91 ++++++++++++++++++ 15 files changed, 877 insertions(+) create mode 100644 Makefile create mode 100644 _Xmodmap create mode 100644 _bash_logout create mode 100644 _bash_profile create mode 100644 _bashrc create mode 100644 _emacs create mode 100644 _emacs-admin create mode 100644 _emacs.d/load/querty.el create mode 100644 _gitconfig create mode 100644 _gnuplot create mode 100644 _hgrc create mode 100644 _screenrc create mode 100644 _xinitrc create mode 100755 diff.sh create mode 100755 fixup.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c088e01 --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +# ~/.dotfiles/Makefile +# +# all: +# Link all the files we have in this directory into the parent. +# +# clean: +# Clean editted files. +# +# Original by Steve Kemp (http://www.steve.org.uk) + +all: fixup + +clean: + find . -name '*~' -exec rm -f \{\} \; + find . -name '.#*' -exec rm -f \{\} \; + +diff: + git diff + +fixup: + ./fixup.sh + +update: + git pull + +merge: + ./merge.sh + +override: + ./fixup -f + +localdiff: + ./diff.sh diff --git a/_Xmodmap b/_Xmodmap new file mode 100644 index 0000000..9b96b21 --- /dev/null +++ b/_Xmodmap @@ -0,0 +1,76 @@ +! .xmodmap bind X characters to keys +! Following http://www.in-ulm.de/~mascheck/X11/input8bit.html +! +keycode 113 = Mode_switch +clear mod3 +add mod3 = Mode_switch + +! U208N is subscript N +keycode 10 = 1 exclam U2081 onehalf +keycode 11 = 2 at U2082 twosuperior +keycode 12 = 3 numbersign U2083 threesuperior +keycode 13 = 4 dollar U2084 foursuperior +keycode 14 = 5 percent +! U207B is superscript minus +! U00B9 is superscript one +keycode 15 = 6 asciicircum U207B U00B9 +keycode 16 = 7 ampersand +! U2219 is the bullet operator +keycode 17 = 8 asterisk infinity U2219 +! U2248 is almost equal (asymptotic) +keycode 18 = 9 parenleft U2248 +keycode 19 = 0 parenright emptyset +! U2213 is minus-or-plus +keycode 20 = minus underscore notsign U2213 +keycode 21 = equal plus notequal plusminus +! U221A is the square root sign (radical) +! U211A is the set of all rationals +keycode 24 = q Q radical U211A +! U1E84 is LATIN CAPITAL LETTER W WITH DIAERESIS +keycode 25 = w W Greek_omega U1E84 +! U2203 is there exists +keycode 26 = e E Greek_epsilon U2203 +! U211D is the set of reals numbers +keycode 27 = r R Greek_rho U211D +keycode 28 = t T Greek_tau Greek_theta +keycode 29 = y Y Greek_psi Greek_PSI +keycode 30 = u U Greek_eta +! U222C is a double integral +keycode 31 = i I integral U222C +keycode 32 = o O elementof Greek_OMEGA +keycode 33 = p P Greek_pi Greek_PI +keycode 34 = bracketleft braceleft leftsinglequotemark leftdoublequotemark +keycode 35 = bracketright braceright rightsinglequotemark rightdoublequotemark +! U2200 is for all +keycode 38 = a A Greek_alpha U2200 +keycode 39 = s S Greek_sigma Greek_SIGMA +! U2202 is partial differential +! (for some reason the keysym partialderivative wasn't working on my eeepc). +keycode 40 = d D U2202 Greek_delta +keycode 41 = f F function Greek_phi +keycode 42 = g G Greek_gamma Greek_GAMMA +keycode 43 = h H degree +keycode 44 = j J +keycode 45 = k K Greek_kappa +keycode 46 = l L Greek_lambda +! U2026 is an ellipsis +keycode 47 = semicolon colon U2026 +keycode 48 = apostrophe quotedbl +! U223C is the tilde operator +keycode 49 = grave asciitilde U223C approximate +keycode 50 = Shift_L +! U2261 is identical to (three-bar equals) +keycode 51 = backslash bar U2261 +! U2115 is the set of all natural numbers, U2124 is the set of integers +keycode 52 = z Z U2115 U2124 +keycode 53 = x X Greek_chi Greek_xi +keycode 54 = c C Greek_chi +keycode 55 = v V Greek_nu +keycode 56 = b B Greek_beta +keycode 57 = n N Greek_DELTA nabla +keycode 58 = m M mu +! includedin = 'subset of' +! includes = 'superset of' +keycode 59 = comma less includedin guillemotleft +keycode 60 = period greater includes guillemotright +keycode 61 = slash question rightarrow questiondown diff --git a/_bash_logout b/_bash_logout new file mode 100644 index 0000000..de4f5f7 --- /dev/null +++ b/_bash_logout @@ -0,0 +1,7 @@ +# ~/.bash_logout: executed by bash(1) when login shell exits. + +# when leaving the console clear the screen to increase privacy + +if [ "$SHLVL" = 1 ]; then + [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q +fi diff --git a/_bash_profile b/_bash_profile new file mode 100644 index 0000000..a2b57d1 --- /dev/null +++ b/_bash_profile @@ -0,0 +1,23 @@ +# ~/.bash_profile: executed by bash(1) for login shells. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# the default umask is set in /etc/login.defs +#umask 022 + +# include .bashrc if it exists +if [ -f ~/.bashrc ]; then + . ~/.bashrc +fi + +# set PATH so it includes user's private bin if it exists +if [ -d ~/bin ]; then + PATH=~/bin:"${PATH}" +fi + +#exec screen -R # automatically attach to first detached session if it exists + +# print my calendar if I've configured it +if [ -e ~/.calendar ]; then + calendar +fi diff --git a/_bashrc b/_bashrc new file mode 100644 index 0000000..550c9cc --- /dev/null +++ b/_bashrc @@ -0,0 +1,158 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +if [ -f /etc/bashrc ]; then + . /etc/bashrc +fi + +# If not running interactively, don't do anything +[ -z "$PS1" ] && return + +# don't put duplicate lines in the history. See bash(1) for more options +export HISTCONTROL=ignoredups +# ... and ignore same sucessive entries. +export HISTCONTROL=ignoreboth + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + # \[\033[XXm\] sets the color. XX = 00:default, 31:red, 33:yellow + PS1='${debian_chroot:+($debian_chroot)}\[\033[31m\]\u@\h\[\033[00m\]:\[\033[33m\]\W\[\033[00m\]\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\W\$ ' +fi +unset color_prompt force_color_prompt colorA colorB + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"' + ;; +*) + ;; +esac + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +#if [ -f ~/.bash_aliases ]; then +# . ~/.bash_aliases +#fi + +# Make file system utilities friendlier +alias rm='rm -iv' +alias rmdir='rmdir -v' +alias cp='cp -iv' +alias mv='mv -iv' +alias less='less -R' + +# Configure useful programs +alias lp='/usr/bin/lp -o sides=two-sided-long-edge -o media=letter -o cpi=16 -o lpi=10' +alias lpb='/usr/bin/lp -o sides=two-sided-long-edge -o media=letter -o cpi=12 -o lpi=6' +alias lpi='/usr/bin/lp -o fitplot' +alias emacs='emacs' +alias xterm='xterm -fg white -bg black' +alias w3mg='w3m http://www.google.com' +alias calendar='calendar -A28' +alias acroread='acroread -geometry 1270x950' +alias graph='graph -TX -C' +alias snownews='snownews -u' + +# Alias useful one-liners & common commands +alias findex='find . -perm -u+x ! -type d' +alias sortdat='find . -printf "%TY-%Tm-%Td+%TH:%TM:%TS %h/%f\n" | sort -n' +alias sortdirdat='find . -type d -printf "%TY-%Tm-%Td+%TH:%TM:%TS %h/%f\n" | sort -n' +alias sshy='ssh wking@129.25.24.53' +alias ssha='ssh sysadmin@129.25.7.55' +alias sshxa='ssh -X sysadmin@129.25.7.55' + +# enable color support of ls and also add handy aliases +if [ "$TERM" != "dumb" ] && [ -x /usr/bin/dircolors ]; then + eval "`dircolors -b`" + alias ls='ls --color=auto' + #alias dir='ls --color=auto --format=vertical' + #alias vdir='ls --color=auto --format=long' + + alias grep='grep --color=auto' + #alias fgrep='fgrep --color=auto' + #alias egrep='egrep --color=auto' +fi + +# some more ls aliases +alias ll='ls -l' +alias la='ls -A' +alias l='ls -CF' + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if [ -f /etc/bash_completion ]; then + . /etc/bash_completion +fi + +# define default programs +export EDITOR="emacs -nw" +export PAGER="less" + +# personalize path +export PATH=/home/wking/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:~/script:~/script/python:~/script/lab:~/bin +export LD_LIBRARY_PATH=~/lib + +# personalize latex path +export TEXINPUTS=":.:$HOME/projects/latex/common/" + +# personalize python path +export PYTHONPATH=":.:$HOME/lib/python:$HOME/lib/python2.5/site-packages:$HOME/.python" + +# append personal manpages to manpath +export MANPATH=":$HOME/share/man" + +# colorize file listings (di was 34 (blue), swapped with 33 (yellow)) +export LS_COLORS='no=00:fi=00:di=00;33:ln=00;36:pi=40;34:so=00;35:bd=40;34;01:cd=40;34;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:' + +# turn off terminal beep in X +if [ $TERM == "xterm" ] && [ -n "$DISPLAY" ] + then + xset b off +fi + +# turn of terminal beeps in the console, unless connecting via SSH +if [ -z "$SSH_CLIENT" ]; then + if [ ! -z "$TERM" ]; then + setterm -blength 0 + fi +fi diff --git a/_emacs b/_emacs new file mode 100644 index 0000000..34bc6cf --- /dev/null +++ b/_emacs @@ -0,0 +1,99 @@ +;;;; Trevor's sysadmin .emacs file +; started Sept 13, 2006 +; The goal is to set up emacs for personal usage. +; See .emacs-admin for a more general setup + +; Lisp comments begin with a ";" + +;------------------------------------------------------------------------------ +; Make operating on buffers more convienient + +(setq inhibit-startup-message t) ; no splash screen +(fset 'yes-or-no-p 'y-or-n-p) ; use y or n instead of yes or n +(setq require-final-newline t) ; always end a file with a newline +(setq backup-by-copying-when-mismatch t) ; preserve file's owner and group +(when (fboundp 'global-font-lock-mode) ; turn on font-lock mode + (global-font-lock-mode t)) +(setq transient-mark-mode t) ; enable visual feedback on selections +(global-set-key "\C-xg" 'goto-line) ; bind the goto-line function + +; Make scripts executable on Save (saves having to do the chmod every time) +;(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) + +;------------------------------------------------------------------------------ +; Set up a more organized version control +; +; Backups are saved to ~/.backup, and autosaves to ~/.autosave If +; ~/.backup doesn't exist it is created. If ~/.autosace doesn't exist +; it is created, the standard autosave procedure is followed. +; +; following J.T. Halbert at http://www.math.umd.edu/~halbert/dotemacs.html +; and the Emacs manual at +; http://www.gnu.org/software/emacs/manual/html_node/emacs/Backup-Names.html + +(setq backup-directory-alist (quote ((".*" . "~/.backup")))) +(defconst use-backup-dir t) ; Use backup directory + +; redefining the make-auto-save-file-name function in order to get +; autosave files sent to a single directory. Note that this function +; looks first to determine if you have a ~/.autosave/ directory. If +; you do not it proceeds with the standard auto-save procedure. +(defun make-auto-save-file-name () + "Return file name to use for auto-saves of current buffer.." + (if buffer-file-name + (if (file-exists-p "~/.autosave/") + (concat (expand-file-name "~/.autosave/") "#" + (replace-regexp-in-string "/" "!" buffer-file-name) + "#") + (concat + (file-name-directory buffer-file-name) + "#" + (file-name-nondirectory buffer-file-name) + "#")) + (expand-file-name + (concat "#%" (buffer-name) "#")))) + +;------------------------------------------------------------------------------ +; Personal tweaks + +; Setup bundled EasyPG (encryption with gpg) +; from minor emacs wizardry +; http://emacs.wordpress.com/2008/07/18/keeping-your-secrets-secret/ +(require 'epa) +;(epa-file-enable) +; end EasyPG + +; setup org-mode +; http://orgmode.org/manual/Activation.html +; The following lines are always needed. Choose your own keys. +(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode)) +(global-set-key "\C-cl" 'org-store-link) +(global-set-key "\C-ca" 'org-agenda) +(global-set-key "\C-cb" 'org-iswitchb) + +(setq browse-url-browser-function 'browse-url-firefox) ; loki hack + +(defun org-time-stamp-now () + "Insert the current timestamp in org-mode, without recourse to the calendar." + (interactive) + (org-insert-time-stamp (current-time) 'with-hm 'inactive)) +(global-set-key "\C-cn" 'org-time-stamp-now) +; end org-mode + +; Emacs Load Path +;(setq load-path (cons "~/.emacs.d/load" load-path)) +; Load querty.el, for switching keyboard mappings. +;(load "querty.el") + +;(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. +; '(safe-local-variable-values (quote ((noweb-code-mode . c-mode))))) +;(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. +; ) diff --git a/_emacs-admin b/_emacs-admin new file mode 100644 index 0000000..1e7e20a --- /dev/null +++ b/_emacs-admin @@ -0,0 +1,54 @@ +;;;; Trevor's sysadmin .emacs file +; started Sept 12, 2008 +; The goal is to set up emacs for general usage & organization, without +; too much Trevor-specific personalization. An inheritable .emacs file ;). + +; Lisp comments begin with a ";" + +;------------------------------------------------------------------------------ +; Make operating on buffers more convienient + +(setq inhibit-startup-message t) ; no splash screen +(fset 'yes-or-no-p 'y-or-n-p) ; use y or n instead of yes or n +(setq require-final-newline t) ; always end a file with a newline +(setq backup-by-copying-when-mismatch t) ; preserve file's owner and group +(when (fboundp 'global-font-lock-mode) ; turn on font-lock mode + (global-font-lock-mode t)) +(setq transient-mark-mode t) ; enable visual feedback on selections +(global-set-key "\C-xg" 'goto-line) ; bind the goto-line function + +; Make scripts executable on Save (saves having to do the chmod every time) +(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) + +;------------------------------------------------------------------------------ +; Set up a more organized version control +; +; Backups are saved to ~/.backup, and autosaves to ~/.autosave If +; ~/.backup doesn't exist it is created. If ~/.autosace doesn't exist +; it is created, the standard autosave procedure is followed. +; +; following J.T. Halbert at http://www.math.umd.edu/~halbert/dotemacs.html +; and the Emacs manual at +; http://www.gnu.org/software/emacs/manual/html_node/emacs/Backup-Names.html + +(setq backup-directory-alist (quote ((".*" . "~/.backup")))) +(defconst use-backup-dir t) ; Use backup directory + +; redefining the make-auto-save-file-name function in order to get +; autosave files sent to a single directory. Note that this function +; looks first to determine if you have a ~/.autosaves/ directory. If +; you do not it proceeds with the standard auto-save procedure. +(defun make-auto-save-file-name () + "Return file name to use for auto-saves of current buffer.." + (if buffer-file-name + (if (file-exists-p "~/.autosaves/") + (concat (expand-file-name "~/.autosaves/") "#" + (replace-regexp-in-string "/" "!" buffer-file-name) + "#") + (concat + (file-name-directory buffer-file-name) + "#" + (file-name-nondirectory buffer-file-name) + "#")) + (expand-file-name + (concat "#%" (buffer-name) "#")))) diff --git a/_emacs.d/load/querty.el b/_emacs.d/load/querty.el new file mode 100644 index 0000000..f908565 --- /dev/null +++ b/_emacs.d/load/querty.el @@ -0,0 +1,204 @@ +;------------------------------------------------------------; +; qwerty.el +; +; For people who are used to more efficient keyboard layouts. +; +; version 1.1 +; +; * Now includes `M-x dvorak' to switch to a Dvorak keyboard layout. +; +; Written by Neil Jerram , +; Monday 14 December 1992. +; Copyright (C) 1993 Neil Jerram. + +;;; This program is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 1, or (at your option) +;;; any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; The GNU General Public License is available by anonymous ftp from +;;; prep.ai.mit.edu in pub/gnu/COPYING. Alternately, you can write to +;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, +;;; USA. + +; This trivial piece of Emacs Lisp was inspired by Stephen Jay Gould's +; essay "The Panda's Thumb of Technology" in his book "Bully for +; Brontosaurus". In this essay, he explains how the intrinsically +; inefficient QWERTY keyboard layout (all the most common keys are in +; weak finger positions) is a hangover from the days when typists +; needed to be slowed down so that the (hidden) mechanics of the +; typewriter didn't get jammed. Maybe if enough people come to use +; Emacs and realise the advantages of different keyboard layouts, the +; days of QWERTY could be numbered. + +; EXAMPLE: French keyboards often have A and Q swapped around +; (in comparison with English keyboards). So a French person +; unused to the English layout (and vice-versa) could re-program +; his/her keyboard by typing `M-x anti-qwerty RET aq RET qa RET'. + +; I would be very interested to hear about alternative keyboard +; layouts that anyone may use, preferably with their definitions +; with respect to the usual QWERTY layout. + +; Public functions + +(defun qwerty () + + "Qwerty keyboard layout." + + (interactive) + (setq keyboard-translate-table nil) + (message "Default keyboard restored.")) + +(defun dvorak () + + "Dvorak keyboard layout: +------------------------------------------------------------------------- +| Esc| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | [ | ] | <- | +------------------------------------------------------------------------- +| Tab | / | , | . | p | y | f | g | c | r | l | ; | = | | +------------------------------------------------------------------- | | +| Ctrl | a | o | e | u | i | d | h | t | n | s | - | <- | +------------------------------------------------------------------------- +| Shift | ' | q | j | k | x | b | m | w | v | z | Shift | +--------------------------------------------------------------------- +" + (interactive) + (anti-qwerty "/,.pyfgcrl;=aoeuidhtns-'qjkxbmwvz?<>PYFGCRL:+AOEUIDHTNS_QJKXBMWVZ[]{}\"" + "qwertyuiop[]asdfghjkl;'zxcvbnm,./QWERTYUIOP{}ASDFGHJKL:\"XCVBNM<>?-=_+Z")) + +(defun anti-qwerty (old new &optional ctrl unsafe) + + "Remaps the keyboard according to OLD and NEW strings. OLD should +include all the keys that the user wants to change, typed in the +default keyboard system (usually qwerty). NEW is what the user would +like to be typing in order to produce the contents of OLD on the +screen. + + The third (optional prefix) argument CTRL, if non-nil, means that +any transformations on letters that occur should be duplicated in the +related control characters: in other words, if `a' becomes `z', then +`C-a' should become `C-z'. + + Before implementing any changes the function first checks that the +mapping implied by OLD and NEW is one to one, in other words no two +keyboard keys may map to the same character and a single keyboard key +may not be given two different mappings. If any such errors are +discovered in the mapping, no changes to the keyboard are made. + + As an additional safeguard, this function binds the keystroke `M-\' +to the restoring function `qwerty'. If the fourth (optional) argument +UNSAFE is non-nil, this binding is suppressed." + + (interactive "sQWERTY expression: \nsNew system expression: \nP") + (let ((o-n-map (if (qwerty-translation-safe-p old new) + 0 + (sit-for 1))) + (n-o-map (if (qwerty-translation-safe-p new old) + 0 + (sit-for 1))) + llp) + (if (and (numberp o-n-map) + (numberp n-o-map)) + (progn + (setq llp (and (letters-to-letters-p old new) + (letters-to-letters-p new old))) + (un-qwerty old new llp ctrl) + (or unsafe + (progn (global-set-key "\e\\" 'qwerty) + (local-unset-key "\e\\")) + t) + (message + (concat "Keyboard changed. " + (if unsafe + "Type `M-x qwerty' to restore default." + "Type `M-\\' or `M-x qwerty' to restore default.")))) + (error "! Expressions given are not a one to one mapping")))) + +; Private functions + +(defun un-qwerty (old new llp ctrl) + (let* ((the-table (make-string 128 0)) + (ml (min (length old) + (length new))) + (old (substring old 0 ml)) + (new (substring new 0 ml)) + (i 0) + co cn) + (while (< i ml) + (setq co (aref old i) + cn (aref new i)) + (if (and (< co 128) (< cn 128)); Reject Meta characters. + (if (= (aref the-table cn) 0); No unnecessary repeats. + (progn + (if (not llp) + (aset the-table cn co) + (aset the-table (upcase cn) (upcase co)) + (aset the-table (downcase cn) (downcase co))) + (setq co (- (upcase co) 64)) + (if (or (not ctrl) (not llp) (< co 0) (> co 31)) + nil + (aset the-table (- (upcase cn) 64) co))))) + (setq i (1+ i))) + (setq i 0) + (while (< i 128) + (if (= (aref the-table i) 0) + (aset the-table i i)) + (setq i (1+ i))) + (setq keyboard-translate-table the-table))) + +(defun qwerty-translation-safe-p (old new) + "Returns nil if the mapping from OLD to NEW is not one to one." + (let* ((mapping-length (min (length old) + (length new))) + (old (substring old 0 mapping-length)) + (new (substring new 0 mapping-length)) + (i 0) + (errors 0) + (case-fold-search nil) + j co cn match) + (while (< i mapping-length) + (setq co (aref old i) + cn (aref new i) + j (1+ i)) + (while (setq match + (string-match (regexp-quote (char-to-string co)) + (substring old j))) + (if (/= cn (aref (substring new j) match)) + (setq errors (1+ errors))) + (setq j (+ j match 1))) + (setq i (1+ i))) + (if (= errors 0) + t + (message "\"%s\" -> \"%s\" : %d %s" old new errors + (if (> errors 1) "errors" "error")) + nil))) + +(defun letters-to-letters-p (old new) + "Returns t if all letters in OLD are mapped to letters in NEW." + (let* ((mapping-length (min (length old) + (length new))) + (old (substring old 0 mapping-length)) + (new (substring new 0 mapping-length)) + (i 0) + (llp t) + (case-fold-search nil) + co cn) + (while (< i mapping-length) + (setq co (upcase (aref old i)) + cn (upcase (aref new i)) + j (1+ i)) + (and (>= co ?A) + (<= co ?Z) + (or (< cn ?A) + (> cn ?Z)) + (setq llp nil)) + (setq i (1+ i))) + llp)) + +;------------------------------------------------------------; diff --git a/_gitconfig b/_gitconfig new file mode 100644 index 0000000..406a05c --- /dev/null +++ b/_gitconfig @@ -0,0 +1,5 @@ +# .gitconfig a Git configuration file + +[user] + name = W. Trevor King + email = wking@drexel.edu diff --git a/_gnuplot b/_gnuplot new file mode 100644 index 0000000..6d1d01a --- /dev/null +++ b/_gnuplot @@ -0,0 +1,3 @@ +# .gnuplot a Gnuplot configuration file + +set terminal x11 diff --git a/_hgrc b/_hgrc new file mode 100644 index 0000000..6f9bad1 --- /dev/null +++ b/_hgrc @@ -0,0 +1,3 @@ +# .hgrc a Mercurial configuration file +[ui] +username = W. Trevor King diff --git a/_screenrc b/_screenrc new file mode 100644 index 0000000..067591e --- /dev/null +++ b/_screenrc @@ -0,0 +1,21 @@ +# .screenrc startup file for GNU Screen + + +# don't show the startup splash screen +startup_message off + +# we're not graphical +unsetenv DISPLAY + +# automatically detach on hangup. +autodetach on + +# These keybindings always annoy me (and Steve :p): xon/xoff. +# Remove them. +bind ^Q +bind q +bind ^S +bind s + +# If a window goes unresponsive, don't block the whole session waiting for it. +nonblock on diff --git a/_xinitrc b/_xinitrc new file mode 100644 index 0000000..751a502 --- /dev/null +++ b/_xinitrc @@ -0,0 +1,57 @@ +#!/bin/bash +# .xinitrc startup file for X + +#WM="gnome" +#WM="twm" +#WM="fluxbox" +WM="Find installed" + +# Set up keybindings +xmodmap .Xinitrc + +# xrdb -load $HOME/.Xresources + +if [ "$WM" == "Find installed" ] +then + for M in fluxbox gnome-session twm + do + PATH=`which $M` + if [ -n "$PATH" ] + then + if [ "$M" == "fluxbox" ] || [ "$M" == "twm" ; then + WM="$M" + elif [ "$M" == "gnome-session" ] + WM="gnome" + else + echo "No known windows manager installed" + exit + fi + fi + done +fi + +if [ "$WM" == "twm" ] # tabbed windows manager. Very simple. +then + # starts a clock, several terminals, and leaves the window manager running + # as the last application. Assuming that the window manager has been + # configured properly, the user then chooses the Exit menu item to + # shut down X. + xsetroot -solid darkgray & + xclock -g 50x50-0+0 -bw 0 & + xload -g 200x50-50+0 -bw 0 -bg black -fg white & + # alias xterm='xterm -bg black -fg white' + xterm -bg black -fg white -g 80x39+0+0 & + xterm -bg black -fg white -g 80x35+0-0 & + xterm -bg black -fg white -g 80x76-0+0 & + twm +elif [ "$WM" == "gnome" ] + then + # start dbus session for gnome power manager + eval `dbus-launch --auto-syntax` + xterm -bg black -fg white -g 80x39+0+0 & + gnome-session +elif [ "$WM" == "fluxbox" ] + then + xterm -bg black -fg white -g 80x39+0+0 & + fluxbox +fi diff --git a/diff.sh b/diff.sh new file mode 100755 index 0000000..d10dd1d --- /dev/null +++ b/diff.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# +# Print diffs for each _FILE / ~/.FILE pair + + +# Create the diff between a pair of files +# +# handleFile( $file, $dotfile ) +# +# Parameters: +# file - The file we're processing '_foo' +# dotfile - The file it should be linked to in ~/, e.g. '.foo' +function handleFile( ) +{ + diff -ru $1 $2 +} + +# See if we can find any _files. +found=0 +for i in _*; do + if [ -e $i ]; then + found=`expr $found + 1` + fi +done + +# If we found none then exit +if [ "$found" -lt 1 ]; then + echo "WARNING: No files matching _* were found" + exit +fi + +# For each file in this directory. +for i in _*; do + # Create .dotfile version. + dotfile=.${i/_/} + + if [ ! -e ~/$dotfile ]; then + echo "~/$dotfile doesn't exist" + else + # run the diff + handleFile $i ~/$dotfile + fi +done diff --git a/fixup.sh b/fixup.sh new file mode 100755 index 0000000..ecbd726 --- /dev/null +++ b/fixup.sh @@ -0,0 +1,91 @@ +#!/bin/bash +# +# Link each _FILE in the current directory to ~/.FILE +# +# Originally by Steve Kemp (http://www.steve.org.uk/) + +FORCE="no" # If "yes", overwrite existing .files + +# parse options +while [ -n "$1" ]; do + case "$1" in + "-f") + FORCE="yes" + ;; + esac + shift +done + +# Create the symbolic link. +# +# handleFile( $file, $dotfile ) +# +# Parameters: +# file - The file we're processing '_foo' +# dotfile - The file it should be linked to in ~/, e.g. '.foo' +function handleFile( ) +{ + file=$1 + dotfile=$2 + ln -s `pwd`/$file ~/$dotfile +} + +# See if we can find any _files. +found=0 +for i in _*; do + if [ -e $i ]; then + found=`expr $found + 1` + fi +done + +# If we found none then exit +if [ "$found" -lt 1 ]; then + echo "WARNING: No files matching _* were found" + exit +fi + +# For each file in this directory. +for i in _*; do + # Create .dotfile version. + dotfile=.${i/_/} + + # If the file/directory exists and we're overriding it, remove it now + if [ -e ~/$dotfile ] && [ $FORCE == "yes" ]; then + rm -rvf ~/$dotfile + fi + + # If this is a file. + if [ -f $i ]; then + + # If it is a symlink, then remove it. + if [ -h ~/$dotfile ]; then + # Remove the old link, and create a new one. + rm ~/$dotfile + fi + + # It is a normal file. + if [ -e ~/$dotfile ]; then + echo "~/$dotfile exists - ignoring it." + else + # File doesn't exist, create the link. + handleFile $i $dotfile + fi + else + # The file _foo is a directory. + + # If that directory doesn't exist in ~/ then create it. + if [ ! -d ~/$dotfile ]; then + echo "Creating new directory in ~"; + mkdir ~/$dotfile + fi + + # Now link all non-linked files up. + for s in $i/*; do + file=`basename $s` + + if [ ! -h ~/$dotfile/$file ]; then + ln -s `pwd`/$s ~/$dotfile/$file + fi + done + fi +done -- 2.26.2