#!/bin/sh if [ -z "$1" ] ; then echo "usage: copyenv " echo "SSHPORT=1234 set remote ssh port (default 22)" exit 1 fi TMP=/tmp/$$ if [ -z "$SSHPORT" ] then SSHPORT=22 fi ####################################################################### if [ -f ~/.ssh/id_rsa.pub ] then PUB=~/.ssh/id_rsa.pub elif [ -f ~/.ssh/id_dsa.pub ] then PUB=~/.ssh/id_dsa.pub fi if [ -f $PUB ] ; then P=`cat $PUB` ssh -p $SSHPORT $1 "mkdir ~/.ssh; chmod 700 ~/.ssh; echo '$P' >> ~/.ssh/authorized_keys" || exit 1 fi ####################################################################### scp -P $SSHPORT $0 $1:copyenv || exit 1 ####################################################################### cat > $TMP <<'EOF' ; emacs configuration from Dirk Jagdmann ; http://cubic.org/~doj/emacs ;;;;This sets garbage collection to hundred times of the default. ;;;;Supposedly significantly speeds up startup time. (Seems to work ;;;;for me, but my computer is pretty modern. Disable if you are on ;;;;anything less than 1 ghz). (setq gc-cons-threshold 5000000) (global-font-lock-mode t) (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. '(auto-compression-mode t nil (jka-compr)) '(browse-url-browser-function (quote browse-url-firefox)) '(case-fold-search t) '(column-number-mode t) '(compile-auto-highlight t) '(current-language-environment "ASCII") '(display-time-24hr-format t) '(display-time-mode t nil (time)) '(display-time-use-mail-icon t) '(ecb-layout-always-operate-in-edit-window (quote (delete-window delete-other-windows split-window-horizontally split-window-vertically switch-to-buffer))) '(ecb-layout-name "left6") '(ecb-layout-nr 6) '(ecb-options-version "2.27") '(ecb-tree-indent 1) '(ecb-truncate-lines nil) '(ecb-truncate-long-names t) '(ecb-windows-width 0.25) '(inhibit-startup-screen t) '(inhibit-splash-screen t) '(inhibit-startup-message t) '(initial-scratch-message nil) '(line-number-mode t) '(mouse-wheel-follow-mouse t) '(mouse-wheel-mode t nil (mwheel)) '(mouse-yank-at-point t) '(org-log-done t) '(paren-mode (quote paren) nil (paren)) '(query-user-mail-address nil) '(save-place t nil (saveplace)) '(show-paren-mode t nil (paren)) '(show-trailing-whitespace t) '(speedbar-navigating-speed 2 t) '(speedbar-update-speed 2 t) '(sql-product (quote postgres)) '(tab-width 8) '(tool-bar-mode nil nil (tool-bar)) '(toolbar-captioned-p nil) '(toolbar-visible-p nil) '(transient-mark-mode t) '(truncate-partial-width-windows nil) '(uniquify-buffer-name-style nil nil (uniquify)) '(user-full-name "Dirk Jagdmann") '(user-mail-address "doj@cubic.org")) (setq user-company-name "Cubic") ; (scroll-bar-mode -1) ; disable scroll-bars (setq kill-whole-line t) ; will make "Ctrl-k" kills an entire line if the cursor is at the beginning of line ; (global-set-key [(meta g)] 'goto-line) (global-set-key [f1] (lambda () (interactive) (manual-entry (current-word)))) (global-set-key [(control f1)] 'ecb-activate) (global-set-key [(control shift f1)] 'ecb-deactivate) (global-set-key [(meta f1)] 'font-lock-mode) (global-set-key [f2] 'revert-buffer) (global-set-key [(control f2)] 'delete-trailing-whitespace) (global-set-key [f3] 'repeat-complex-command) (global-set-key [f4] 'add-change-log-entry) (global-set-key [f5] 'replace-string) (global-set-key [(control f5)] 'query-replace) (global-set-key [f6] 'replace-regexp) (global-set-key [(control f6)] 'query-replace-regexp) (global-set-key [f9] 'compile) (global-set-key [(control f9)] 'kill-compilation) (global-set-key [f10] 'next-error) (global-set-key [(shift f10)] 'flymake-goto-next-error) (global-set-key [(shift meta f10)] 'flymake-goto-prev-error) (global-set-key [(meta f10)] 'flymake-display-err-menu-for-current-line) (global-set-key [(control f10)] 'sort-lines) (global-set-key [f11] 'fill-region) (global-set-key [(control f11)] 'hide-ifdef-block) (global-set-key [(control shift f11)] 'show-ifdef-block) (global-set-key [f12] 'hs-show-block) (global-set-key [(control f12)] 'hs-hide-block) (global-set-key [(shift f12)] 'hs-show-all) (global-set-key [(control shift f12)] 'hs-hide-all) (global-set-key [Scroll_Lock] 'scroll-lock-mode) ; A wheel mouse that doesn't beep, unlike mwheel-install (defun scroll-me-up () (interactive) (scroll-up 20)) (defun scroll-me-down () (interactive) (scroll-down 20)) (defun scroll-me-up-a-bit () (interactive) (scroll-up 5)) (defun scroll-me-down-a-bit () (interactive) (scroll-down 5)) (define-key global-map [(button4)] 'scroll-me-down) (define-key global-map [(button5)] 'scroll-me-up) (define-key global-map [(shift button4)] 'scroll-me-down-a-bit) (define-key global-map [(shift button5)] 'scroll-me-up-a-bit) ; alternative buffer window (require 'bs) (global-set-key "\C-x\C-b" 'bs-show) ; use aspell instead of ispell (setq-default ispell-program-name "aspell") ; start emacs in server mode (add-hook 'after-init-hook 'server-start) ; provide command 'uncomment-region' (defun uncomment-region (beg end) "Like `comment-region' invoked with a C-u prefix arg." (interactive "r") (comment-region beg end -1)) ; enable auto compression mode (auto-compression-mode 1) ; make scripts executable upon saving (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) ;; Make all yes/no prompts into y/n prompts (fset 'yes-or-no-p 'y-or-n-p) ;;; some code stolen from KDE emacs script ; Creates the ifndef/define/endif statements necessary for a header file (defun header-protection () (interactive) (let ((f (buffer-file-name))) (if (string-match "^.*/" f) (setq f (replace-match "" t t f))) (while (string-match "\\." f) (setq f (replace-match "__" t t f))) (save-excursion (goto-char (point-min)) (insert "#ifndef " (upcase f) "\n#define " (upcase f) "\n\n") (goto-char (point-max)) (insert "\n#endif\n") ) ) ) (defun insert-c-skeleton () (interactive) (insert "/* Copyright (c) ") (insert (format-time-string "%Y")) (insert (format " %s <%s> */\n\n" user-full-name user-mail-address)) (insert "#include \n\n") (insert "int main(int argc, char **argv)\n{\n\n return 0;\n}\n") (previous-line) (previous-line) (previous-line) ) (defun insert-select-skeleton () (interactive) (insert "/* #include */\n") (insert "int __maxfd__=-1;\n") (insert "fd_set rfds;\n") (insert "FD_ZERO(&rfds);\n") (insert "#define SET_FD(fd) do { FD_SET(fd, &rfds); if(fd > __maxfd__) __maxfd__=fd; } while(0)\n") (insert "\n") (insert "#undef SET_FD\n") (insert "struct timeval tv;\n") (insert "tv.tv_sec = 1;\n") (insert "tv.tv_usec = 0;\n") (insert "\n") (insert "const int __s__ = select(__maxfd__+1, &rfds, NULL, NULL, &tv);\n") (insert "if(__s__ < 0)\n") (insert " {\n") (insert " perror("select()");\n") (insert " }\n") (insert "else if(__s__ == 0)\n") (insert " {\n") (insert " /* timeout */\n") (insert " }\n") (insert "else if(FD_ISSET(fd, &rfds))\n") (insert " {\n") (insert " }\n") ) (defun insert-trigger-skeleton () (interactive) (insert "CREATE OR REPLACE FUNCTION a()\n") (insert "RETURNS trigger\n") (insert "AS $BODY$\n") (insert " DECLARE\n") (insert " BEGIN\n") (insert " RETURN NEW;\n") (insert " END;\n") (insert "$BODY$ LANGUAGE plpgsql;\n") (insert "\n") (insert "CREATE TRIGGER a\n") (insert "BEFORE INSERT or UPDATE or DELETE ON \n") (insert "FOR EACH ROW EXECUTE PROCEDURE a();\n") ) ; add .pgc files to c++mode (autoload 'c++-mode "c++" "Major mode for C++ code." t) (setq auto-mode-alist (cons '("\.pgc$" . c++-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\.ipp$" . c++-mode) auto-mode-alist)) ; add wxWidgets stuff (require 'cc-mode) (add-to-list 'c++-font-lock-extra-types "\\bwx[A-Z][a-z][a-zA-Z]*?\\b") (defun c-wx-lineup-topmost-intro-cont (langelem) (save-excursion (beginning-of-line) (if (re-search-forward "EVT_" (line-end-position) t) 'c-basic-offset (c-lineup-topmost-intro-cont langelem)))) (setq c++-mode-hook (lambda () (c-set-offset 'topmost-intro-cont 'c-wx-lineup-topmost-intro-cont))) ; customize CPerl mode (defun doj-cperl-setup () (cperl-set-style "C++")) (add-hook 'cperl-mode-hook 'doj-cperl-setup) (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\|t\\)\\'" . cperl-mode)) (add-to-list 'interpreter-mode-alist '("env perl" . cperl-mode)) (defalias 'perl-mode 'cperl-mode) (defun insert-perl-skeleton () (interactive) (insert "#!/usr/bin/env perl\n# $Header: /home/doj/a/www/doj/copyenv,v 1.4 2011-03-20 23:40:35 doj Exp $\n# Copyright (c) ") (insert (format-time-string "%Y")) (insert (format " %s <%s>\n" user-full-name user-mail-address)) (insert "\n") (insert "while(<>)\n{\n chomp;\n\n print \"$_\\n\";\n}\n") (previous-line) (previous-line) (previous-line) ) ; from http://www.emacswiki.org/cgi-bin/wiki/ChangingEncodings (defun recode-region (start end &optional coding-system) "Replace the region with a recoded text." (interactive "r\n\zCoding System (utf-8): ") (setq coding-system (or coding-system 'utf-8)) (let ((buffer-read-only nil) (text (buffer-substring start end))) (delete-region start end) (insert (decode-coding-string (string-make-unibyte text) coding-system)))) ;;; buffer-charsets.el --- show usage of charsets in a buffer ;; Displays list of charsets used in current buffer. (require 'hi-lock) (defun charset-chars-regexp (charset) (let ((dim (charset-dimension charset)) (chars (charset-chars charset)) (plane (charset-iso-graphic-plane charset)) min max) (cond ((eq charset 'eight-bit-control) (setq min 128 max 159)) ((eq charset 'eight-bit-graphic) (setq min 160 max 255)) (t (if (= chars 94) (setq min 33 max 126) (setq min 32 max 127)) (or (= plane 0) (setq min (+ min 128) max (+ max 128))))) (if (= dim 1) (format "[%c-%c]" (make-char charset min) (make-char charset max)) (format "[%c-%c]" (make-char charset min min) (make-char charset max max))))) (defun buffer-charsets () (find-charset-region (point-min) (point-max))) (defun display-buffer-charsets () "Displays list of charsets used in current buffer" (interactive) (let ((charsets (buffer-charsets)) (curr-buf-name (current-buffer))) (with-output-to-temp-buffer "*Buffer Charsets*" (save-excursion (set-buffer standard-output) (insert (format "Buffer %s uses the following charsets:\n" curr-buf-name)) (while charsets (insert (symbol-name (car charsets))) (insert "\n") (setq charsets (cdr charsets))))))) (defun charset-alist (charset-list) (let ((l (charset-list)) charset-alist) (while l (setq charset-alist (cons (list (symbol-name (car l))) charset-alist)) (setq l (cdr l))) charset-alist)) (defun show-buffer-charset-characters (charset face) "Uses hi-lock-mode to highlight by face characters of charset." (interactive (let ((completion-ignore-case t)) (list (completing-read "Charset:" (charset-alist (buffer-charsets)) nil t nil nil) (hi-lock-read-face-name)))) (highlight-regexp (charset-chars-regexp (intern charset)) face)) (defun unhighlight-charset (charset) (interactive (let ((completion-ignore-case t)) (list (completing-read "Charset:" (charset-alist (buffer-charsets)) nil t nil nil)))) (unhighlight-regexp (charset-chars-regexp (intern charset)))) ;(define-key hi-lock-map "\C-xwc" 'show-buffer-charset-characters) ;(define-key hi-lock-map "\C-xwu" 'unhighlight-charset) ; po-mode (setq auto-mode-alist (cons '("\\.po\\'\\|\\.po\\." . po-mode) auto-mode-alist)) (autoload 'po-mode "po-mode" "Major mode for translators to edit PO files" t) ;(modify-coding-system-alist 'file "\\.po\\'\\|\\.po\\." 'po-find-file-coding-system) ;(autoload 'po-find-file-coding-system "po-mode") ;; set time to show in corner (setq display-time-day-and-date t) (display-time) ; cycle buffers with C-Tab, ignoring uninteresting ones ; ripped from http://www.dotemacs.de/dotfiles/KilianAFoth.emacs.html (defun backward-buffer () (interactive) "Switch to previously selected buffer." (let* ((list (cdr (buffer-list))) (buffer (car list))) (while (and (cdr list) (string-match "\\*" (buffer-name buffer))) (progn (setq list (cdr list)) (setq buffer (car list)))) (bury-buffer) (switch-to-buffer buffer))) (defun forward-buffer () (interactive) "Opposite of backward-buffer." (let* ((list (reverse (buffer-list))) (buffer (car list))) (while (and (cdr list) (string-match "\\*" (buffer-name buffer))) (progn (setq list (cdr list)) (setq buffer (car list)))) (switch-to-buffer buffer))) (global-set-key [(control tab)] 'backward-buffer) (global-set-key [(control shift tab)] 'forward-buffer) ; kill current buffer without confirmation ; ripped from http://www.dotemacs.de/dotfiles/DaveGallucci.emacs.html (defun kill-current-buffer () "Kill the current buffer, without confirmation." (interactive) (kill-buffer (current-buffer))) (global-set-key "\C-xk" 'kill-current-buffer) ;convert a buffer from dos ^M end of lines to unix end of lines (defun dos2unix () (interactive) (goto-char (point-min)) (while (search-forward "\r" nil t) (replace-match ""))) (defun turn-to-unix () (interactive) (set-buffer-file-coding-system 'iso-8859-1-unix)) (defun insert-time () (interactive) (insert (format-time-string "%Y-%m-%d"))) (defun insert-libpng-license () (interactive) (setq doj-startpos (point)) (insert "Copyright (c) ") (insert (format-time-string "%Y")) (insert (format " %s <%s>\n" user-full-name user-mail-address)) (insert "\n") (insert "This software is provided 'as-is', without any express or implied\n") (insert "warranty. In no event will the authors be held liable for any damages\n") (insert "arising from the use of this software.\n") (insert "\n") (insert "Permission is granted to anyone to use this software for any purpose,\n") (insert "including commercial applications, and to alter it and redistribute it\n") (insert "freely, subject to the following restrictions:\n") (insert "\n") (insert " 1. The origin of this software must not be misrepresented; you\n") (insert " must not claim that you wrote the original software. If you use\n") (insert " this software in a product, an acknowledgment in the product\n") (insert " documentation would be appreciated but is not required.\n") (insert "\n") (insert " 2. Altered source versions must be plainly marked as such, and\n") (insert " must not be misrepresented as being the original software.\n") (insert "\n") (insert " 3. This notice may not be removed or altered from any source\n") (insert " distribution.\n") (insert "\n") (insert "$Header: /home/doj/a/www/doj/copyenv,v 1.4 2011-03-20 23:40:35 doj Exp $\n") (setq doj-endpos (point)) (comment-region doj-startpos doj-endpos) ) (defun insert-zlib-license () (insert-libpng-license) ) (defun insert-gpl () (interactive) (setq doj-startpos (point)) (insert "Copyright (c) ") (insert (format-time-string "%Y")) (insert (format " %s <%s>\n" user-full-name user-mail-address)) (insert "\n") (insert "This program is free software; you can redistribute it and/or modify\n") (insert "it under the terms of the GNU General Public License as published by\n") (insert "the Free Software Foundation; either version 2 of the License, or\n") (insert "(at your option) any later version.\n") (insert "\n") (insert "This program is distributed in the hope that it will be useful,\n") (insert "but WITHOUT ANY WARRANTY; without even the implied warranty of\n") (insert "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n") (insert "GNU General Public License for more details.\n") (insert "\n") (insert "You should have received a copy of the GNU General Public License\n") (insert "along with this program; if not, write to the Free Software\n") (insert "Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n") (insert "\n") (insert "$Header: /home/doj/a/www/doj/copyenv,v 1.4 2011-03-20 23:40:35 doj Exp $\n") (setq doj-endpos (point)) (comment-region doj-startpos doj-endpos) ) (defun insert-ncn-license () (interactive) (setq doj-startpos (point)) (insert "########################################################################\n") (insert "# #\n") (insert "# Copyright (c) 2007..") (insert (format-time-string "%Y")) (insert " by NeoCatena Networks, Inc. #\n") (insert "# 440 N Wolfe Rd., Sunnyvale, CA 94085, USA #\n") (insert "# #\n") (insert "# Developer : Dirk Jagdmann (doj@neocatena.com) #\n") (insert "# Date : $Id: copyenv,v 1.4 2011-03-20 23:40:35 doj Exp $\n") (insert "# #\n") (insert "# This source file is proprietary property of NeoCatena Networks, Inc. #\n") (insert "# #\n") (insert "# All rights reserved. #\n") (insert "# #\n") (insert "########################################################################\n") (insert "\n") (setq doj-endpos (point)) (comment-region doj-startpos doj-endpos) ) (defun insert-bsd-license () (interactive) (setq doj-startpos (point)) (insert "Copyright (c) ") (insert (format-time-string "%Y")) (insert (format ", %s <%s>\n" user-full-name user-mail-address)) (insert "All rights reserved.\n") (insert "\n") (insert "Redistribution and use in source and binary forms, with or\n") (insert "without modification, are permitted provided that the following\n") (insert "conditions are met:\n") (insert "\n") (insert " * Redistributions of source code must retain the above copyright\n") (insert " notice, this list of conditions and the following disclaimer.\n") (insert " * Redistributions in binary form must reproduce the above\n") (insert " copyright notice, this list of conditions and the following\n") (insert " disclaimer in the documentation and/or other materials\n") (insert " provided with the distribution.\n") (insert " * Neither the name of ") (insert (format "%s" user-company-name)) (insert " nor the names of its\n") (insert " contributors may be used to endorse or promote products\n") (insert " derived from this software without specific prior written\n") (insert " permission.\n") (insert "\n") (insert "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n") (insert "\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n") (insert "LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n") (insert "A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n") (insert "HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n") (insert "SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n") (insert "LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n") (insert "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n") (insert "THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n") (insert "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n") (insert "OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n") (setq doj-endpos (point)) (comment-region doj-startpos doj-endpos) ) ; convert end-of-line style (defun set-buffer-eol-conversion (type) "Convert buffer to TYPE line endings. TYPE should be one of the symbols: unix, dos, mac." (let ((old-bfcs buffer-file-coding-system)) (set-buffer-file-coding-system (coding-system-change-eol-conversion (cond ((null buffer-file-coding-system) 'undecided) ((eq buffer-file-coding-system 'no-conversion) 'raw-text) (buffer-file-coding-system)) type)) (unless (eq old-bfcs buffer-file-coding-system) ;; Larry Smith: This may be necessary to remove ^Ms when going ;; from unix to dos. FJW: When else? (if (eq type 'dos) (decode-coding-region (point-min) (point-max) buffer-file-coding-system)) (message "Coding system changed from %s to %s." old-bfcs buffer-file-coding-system) ))) (defun set-buffer-eol-conversion-unix () "Convert buffer to UNIX line endings" (interactive "*") (set-buffer-eol-conversion 'unix)) (defun set-buffer-eol-conversion-dos () "Convert buffer to MS-DOS line endings" (interactive "*") (set-buffer-eol-conversion 'dos)) (defun set-buffer-eol-conversion-mac () "Convert buffer to Macintosh line endings" (interactive "*") (set-buffer-eol-conversion 'mac)) (define-key global-map (vector '(control x) '(control m) ?:) 'set-buffer-eol-conversion-unix) (define-key global-map (vector '(control x) '(control m) ?\\) 'set-buffer-eol-conversion-dos) (define-key global-map (vector '(control x) '(control m) ?/) 'set-buffer-eol-conversion-mac) ; http://www.emacswiki.org/cgi-bin/wiki/AsciiTable (defun ascii-table () "Display basic ASCII table (0 thru 128)." (interactive) (switch-to-buffer "*ASCII*") (erase-buffer) (save-excursion (let ((i -1)) (insert "ASCII characters 0 thru 127.\n\n") (insert " Hex Dec Char| Hex Dec Char| Hex Dec Char| Hex Dec Char\n") (while (< i 31) (insert (format "%4x %4d %4s | %4x %4d %4s | %4x %4d %4s | %4x %4d %4s\n" (setq i (+ 1 i)) i (single-key-description i) (setq i (+ 32 i)) i (single-key-description i) (setq i (+ 32 i)) i (single-key-description i) (setq i (+ 32 i)) i (single-key-description i))) (setq i (- i 96)))))) ; http://www.emacswiki.org/cgi-bin/wiki/ModeCompile ;; Helper for compilation. Close the compilation window if ;; there was no error at all. (defun compilation-exit-autoclose (status code msg) ;; If M-x compile exists with a 0 (when (and (eq status 'exit) (zerop code)) ;; then bury the *compilation* buffer, so that C-x b doesn't go there (bury-buffer) ;; and delete the *compilation* window (delete-window (get-buffer-window (get-buffer "*compilation*")))) ;; Always return the anticipated result of compilation-exit-message-function (cons msg code)) ;; Specify my function (maybe I should have done a lambda function) ;(setq compilation-exit-message-function 'compilation-exit-autoclose) ; javascript mode (require 'generic-x) (when (locate-library "javascript") (autoload 'javascript-mode "javascript" nil t) (add-to-list 'auto-mode-alist '("\\.js\\'" . javascript-mode)) (set-variable 'javascript-indent-level 2) ) ; reload the init file (defun reload-init-file () "Reload the .emacs file" ( interactive "*" ) (load-file "~/.emacs")) ; make TAGS (defun tags-generate-c-file () "generate TAGS file from c sources" (interactive) (setq shell-file-name "/bin/sh") (shell-command "etags *.cc *.hh *.c *.h *.cpp *.hpp 2>/dev/null")) ; turn on terminal type colors (defun black-background () "Switches colors to white on black." (interactive) (set-background-color "block") (set-foreground-color "white") (set-cursor-color "gray") ; (set-default-font "-outline-Times New Roman-normal-r-normal-normal-*-*-96-96-p-*-iso8859-1") ) ;;;;Use ANSI colors within shell-mode (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) ;;;;Change pasting behavior. Normally, it pastes where the mouse ;;;;is at, which is not necessarily where the cursor is. This changes ;;;;things so all pastes, whether they be middle-click or C-y or menu, ;;;;all paste at the cursor. (setq mouse-yank-at-point t) ;;;;The autosave is typically done by keystrokes, but I'd like to save ;;;;after a certain amount of time as well. (setq auto-save-timeout 1800) ;;;;What it says. Keeps the cursor in the same relative row during ;;;;pgups and dwns. (setq scroll-preserve-screen-position t) ;;;;;Accelerate the cursor when scrolling. (load "accel" t t) ;;;;This apparently allows seamless editting of files in a tar/jar/zip ;;;;file. (auto-compression-mode 1) ;; This function will format the whole file for you (defun indent-whole-buffer () (interactive) (indent-region (point-min) (point-max) nil)) EOF scp -P $SSHPORT $TMP $1:.emacs ####################################################################### cat > $TMP <<'EOF' vbell on autodetach on startup_message off pow_detach_msg "Screen session of \$LOGNAME \$:cr:\$:nl:ended." shell -$SHELL defscrollback 1000 ################ # # xterm tweaks # #xterm understands both im/ic and doesn't have a status line. #Note: Do not specify im and ic in the real termcap/info file as #some programs (e.g. vi) will not work anymore. termcap xterm hs@:cs=\E[%i%d;%dr:im=\E[4h:ei=\E[4l terminfo xterm hs@:cs=\E[%i%p1%d;%p2%dr:im=\E[4h:ei=\E[4l #80/132 column switching must be enabled for ^AW to work #change init sequence to not switch width termcapinfo xterm Z0=\E[?3h:Z1=\E[?3l:is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l # Make the output buffer large for (fast) xterms. termcapinfo xterm* OL=10000 # tell screen that xterm can switch to dark background and has function # keys. termcapinfo xterm 'VR=\E[?5h:VN=\E[?5l' termcapinfo xterm 'k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~' termcapinfo xterm 'kh=\E[1~:kI=\E[2~:kD=\E[3~:kH=\E[4~:kP=\E[H:kN=\E[6~' # special xterm hardstatus: use the window title. termcapinfo xterm 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007' #terminfo xterm 'vb=\E[?5h$<200/>\E[?5l' termcapinfo xterm 'vi=\E[?25l:ve=\E[34h\E[?25h:vs=\E[34l' # emulate part of the 'K' charset termcapinfo xterm 'XC=K%,%\E(B,[\304,\\\\\326,]\334,{\344,|\366,}\374,~\337' # xterm-52 tweaks: # - uses background color for delete operations termcapinfo xterm ut ################ # # wyse terminals # #wyse-75-42 must have flow control (xo = "terminal uses xon/xoff") #essential to have it here, as this is a slow terminal. termcapinfo wy75-42 xo:hs@ # New termcap sequences for cursor application mode. termcapinfo wy* CS=\E[?1h:CE=\E[?1l:vi=\E[?25l:ve=\E[?25h:VR=\E[?5h:VN=\E[?5l:cb=\E[1K:CD=\E[1J ################ # # other terminals # #make hp700 termcap/info better termcapinfo hp700 'Z0=\E[?3h:Z1=\E[?3l:hs:ts=\E[62"p\E[0$~\E[2$~\E[1$}:fs=\E[0}\E[61"p:ds=\E[62"p\E[1$~\E[61"p:ic@' # Extend the vt100 desciption by some sequences. termcap vt100* ms:AL=\E[%dL:DL=\E[%dM:UP=\E[%dA:DO=\E[%dB:LE=\E[%dD:RI=\E[%dC terminfo vt100* ms:AL=\E[%p1%dL:DL=\E[%p1%dM:UP=\E[%p1%dA:DO=\E[%p1%dB:LE=\E[%p1%dD:RI=\E[%p1%dC ################ # # keybindings # #remove some stupid / dangerous key bindings bind k bind ^k bind . bind ^\ bind \\ bind ^h bind h #make them better bind 'K' kill bind 'I' login on bind 'O' login off bind '}' history # Yet another hack: # Prepend/append register [/] to the paste if ^a^] is pressed. # This lets me have autoindent mode in vi. register [ "\033:se noai\015a" register ] "\033:se ai\015a" bind ^] paste [.] ################ # # default windows # # screen -t local 0 # screen -t mail 1 elm # screen -t 40 2 rlogin faui40 # caption always "%3n %t%? @%u%?%? [%h]%?" # hardstatus alwaysignore # hardstatus alwayslastline "%w" EOF scp -P $SSHPORT $TMP $1:.screenrc ########################################################################## cat > $TMP <<'EOF' ########## C++ functions by Herman Pijl CUJ 200406 ## patched to g++ by Dirk Jagdmann # # on other platorms, you'll have to make some changes # like replacing _C_ by _M_ # # e.g. compile Listing1.cpp # you> aCC -g -AA -o gdbcontainer Listing1.cpp # you> gdb gdbcontainer # (gdb) b main # (gdb) r # ... # (gdb) p l_vec ######################################### define veclen set $veclen = $arg0._M_impl._M_finish - $arg0._M_impl._M_start end document veclen Set the variable $veclen to the length of the vector end ######################################### define pveclen veclen $arg0 output $veclen echo \n end document pveclen Print the length of a vector end ######################################### define pvecidx veclen $arg0 if ($arg1 > $veclen-1) echo idx out of range\n else if ($arg1 < 0) echo idx < 0\n else output *($arg0._M_impl._M_start + $arg1) echo \n end end end document pvecidx Print the i-th element of a vector end ######################################### define pvec veclen $arg0 set $lloop = 0 while ($lloop < $veclen) pvecidx $arg0 $lloop set $lloop = $lloop + 1 end echo length: output $veclen echo \n end document pvec pvec varname Print all the elements of a vector varname end ######################################### define setlen set $setlen = $arg0._M_t._M_impl._M_node_count end document setlen Set the variable $setlen to the length of the set end ######################################### define psetlen setlen $arg0 output $setlen echo \n end document psetlen Print the length of a set end ######################################### define maplen set $maplen = $arg0._M_t._M_impl._M_impl._M_node_count end document maplen Set the variable $maplen to the length of the map end ######################################### define pmaplen maplen $arg0 output $maplen echo \n end document pmaplen Print the length of the map end ######################################### define pstr output $arg0._M_dataplus._M_p echo \n length: set $pstr = strlen($arg0._M_dataplus._M_p) output $pstr echo \n end document pstr Print the string end EOF scp -P $SSHPORT $TMP $1:.gdbinit ########################################################################### cat > $TMP <<'EOF' ! standard font *font: -*-fixed-medium-r-*-*-14-*-*-*-*-*-iso8859-15 ! Xterm stuff XTerm*font: -misc-fixed-*-*-*-*-20-*-*-*-*-*-iso10646-* XTerm*Background: black XTerm*Foreground: gray90 XTerm*pointerColor: white XTerm*pointerColorBackground: gray20 *VT100*pointerColor: white *VT100*pointerColorBackground: gray20 *VT100*font: -misc-fixed-*-*-*-*-20-*-*-*-*-*-iso10646-* *VT100*font2: -misc-fixed-*-*-*-*-15-*-*-*-*-*-iso10646-* *VT100*font3: -misc-fixed-*-*-*-*-13-*-*-*-*-*-iso10646-* *VT100*font4: -misc-fixed-*-*-*-*-10-*-*-*-*-*-iso10646-* *VT100*font5: -misc-fixed-*-*-*-*-8-*-*-*-*-*-iso10646-* *VT100*font6: -misc-fixed-*-*-*-*-6-*-*-*-*-*-iso10646-* *VT100.activeIcon: true *VT100.iconFont: -*-fixed-*-*-*-*-6-*-*-*-*-*-iso8859-15 *VT100.background: black *VT100.foreground: gray90 *VT100.locale: true *VT100.scrollbar: false *VT100.saveLines: 1024 XDvi.paper: a4 ! Xfig Fig.latexfonts: true Fig.specialtext: true EOF scp -P $SSHPORT $TMP $1:.Xresources ########################################################################### cat > $TMP <<'EOF' OS=`uname -s` if [ "$OS" = "Linux" ] ; then # remap CapsLock to CTRL # echo 'keycode 58 = Control' | sudo loadkeys # disable screen saver setterm -blank 0 alias ls="ls --color -N" DOJLC=de_DE@euro elif [ "$OS" = "FreeBSD" ] ; then # enable ls color export CLICOLOR=1 export PACKAGESITE=ftp://ftp4.us.freebsd.org/pub/FreeBSD/ports/`uname -m`/packages-`uname -r|tr '[:upper:]' '[:lower:]'`/Latest/ DOJLC= if [ "$TERM" = screen.xterm-xfree86 ] then export TERM=xterm-color fi alias poweroff="shutdown -p now" fi if [ -z "$SSH_AUTH_SOCK" -a -z "$SSH_AGENT_PID" ] ; then eval `ssh-agent -s` fi ssh-add export CVS_RSH=ssh export CVSROOT=:pserver:doj@cvs.cubic.org:/code EDITOR=`which joe 2>/dev/null` if [ -z "$EDITOR" ] ; then EDITOR=`which emacs 2>/dev/null` ; fi if [ -z "$EDITOR" ] ; then EDITOR=`which nano 2>/dev/null` ; fi if [ -z "$EDITOR" ] ; then EDITOR=`which vim 2>/dev/null` ; fi if [ -z "$EDITOR" ] ; then EDITOR=vi ; fi export EDITOR export VISUAL=$EDITOR PAGER=`which less` if [ -z "$PAGER" ] ; then PAGER=more; fi export PAGER export LESSCHARSET=iso8859 #export LANG=en_US.UTF-8 #export LANGUAGE=$LANG export LC_CTYPE=$DOJLC # character classification and case conversion #LC_COLLATE # collation order export LC_MONETARY=$DOJLC # monetary formatting #LC_NUMERIC # numeric formatting export LC_TIME=$DOJLC # date and time formats #export LC_MESSAGES=C # format of messages #LC_ALL export TZ='Europe/Berlin' # are we an interactive shell? if [ "$PS1" ]; then if [ "x`tput kbs`" != "x" ]; then # We can't do this with "dumb" terminal stty erase `tput kbs` fi PS1="[\u@\h \w]\\$ " case $TERM in xterm*|rxvt*) PROMPT_COMMAND='echo -ne "\033]0;[${USER}@${HOSTNAME} ${PWD}]\007"' ;; *) ;; esac fi if [ -f /etc/bash_completion ] then . /etc/bash_completion elif [ -f /usr/local/etc/bash_completion ] then . /usr/local/etc/bash_completion fi BCD_=/usr/local/etc/bash_completion.d if [ -d $BCD_ -a -r $BCD_ -a -x $BCD_ ]; then for i in $BCD_/*; do . $i done fi unset i unset BCD_ alias cd..="cd .." alias df="df -h" alias emacsclient="emacsclient -n" alias nice19="nice -n 19" alias pd="pushd ." EOF scp -P $SSHPORT $TMP $1:.profile ########################################################################### cat > $TMP <<'EOF' update -dP checkout -P EOF scp -P $SSHPORT $TMP $1:.cvsrc ########################################################################### cat > $TMP <<'EOF' set folder = ~ set delete = yes set mail_check = 60 set move = no set pager_stop = yes EOF scp -P $SSHPORT $TMP $1:.muttrc ########################################################################### cat > $TMP <<'EFO' #!/bin/sh # @(#) unified command line access to CVS, SVN, GIT # Copyright (c) 2008..2009 by Dirk Jagdmann # # This software is provided 'as-is', without any express or implied # warranty. In no event will the authors be held liable for any damages # arising from the use of this software. # # Permission is granted to anyone to use this software for any purpose, # including commercial applications, and to alter it and redistribute it # freely, subject to the following restrictions: # # 1. The origin of this software must not be misrepresented; you # must not claim that you wrote the original software. If you use # this software in a product, an acknowledgment in the product # documentation would be appreciated but is not required. # # 2. Altered source versions must be plainly marked as such, and # must not be misrepresented as being the original software. # # 3. This notice may not be removed or altered from any source # distribution. # Version 2009-12-30 if [ "$1" = diffl -o "$1" = dil ] ; then shift $0 diff "$@" | less exit 0 fi if [ -d CVS ] ; then if [ "$1" = status -o "$1" = stat -o "$1" = st ] ; then perl <<'EOF' open(A, 'cvs status 2>&1 |') or die "could not execute 'cvs status'"; while() { if(/cvs status: Examining (.+)\s*$/) { if($1 eq ".") { $dir=""; } else { $dir=$1; } } if(/File\:\s+(.+?)\s+(Status\:.+)\s*$/) { next if $2 eq 'Status: Up-to-date'; print "$dir/" if $dir; print "$1\t$2\n"; } if(/^\?/) { print; } } EOF elif [ "$1" = diff -o "$1" = di ] ; then shift cvs diff -u "$@" 2>/dev/null elif [ "$1" = rm -o "$1" = del -o "$1" = delete -o "$1" = remove ] ; then shift cvs rm -f "$@" elif [ "$1" = mv -o "$1" = ren -o "$1" = rename -o "$1" = move ] ; then shift if [ $# -lt 2 ] ; then echo "usage: vc move " exit 1 fi if [ ! -f "$1" ] ; then echo "could not find $1" exit 1 fi if [ -f "$2" ] ; then echo "$2 already exists" exit 1 fi cp "$1" "$2" || exit 1 cvs add "$2" || exit 1 cvs rm -f "$1" elif [ "$1" = cp -o "$1" = copy ] ; then shift if [ $# -lt 2 ] ; then echo "usage: vc copy " exit 1 fi if [ ! -f "$1" ] ; then echo "could not find $1" exit 1 fi if [ -f "$2" ] ; then echo "$2 already exists" exit 1 fi cp "$1" "$2" || exit 1 cvs add "$2" || exit 1 elif [ "$1" = mkdir ] ; then if [ -z "$2" -o -x "$2" ] ; then echo "usage: vc mkdir " exit 1 fi mkdir "$2" || exit 1 cvs add "$2" elif [ "$1" = revert ] ; then if [ -z "$2" -o ! -f "$2" ] ; then echo "usage: vc revert " exit 1 fi rm -f "$2" cvs up "$2" elif [ "$1" = add ] ; then shift for i in "$@"; do cvs add "$i" done else cvs "$@" fi elif [ -d .svn ] ; then svn "$@" elif [ -d .git ] ; then if [ "$1" = ci -o "$1" = commit ] ; then shift git commit -a "$@" elif [ "$1" = st -o "$1" = stat ] ; then shift git status "$@" elif [ "$1" = up -o "$1" = update ] ; then shift git pull "$@" elif [ "$1" = di -o "$1" = diff ] ; then echo "==================" echo "===== CACHED =====" echo "==================" git diff --cached echo "=========================" echo "===== NOT YET ADDED =====" echo "=========================" git diff elif [ "$1" = rename ] ; then shift git mv "$@" else git "$@" fi else echo no version control found here exit 1 fi EFO scp -P $SSHPORT $TMP $1:vc ########################################################################### cat > $TMP <<'EOF' #!/bin/sh COUNTRY=us SERVER=4 P=$PWD export P V=/var/db/doj export V [ -d $V ] || mkdir -p $V if [ -z "$PACKAGESITE" ] ; then export PACKAGESITE=ftp://ftp${SERVER}.${COUNTRY}.freebsd.org/pub/FreeBSD/ports/`uname -m`/packages-`uname -r|tr '[:upper:]' '[:lower:]'`/Latest/ fi xterm_display() { if [ `uname -s` = "FreeBSD" ] ; then perl -e "print \"\\033]0;$*\\007\\n\"" else echo -ne "\033]0;$*\007" fi echo $* } pkgadd() { if [ -f "$V/$1" ] ; then return 0 fi xterm_display "installing $1" pkg_add -r -F "$1" || exit 1 touch "$V/$1" return 0 } ############################################################################# xterm_display installing some packages pkgadd perl || exit 1 pkgadd bash-completion || exit 1 pkgadd quilt || exit 1 pkgadd wget || exit 1 pkgadd p5-ack || exit 1 pkgadd screen || exit 1 pkgadd joe || exit 1 pkgadd emacs-nox11 || exit 1 ############################################################################# # download ports if present if [ ! -d /usr/ports -a -z "$NOPORTS" ] ; then cd /usr if [ ! -f ports.tar.gz ] ; then xterm_display downloading ports fetch -v -p ftp://ftp${SERVER}.${COUNTRY}.freebsd.org/pub/FreeBSD/ports/ports/ports.tar.gz || exit 1 fi xterm_display extracting ports tar xfz ports.tar.gz rm ports.tar.gz fi ############################################################################# # get the required version of ports collection if [ ! -f $V/csup -a -z "$NOPORTS" ] ; then xterm_display updating ports csup -z -L 2 -h cvsup${SERVER}.${COUNTRY}.FreeBSD.org /usr/share/examples/cvsup/ports-supfile || exit 1 touch $V/csup fi ############################################################################# # install emacs if [ ! -f $V/doj-emacs ] ; then xterm_display installing dojs emacs config cd /tmp fetch http://cubic.org/~doj/site-lisp.tar.bz2 || exit 1 cd /usr/local/share/emacs/site-lisp/ tar xfj /tmp/site-lisp.tar.bz2 rm /tmp/site-lisp.tar.bz2 cd $P touch $V/doj-emacs fi ############################################################################# # enable ntp if [ ! -f $V/ntp ] ; then echo 'ntpd_enable="YES"' >> /etc/rc.conf echo "server ${COUNTRY}.pool.ntp.org prefer" > /etc/ntp.conf echo "tinker panic 0" >> /etc/ntp.conf echo "# To deny other machines from changing the" >> /etc/ntp.conf echo "# configuration but allow localhost:" >> /etc/ntp.conf echo "restrict default nomodify nopeer" >> /etc/ntp.conf echo "restrict 127.0.0.1" >> /etc/ntp.conf touch $V/ntp fi xterm_display finished updating FreeBSD system EOF scp -P $SSHPORT $TMP $1:freebsd.sh ############################################################################ cat > $TMP <<'EOF' #!/bin/sh export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin if [ "$1" ] then PREFIX=$1/ fi DESCFILE=dump.txt echo "# Description of FreeBSD Dump" > $DESCFILE echo '#' `uname -a` >> $DESCFILE dodump() { dump -a -f - -0 -L $1 | split -b 2000m - $2 } DOLLAR='$' LIST=`mount | grep ufs | awk '{print $3}'` FS_LIST= DEVICES= for i in $LIST ; do if [ $i = "/dev" -o $i = "/mnt" -o $i = "/media" -o $i = "/cdrom" ] then true # skip these mount points else if [ $i = "/" ] then name=root else name=`echo $i | cut -b 2- -` fi FS_LIST="$FS_LIST $name" SIZEMB=`df -m | grep "$i\$" | awk '{print $2}'` DEVICE=`mount | grep "on $i " | awk '{print $1}'` DEVICES="$DEVICES $DEVICE" echo "${name}_mountpoint=$i" >> $DESCFILE echo "${name}_device=$DEVICE" >> $DESCFILE echo "${name}_sizemb=$SIZEMB" >> $DESCFILE # skip /tmp [ $i = "/tmp" ] || dodump $i ${PREFIX}${name}.dump. fi done echo "filesystems='$FS_LIST'" >> $DESCFILE for i in $DEVICES ; do SLICE=`echo $i | perl -pe 's!/dev/(\w\w\d\w\d)\w!\1!g'` DEVICE=`echo $i | perl -pe 's!/dev/(\w\w\d)\w\d\w!\1!g'` [ -f ${SLICE}.txt ] || bsdlabel /dev/$SLICE > ${SLICE}.txt [ -f ${DEVICE}.txt ] || fdisk /dev/$DEVICE > ${DEVICE}.txt done EOF scp -P $SSHPORT $TMP $1:freebsd-dump.sh cat > $TMP <<'EOF' #!/bin/sh if [ $# -lt 2 ] ; then echo "usage: service " exit 1 fi SERVICE="$1" shift for d in /etc/rc.d /usr/local/etc/rc.d ; do if [ -x "$d/$SERVICE" ] ; then "$d/$SERVICE" "$@" exit $? fi done echo "no service $SERVICE found" exit 1 EOF scp -P $SSHPORT $TMP $1:freebsd-service.sh ############################################################################ cat > $TMP <<'EOF' #!/bin/sh PATH="/usr/local/bin:$PATH" export PATH for m in `vmware-toolbox-cmd disk list` ; do echo "shrinking $m ..." vmware-toolbox-cmd disk shrink "$m" done EOF scp -P $SSHPORT $TMP $1:vmware-shrink ############################################################################ ssh -p $SSHPORT $1