| @@ -0,0 +1,2 @@ | |||||
| .vagrant | |||||
| .checksum | |||||
| @@ -0,0 +1,81 @@ | |||||
| DOTDEE=update-dotdee | |||||
| STOW=xstow | |||||
| STOWOPTS=-f | |||||
| DOTGIT=.gitconfig | |||||
| DOTPRO=.profile | |||||
| GITCONFIG=git/.gitconfig | |||||
| GITCONFIGDOTDEE=$(GITCONFIG).d | |||||
| GITCONFIGCKSUM=$(GITCONFIGDOTDEE)/.checksum | |||||
| DOTPROFILE=common/.profile | |||||
| DOTPROFILEDOTDEE=$(DOTPROFILE).d | |||||
| DOTPROFILECKSUM=$(DOTPROFILEDOTDEE)/.checksum | |||||
| PWD=$(shell pwd) | |||||
| .PHONY: common emacs git ruby haskell perl tmux vim zsh list home osx linux ws | |||||
| home: gitconfig dotprofile | |||||
| $(DOTDEE) ../$(DOTPRO) | |||||
| $(DOTDEE) ../$(DOTGIT) | |||||
| ws: common emacs git ruby haskell perl tmux vim zsh home | |||||
| all: home | |||||
| dotprofile: $(DOTPROFILECKSUM) | |||||
| gitconfig: $(GITCONFIGCKSUM) | |||||
| $(GITCONFIG): | |||||
| touch $(GITCONFIG) | |||||
| $(GITCONFIGCKSUM): $(GITCONFIG) | |||||
| $(DOTDEE) $(GITCONFIG) | |||||
| list: | |||||
| echo common emacs git ruby haskell perl tmux vim zsh | |||||
| clean: | |||||
| $(STOW) -D common emacs git ruby haskell perl tmux vim zsh osx | |||||
| -rm $(GITCONFIG) $(GITCONFIGCKSUM) $(DOTPROFILE) $(DOTPROFILECKSUM) | |||||
| gitconfig: $(GITCONFIG) | |||||
| $(DOTPROFILE): | |||||
| touch $(DOTPROFILE) | |||||
| $(DOTPROFILECKSUM): $(DOTPROFILE) | |||||
| $(DOTDEE) $(DOTPROFILE) | |||||
| common: $(DOTFILECKSUM) | |||||
| $(STOW) $(STOWOPTS) common | |||||
| # Specific stows, nothing special | |||||
| git: gitconfig | |||||
| $(STOW) git | |||||
| emacs: | |||||
| $(STOW) emacs # $@? | |||||
| osx: | |||||
| $(STOW) osx | |||||
| linux: | |||||
| $(STOW) linux | |||||
| x: | |||||
| $(STOW) x | |||||
| ruby: | |||||
| $(STOW) ruby | |||||
| zsh: | |||||
| $(STOW) zsh | |||||
| vim: | |||||
| $(STOW) vim | |||||
| haskell: | |||||
| $(STOW) haskell | |||||
| perl: | |||||
| $(STOW) perl | |||||
| @@ -0,0 +1,27 @@ | |||||
| # -*- mode: ruby -*- | |||||
| # vi: set ft=ruby : | |||||
| ENV['VAGRANT_DOTFILE_PATH'] = "/tmp/vagrant" | |||||
| Vagrant.configure("2") do |config| | |||||
| config.vm.box = "precise64" | |||||
| config.vm.provision "shell", | |||||
| privileged: false, | |||||
| inline: "if [ ! -e /var/tmp/.done ]; then | |||||
| sudo apt-get clean | |||||
| sudo rm -fr /var/lib/apt/lists | |||||
| sudo apt-get update | |||||
| # git 2.N+ instead of ass old git | |||||
| sudo apt-get install -y -q python-software-properties | |||||
| sudo add-apt-repository ppa:git-core/ppa | |||||
| sudo apt-get update | |||||
| sudo apt-get install -y -q xstow python-pip git pax zsh | |||||
| sudo pip install update-dotdee | |||||
| sudo usermod -s /bin/zsh vagrant | |||||
| mkdir /home/vagrant/dotfiles | |||||
| sudo mount -o bind /vagrant /home/vagrant/dotfiles | |||||
| touch /var/tmp/.done | |||||
| fi | |||||
| cd ~/dotfiles | |||||
| make ws all | |||||
| " | |||||
| end | |||||
| @@ -0,0 +1,100 @@ | |||||
| COLOR tty | |||||
| TERM ansi | |||||
| TERM color-xterm | |||||
| TERM con132x25 | |||||
| TERM con132x30 | |||||
| TERM con132x43 | |||||
| TERM con132x60 | |||||
| TERM con80x25 | |||||
| TERM con80x28 | |||||
| TERM con80x30 | |||||
| TERM con80x43 | |||||
| TERM con80x50 | |||||
| TERM con80x60 | |||||
| TERM cons25 | |||||
| TERM console | |||||
| TERM cygwin | |||||
| TERM dtterm | |||||
| TERM eterm-color | |||||
| TERM Eterm | |||||
| TERM gnome | |||||
| TERM konsole | |||||
| TERM kterm | |||||
| TERM linux | |||||
| TERM linux-c | |||||
| TERM mach-color | |||||
| TERM putty | |||||
| TERM rxvt | |||||
| TERM rxvt-cygwin | |||||
| TERM rxvt-cygwin-native | |||||
| TERM rxvt-unicode | |||||
| TERM screen | |||||
| TERM screen-bce | |||||
| TERM screen-w | |||||
| TERM screen.linux | |||||
| TERM vt100 | |||||
| TERM xterm | |||||
| TERM xterm-256color | |||||
| TERM xterm-color | |||||
| TERM xterm-debian | |||||
| # Below are the color init strings for the basic file types. A color init | |||||
| # string consists of one or more of the following numeric codes: | |||||
| # Attribute codes: | |||||
| # 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed | |||||
| # Text color codes: | |||||
| # 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white | |||||
| # Background color codes: | |||||
| # 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white | |||||
| NORMAL 00 # global default, although everything should be something. | |||||
| FILE 00 # normal file | |||||
| DIR 01;34 # directory | |||||
| LINK 01;36 # symbolic link. (If you set this to 'target' instead of a | |||||
| # numerical value, the color will match the file pointed to) | |||||
| FIFO 40;33 # pipe | |||||
| SOCK 01;35 # socket | |||||
| DOOR 01;35 # door | |||||
| BLK 40;33;01 # block device driver | |||||
| CHR 40;33;01 # character device driver | |||||
| ORPHAN 01;05;37;41 # orphaned syminks | |||||
| MISSING 01;05;37;41 # ... and the files they point to | |||||
| # This is for files with execute permission: | |||||
| EXEC 01;32 | |||||
| # List any file extensions like '.gz' or '.tar' that you would like ls | |||||
| # to colorize below. Put the extension, a space, and the color init string. | |||||
| # (and any comments you want to add after a '#') | |||||
| .cmd 01;32 # executables (bright green) | |||||
| .exe 01;32 | |||||
| .com 01;32 | |||||
| .btm 01;32 | |||||
| .bat 01;32 | |||||
| .sh 01;32 | |||||
| .csh 01;32 | |||||
| .ksh 01;32 | |||||
| .zsh 01;32 | |||||
| .tar 01;31 # archives / compressed (bright red) | |||||
| .tgz 01;31 | |||||
| .arj 01;31 | |||||
| .taz 01;31 | |||||
| .lzh 01;31 | |||||
| .zip 01;31 | |||||
| .z 01;31 | |||||
| .Z 01;31 | |||||
| .gz 01;31 | |||||
| .bz2 01;31 | |||||
| .bz 01;31 | |||||
| .tbz2 01;31 | |||||
| .tz 01;31 | |||||
| .deb 01;31 | |||||
| .rpm 01;31 | |||||
| .rar 01;31 # app-arch/rar | |||||
| .ace 01;31 # app-arch/unace | |||||
| .zoo 01;31 # app-arch/zoo | |||||
| .cpio 01;31 # app-arch/cpio | |||||
| .7z 01;31 # app-arch/p7zip | |||||
| .rz 01;31 # app-arch/rzip | |||||
| @@ -0,0 +1,14 @@ | |||||
| # common/.profile.d/00-prelude.sh | |||||
| # -*- mode: Shell-script; -*- | |||||
| # Common .profile | |||||
| # | |||||
| # This file is generated from dotdee and managed from stow. | |||||
| # | |||||
| # Manual editing discouraged. | |||||
| # Common variables for use later | |||||
| _uname=$(uname) | |||||
| _uname_n=$(uname -n) | |||||
| _hostname=$(hostname) | |||||
| export _uname _uname_n _hostname | |||||
| @@ -0,0 +1,3 @@ | |||||
| # common/.profile.d/01-ps1.sh | |||||
| # Default if not already overridden | |||||
| _host=${_host:=${_uname_n}} | |||||
| @@ -0,0 +1,3 @@ | |||||
| # common/.profile.d/10-path.sh | |||||
| PATH="${PATH}:${HOME}/bin" | |||||
| export PATH | |||||
| @@ -0,0 +1,42 @@ | |||||
| # common/.profile.d/20-functions-path.sh | |||||
| # cat out a : separated env variable | |||||
| # variable is the parameter | |||||
| cat_env() | |||||
| { | |||||
| set | grep '^'"$1"'=' > /dev/null 2>&1 && eval "echo \$$1" | tr ':' ' | |||||
| ' | awk '!/^\s+$/' | awk '!/^$/' | |||||
| } | |||||
| # Convert a line delimited input to : delimited | |||||
| to_env() | |||||
| { | |||||
| awk '!a[$0]++' < /dev/stdin | tr -s ' | |||||
| ' ':' | sed -e 's/\:$//' | awk 'NF > 0' | |||||
| } | |||||
| # Unshift a new value onto the env var | |||||
| # first arg is ENV second is value to unshift | |||||
| # basically prepend value to the ENV variable | |||||
| unshift_env() | |||||
| { | |||||
| new=$(eval "echo $2; echo \$$1" | to_env) | |||||
| eval "$1=${new}; export $1" | |||||
| } | |||||
| # Opposite of above, but echos what was shifted off | |||||
| shift_env() | |||||
| { | |||||
| first=$(cat_env "$1" | head -n 1) | |||||
| rest=$(cat_env "$1" | awk '{if (NR!=1) {print}}' | to_env) | |||||
| eval "$1=$rest; export $1" | |||||
| echo "${first}" | |||||
| } | |||||
| # push $2 to $1 on the variable | |||||
| push_env() | |||||
| { | |||||
| have=$(cat_env "$1") | |||||
| new=$(printf "%s | |||||
| %s" "$have" "$2" | to_env) | |||||
| eval "$1=$new; export $1" | |||||
| } | |||||
| @@ -0,0 +1,242 @@ | |||||
| # common/.profile.d/20-functions-ps1.sh | |||||
| # Get user name of current user even if | |||||
| # $USER isn't set | |||||
| # Use id if we don't have $USER | |||||
| user_name() | |||||
| { | |||||
| if [ -z $USER ]; then | |||||
| echo $(id | awk -F\( '{print $2}' | sed -e 's/[)].*//g') | |||||
| else | |||||
| echo $USER | |||||
| fi | |||||
| } | |||||
| # duh | |||||
| am_i_root() | |||||
| { | |||||
| [ "$(user_name)" = 'root' ] | |||||
| } | |||||
| userps1name= | |||||
| hostps1name= | |||||
| host_name() | |||||
| { | |||||
| name='' | |||||
| case $(os_type) in | |||||
| osx) name=$(hostname -s) ;; | |||||
| *) name=$(uname -n) ;; | |||||
| esac | |||||
| echo $name | |||||
| } | |||||
| host_ps1name() | |||||
| { | |||||
| if [[ ${hostps1name:+1} != 1 ]]; then | |||||
| hostps1name=$(host_name) | |||||
| if [[ ${pscolors:+1} == 1 ]]; then | |||||
| hostps1name="%{$fg[blue]%}$hostps1name%{$reset_color%}" | |||||
| fi | |||||
| fi | |||||
| echo $hostps1name | |||||
| } | |||||
| user_ps1name() | |||||
| { | |||||
| if [[ ${userps1name:+1} != 1 ]]; then | |||||
| case $(user_name) in | |||||
| mitch) | |||||
| userps1name='me' | |||||
| if [[ ${pscolors:+1} == 1 ]]; then | |||||
| userps1name="%{$fg[blue]%}$userps1name%{$reset_color%}" | |||||
| fi | |||||
| ;; | |||||
| root) | |||||
| userps1name='root' | |||||
| if [[ ${pscolors:+1} == 1 ]]; then | |||||
| userps1name="%{$fg[red]%}$userps1name%{$reset_color%}" | |||||
| fi | |||||
| ;; | |||||
| *) | |||||
| userps1name=$(user_name) | |||||
| if [[ ${pscolors:+1} == 1 ]]; then | |||||
| userps1name="%{$fg[cyan]%}$userps1name%{$reset_color%}" | |||||
| fi | |||||
| ;; | |||||
| esac | |||||
| fi | |||||
| echo $userps1name | |||||
| } | |||||
| # using who am i, see if our pty is owned by someone else. | |||||
| user_ptyname() | |||||
| { | |||||
| name=$(who am i | sed -e "s/[ ].*//1") | |||||
| [ ${name} == '' ] && name=$LOGNAME | |||||
| echo $name | |||||
| } | |||||
| ps1_user_host() | |||||
| { | |||||
| echo "$(user_ps1name)@$(host_ps1name)" | |||||
| } | |||||
| ps1_special() | |||||
| { | |||||
| am_i_root | |||||
| [ $? -eq 0 ] && echo '# ' || echo '$ ' | |||||
| } | |||||
| ps1() | |||||
| { | |||||
| echo "$(ps1_user_host) $(ps1_special)" | |||||
| } | |||||
| ostype='' | |||||
| oskernel='' | |||||
| osarch='' | |||||
| osmajor='' | |||||
| osminor='' | |||||
| osversion='' | |||||
| osuname_s='' | |||||
| osrelease='' | |||||
| osprefix='' | |||||
| osreleasefile='' | |||||
| # where /etc/*release files exist | |||||
| archreleasefile='/etc/arch-release' | |||||
| debianreleasefile='/etc/debian_version' | |||||
| susereleasefile='/etc/SuSE-release' | |||||
| redhatreleasefile='/etc/Redhat-release' | |||||
| solarisreleasefile='/etc/release' | |||||
| freebsdreleasefile='/etc/freebsd-update.conf' | |||||
| os_release() | |||||
| { | |||||
| case $(os_uname_s) in | |||||
| Linux) osrelease=$(cat $osreleasefile) ;; | |||||
| Darwin) osrelease=$(sw_vers -productVersion) ;; | |||||
| bsd) osrelease=$(uname -r) ;; | |||||
| *) osrelease='' ;; | |||||
| esac | |||||
| echo $osrelease | |||||
| } | |||||
| os_kernel() | |||||
| { | |||||
| if [[ ${oskernel:+1} != 1 ]]; then | |||||
| oskernel=$(uname -r) | |||||
| fi | |||||
| echo $oskernel | |||||
| } | |||||
| os_arch() | |||||
| { | |||||
| if [[ ${osarch:+1} != 1 ]]; then | |||||
| osarch=$(uname -m) | |||||
| fi | |||||
| echo $osarch | |||||
| } | |||||
| os_uname_s() | |||||
| { | |||||
| if [[ ${os_uname_s:+1} != 1 ]]; then | |||||
| osuname_s=$(uname -s) | |||||
| fi | |||||
| echo $osuname_s | |||||
| } | |||||
| function os_type { | |||||
| if [[ ${ostype:+1} != 1 ]]; then | |||||
| if [[ -f $archreleasefile ]]; then | |||||
| ostype='arch' | |||||
| osreleasefile=$archreleasefile | |||||
| elif [[ -f $debianreleasefile ]]; then | |||||
| ostype='debian' | |||||
| osreleasefile=$debianreleasefile | |||||
| elif [[ -f $susereleasefile ]]; then | |||||
| ostype='suse' | |||||
| osreleasefile=$susereleasefile | |||||
| elif [[ -f $redhatreleasefile ]]; then | |||||
| ostype='redhat' | |||||
| osreleasefile=$redhatreleasefile | |||||
| elif [[ $(os_uname_s) == 'SunOS' ]]; then | |||||
| ostype='sun' | |||||
| elif [[ $(os_uname_s) == 'Darwin' ]]; then | |||||
| ostype='osx' | |||||
| elif [[ -f $freebsdreleasefile ]]; then | |||||
| ostype='bsd' | |||||
| else | |||||
| echo "No idea what os type this is." | |||||
| fi | |||||
| fi | |||||
| echo $ostype | |||||
| } | |||||
| os_major() | |||||
| { | |||||
| if [[ ${osmajor:+1} != 1 ]]; then | |||||
| case $(os_type) in | |||||
| arch) osmajor='arch' ;; | |||||
| debian) osmajor=$(os_release | sed -e 's/\.[0-9]\{1\}//2') ;; | |||||
| suse) | |||||
| osmajor=$(os_release | grep 'VER' | sed -e 's/.*\=\ //g') ;; | |||||
| redhat) osmajor='zomg' ;; | |||||
| sun) osmajor=$(uname -r) ;; | |||||
| osx) osmajor=$(os_release | sed -e 's/\.[0-9]\{1\}//2') ;; | |||||
| bsd) osmajor=$(os_release | sed -e 's/\.*//') ;; | |||||
| *) osmajor='?' | |||||
| esac | |||||
| fi | |||||
| echo $osmajor | |||||
| } | |||||
| os_minor() | |||||
| { | |||||
| if [[ ${osminor:+1} != 1 ]]; then | |||||
| case $(os_type) in | |||||
| arch) osminor='zomg' ;; | |||||
| debian) osminor=$(os_release | sed -e 's/[0-9]\.[0-9]\{1\}\.//1') ;; | |||||
| suse) | |||||
| osminor=$(os_release | grep 'PATCH' | sed -e 's/.*\=\ //g') ;; | |||||
| redhat) osminor='zomg' ;; | |||||
| sun) osminor=$(uname -r) ;; | |||||
| osx) osminor=$(os_release | sed -e 's/10\.[0-9]\{1\}\.//1') ;; | |||||
| bsd) osminor=$(os_release | sed -e 's/\d+\.[0-9]\{1\}\-//1') ;; | |||||
| *) osminor='?' | |||||
| esac | |||||
| fi | |||||
| echo $osminor | |||||
| } | |||||
| os_version() | |||||
| { | |||||
| if [[ ${osversion:+1} != 1 ]]; then | |||||
| case $(os_type) in | |||||
| arch) osversion='zomg' ;; | |||||
| debian) osversion=$(os_release) ;; | |||||
| suse) osversion="${osmajor}u${osminor}" ;; | |||||
| redhat) osversion='zomg' ;; | |||||
| sun) osversion=$osmajor ;; | |||||
| osx) osversion=$(os_release) ;; | |||||
| bsd) osversion="${osmajor}.${osminor}" ;; | |||||
| *) osversion='wtf?' ;; | |||||
| esac | |||||
| fi | |||||
| echo $osversion | |||||
| } | |||||
| os_prefix() | |||||
| { | |||||
| if [[ ${osprefix:+1} != 1 ]]; then | |||||
| case $(os_type) in | |||||
| osx) osprefix="$(os_major)-$(os_uname_s)-$(os_arch)" ;; | |||||
| *) osprefix="$(os_type)-$(os_uname_s)-$(os_arch)" ;; | |||||
| esac | |||||
| fi | |||||
| echo $osprefix | |||||
| } | |||||
| # setup the one thing we need for all of the functions. | |||||
| os_type > /dev/null 2>&1 | |||||
| @@ -0,0 +1,82 @@ | |||||
| # common/.profile.d/20-functions.sh | |||||
| # Remove a line matched in $HOME/.ssh/known_hosts for when there are legit | |||||
| # host key changes. | |||||
| nukehost() | |||||
| { | |||||
| if [ -z "$1" ]; then | |||||
| echo "Usage: nukehost <hostname>" | |||||
| echo " Removes <hostname> from ssh known_host file." | |||||
| else | |||||
| sed -i -e "/$1/d" ~/.ssh/known_hosts | |||||
| fi | |||||
| } | |||||
| # Cheap copy function to make copying a file via ssh from one host | |||||
| # to another less painful, use pipeviewer to give some idea as to progress. | |||||
| ssh-copyfile() | |||||
| { | |||||
| if [ -z "$1" -o -z "$2" ]; then | |||||
| echo "Usage: copy source:/file/location destination:/file/location" | |||||
| else | |||||
| srchost="$(echo "$1" | awk -F: '{print $1}')" | |||||
| src="$(echo "$1" | awk -F: '{print $2}')" | |||||
| dsthost="$(echo "$2" | awk -F: '{print $1}')" | |||||
| dst="$(echo "$2" | awk -F: '{print $2}')" | |||||
| size=$(ssh "$srchost" du -hs "$src" 2> /dev/null) | |||||
| size=$(echo "${size}" | awk '{print $1}') | |||||
| echo "Copying $size to $dst" | |||||
| ssh "$srchost" "/bin/cat \$src" 2> /dev/null | pv -cb -N copied - | ssh "$dsthost" "/bin/cat - > \$dst" 2> /dev/null | |||||
| fi | |||||
| } | |||||
| # extract function to automate being lazy at extracting archives. | |||||
| extract() | |||||
| { | |||||
| if [ -f "$1" ]; then | |||||
| case ${1} in | |||||
| *.tar.bz2|*.tbz2|*.tbz) bunzip2 -c "$1" | tar xvf -;; | |||||
| *.tar.gz|*.tgz) gunzip -c "$1" | tar xvf -;; | |||||
| *.tz|*.tar.z) zcat "$1" | tar xvf -;; | |||||
| *.tar.xz|*.txz|*.tpxz) xz -d -c "$1" | tar xvf -;; | |||||
| *.bz2) bunzip2 "$1";; | |||||
| *.gz) gunzip "$1";; | |||||
| *.jar|*.zip) unzip "$1";; | |||||
| *.rar) unrar x "$1";; | |||||
| *.tar) tar -xvf "$1";; | |||||
| *.z) uncompress "$1";; | |||||
| *.rpm) rpm2cpio "$1" | cpio -idv;; | |||||
| *) echo "Unable to extract <$1> Unknown extension." | |||||
| esac | |||||
| else | |||||
| print "File <$1> does not exist." | |||||
| fi | |||||
| } | |||||
| # Tcsh compatibility so I can be a lazy bastard and paste things directly | |||||
| # if/when I need to. | |||||
| setenv() | |||||
| { | |||||
| export "$1=$2" | |||||
| } | |||||
| # Just to be lazy, set/unset the DEBUG env variable used in my scripts | |||||
| debug() | |||||
| { | |||||
| if [ -z "$DEBUG" ]; then | |||||
| if [ -z "$1" ]; then | |||||
| echo Setting DEBUG to "$1" | |||||
| setenv DEBUG "$1" | |||||
| else | |||||
| echo Setting DEBUG to default | |||||
| setenv DEBUG default | |||||
| fi | |||||
| else | |||||
| echo Unsetting DEBUG | |||||
| unset DEBUG | |||||
| fi | |||||
| } | |||||
| login_shell() | |||||
| { | |||||
| [[ $- == *i* ]] | |||||
| } | |||||
| @@ -0,0 +1,12 @@ | |||||
| # common/.profile.d/99-alias.sh | |||||
| alias s="\$(which ssh)" | |||||
| alias quit='exit' | |||||
| alias cr='reset; clear' | |||||
| alias a=ag | |||||
| alias n=noglob | |||||
| alias l=ls | |||||
| alias L='ls -dal' | |||||
| alias tl='tmux ls' | |||||
| alias cleandir="find . -type f \( -name '*~' -o -name '#*#' -o -name '.*~' -o -name '.#*#' -o -name 'core' -o -name 'dead.letter*' \) | grep -v auto-save-list | xargs -t rm" | |||||
| which less > /dev/null 2>&1 | |||||
| [ $? = 0 ] && alias T='less -f +F' || alias T='tail -f' | |||||
| @@ -0,0 +1,142 @@ | |||||
| #!/usr/bin/env perl | |||||
| # | |||||
| # Convert input ip/cidr|netmask|hexnetmask to useable network information. | |||||
| # | |||||
| use strict; | |||||
| use warnings; | |||||
| use Socket; | |||||
| use Sys::Hostname; | |||||
| # | |||||
| # Globalish vars | |||||
| # | |||||
| $ENV{PATH} = '/usr/bin:/bin:/usr/sbin:/sbin'; # Paranoia, know thy name! | |||||
| my ($fqdn_regexp) = qr/([0-9,a-z,A-Z,\-,\_]+)\.([0-9,a-z,A-Z,\-,\_]+)\.(com|gov)/; | |||||
| # | |||||
| # converts a 1-word (4 byte) signed or unsigned integer into a dotted decimal | |||||
| # ip address. | |||||
| # | |||||
| sub int2ip { | |||||
| my $n=int(pop); | |||||
| return(sprintf("%d.%d.%d.%d", ($n>>24)&0xff,($n>>16)&0xff, | |||||
| ($n>>8)&0xff,$n&0xff)); | |||||
| }; | |||||
| # | |||||
| # Convert a host/ip/netmask/cidr/etc.... to a hash of information | |||||
| # Example: host.domain.tld/24 will get the ip and calculate the netmask info | |||||
| # equally if host.domain.tld corresponds with 1.2.3.4 the following is valid | |||||
| # 1.2.3.4/255.255.255.0 would obtain the same information. | |||||
| # | |||||
| # die()'s if anything isn't kosher. | |||||
| # | |||||
| # Ultra long function, probably needs to be looked at for condensing/splitting. | |||||
| # | |||||
| sub cidr2raw { | |||||
| my $rawinput = pop; | |||||
| my ($lhs, $rhs, $j, $uip) = (undef, undef, undef, undef); | |||||
| my ($ucidr) = 0; | |||||
| my ($network, $bits, $netmask, $broadcast, $low, $high); | |||||
| if ($rawinput =~ qr/(.*)\/(.*)/){ | |||||
| $lhs = $1; $rhs = $2; | |||||
| }else{ | |||||
| die "Input: $rawinput not expected.\n"; | |||||
| }; | |||||
| # | |||||
| # Handle ip/hostname for left hand side. | |||||
| if ($lhs =~ qr/(\d+)\.(\d+)\.(\d+)\.(\d+)/){ | |||||
| foreach my $dotted (($1,$2,$3,$4)){ | |||||
| if (($dotted > 255) or ($dotted < 0)){ | |||||
| die "FATAL: ipv4 address entered, $lhs entered is impossible, $dotted is not between 0-255.\n"; | |||||
| }; | |||||
| }; | |||||
| $uip = inet_ntoa(scalar gethostbyname($lhs)); | |||||
| die "FATAL: Cannot determine hostname for $lhs$!\n" if (!defined($lhs)); | |||||
| }elsif ($lhs =~ $fqdn_regexp){ | |||||
| my $tmp = gethostbyname($lhs); | |||||
| die "FATAL: Cannot determine ip for $lhs" if (!defined($tmp)); | |||||
| $uip = inet_ntoa($tmp); | |||||
| }else{ | |||||
| die "FATAL: host value not fully qualified, or not an ip <$lhs>\n"; | |||||
| }; | |||||
| # | |||||
| # Handle the netmask/cidr for the right hand side, | |||||
| # | |||||
| # All input netmasks are converted to a cidr address for notation | |||||
| if ($rhs =~ qr/^(\d+)$/){ # /cidr | |||||
| $ucidr = $1; | |||||
| die "FATAL: Invalid CIDR <$ucidr>.$!\n" if (($ucidr > 32) or ($ucidr < 0)); | |||||
| }elsif ($rhs =~ qr/(0[xX])?([0-9,a-f,A-F]{7})/){ # /0xhexnetmask | |||||
| my $trimmed = $2; | |||||
| my $insane = 0; | |||||
| foreach my $byte (split('', unpack("B32", pack("H*", $trimmed)))){ | |||||
| ($byte) ? $ucidr++ : $insane++; | |||||
| die "FATAL: $rhs is not a valid hex netmask.$!\n" if ($insane and $byte); | |||||
| }; | |||||
| }elsif ($rhs =~ qr/(\d+)\.(\d+)\.(\d+)\.(\d+)/){ # /255.255.255.0 form | |||||
| my @a = ($1, $2, $3, $4); | |||||
| my $insane = 0; | |||||
| foreach my $t (@a){ | |||||
| die "FATAL: Netmask out of range. Input <$rhs> Invalid <$t>$!\n" if (($t < 0) or ($t > 255)); | |||||
| }; | |||||
| foreach my $byte (split('', unpack("B32", pack("C4", @a)))){ | |||||
| ($byte) ? $ucidr++ : $insane++; | |||||
| die "FATAL: $rhs is not a valid netmask.$!\n" if ($insane and $byte); | |||||
| }; | |||||
| }else{ | |||||
| die "FATAL: Unknown or invalid netmask value entered. <$rhs>\n"; | |||||
| }; | |||||
| # | |||||
| # Network math GO! This is the meat of the function. | |||||
| my (@uip) = split(/\./, $uip); | |||||
| $network = 0; | |||||
| for ($j = 0; $j <= $#uip; $j++){ | |||||
| $network += int($uip[$j])<<((3-$j)*8); | |||||
| }; | |||||
| $bits = 0; $j = 0; | |||||
| for ($j = 31 - $ucidr; $j >= 0; $j--){ | |||||
| $bits |= 1<<$j; | |||||
| }; | |||||
| $netmask = 0xffffffff^$bits; | |||||
| $low = ($network&$netmask); | |||||
| $high = ($network&$netmask)+$bits-1; | |||||
| $broadcast = ($network&$netmask)|$bits; | |||||
| my ($guessed_hostname,undef,undef,undef,undef) = gethostbyaddr(inet_aton($uip), AF_INET); | |||||
| # | |||||
| # Throw the info back, they get a hash with zie info they may/may not need. | |||||
| # All up to the caller what they want to use. | |||||
| # | |||||
| return ("inet4" => $uip, | |||||
| "netmask" => int2ip($netmask), | |||||
| "broadcast" => int2ip($broadcast), | |||||
| "cidr" => $ucidr, | |||||
| "router" => int2ip($low+1), | |||||
| "network" => int2ip($low), | |||||
| "high" => int2ip($high), | |||||
| "hostname" => $guessed_hostname, | |||||
| ); | |||||
| }; | |||||
| #package Main; # future use | |||||
| foreach my $arg (@ARGV){ | |||||
| my %stuff = cidr2raw($arg); | |||||
| printf("%s/%s is %s/%s\n%-12s\t%s\n%-12s\t%s\n%-12s\t%s\n%-12s\t%s\n%-12s\t%s\n", | |||||
| $stuff{"inet4"},$stuff{"cidr"}, | |||||
| $stuff{"network"},$stuff{"cidr"}, | |||||
| "Netmask",$stuff{"netmask"}, | |||||
| "Broadcast",$stuff{"broadcast"}, | |||||
| "Network",$stuff{"network"}, | |||||
| "Router",$stuff{"router"}, | |||||
| "HighUsable",$stuff{"high"}, | |||||
| ); | |||||
| }; | |||||
| @@ -0,0 +1,36 @@ | |||||
| #!/usr/bin/env perl | |||||
| # | |||||
| # Stupid script to help with dns information. Solaris 9/8 lack the host utility. | |||||
| # Which this (kinda) mimics, except the mx record crap | |||||
| use strict; | |||||
| use warnings; | |||||
| use Socket; | |||||
| use Sys::Hostname; | |||||
| my $input = shift || hostname(); | |||||
| my $lookup = $input; | |||||
| if ( $lookup =~ /\d+[.]\d+[.]\d+[.]\d+/smx ) { | |||||
| $lookup = ( gethostbyaddr inet_aton($lookup), AF_INET )[0]; | |||||
| die "Error: Unable to reverse lookup ip $input.\n" if ( $lookup eq q{} ); | |||||
| } | |||||
| my $ipv4 = gethostbyname $lookup; | |||||
| die "Error: $lookup doesn't have any known ip addresses\n" | |||||
| if ( !defined $ipv4 ); | |||||
| $ipv4 = inet_ntoa($ipv4); | |||||
| my ( $short_name, $aliases, $addrtype, $len, @addrs ) = gethostbyname $lookup; | |||||
| foreach my $ipv4 (@addrs) { | |||||
| $ipv4 = inet_ntoa($ipv4); | |||||
| print "$lookup is $ipv4\n"; | |||||
| } | |||||
| print "$lookup is also $short_name\n"; | |||||
| if ( defined $aliases and "$aliases" ne q{} ) { | |||||
| print "aliases are ($aliases)\n"; | |||||
| } | |||||
| exit 0; | |||||
| @@ -0,0 +1,61 @@ | |||||
| #!/usr/bin/env ruby | |||||
| # | |||||
| # Quick script to find duplicate files | |||||
| # | |||||
| require 'find' | |||||
| require 'digest/sha1' | |||||
| require 'set' | |||||
| hashes = Hash.new | |||||
| start = ARGV[0] || ENV["HOME"] | |||||
| puts "Building digests from #{start}" | |||||
| Find.find(start) do |path| | |||||
| STDOUT.flush | |||||
| this_hash = Set.new | |||||
| hash = "NONE" | |||||
| if (FileTest.directory?(path) or FileTest.symlink?(path)\ | |||||
| or FileTest.blockdev?(path) or FileTest.chardev?(path)\ | |||||
| or FileTest.socket?(path) or FileTest.pipe?(path)\ | |||||
| or FileTest.zero?(path)) then | |||||
| next | |||||
| else | |||||
| begin | |||||
| file_digest = Digest::SHA1.new | |||||
| File.open(path, 'r') do |fh| | |||||
| while buffer = fh.read(8096) | |||||
| file_digest.update(buffer) | |||||
| end | |||||
| end | |||||
| hash = file_digest.hexdigest | |||||
| rescue NoMemoryError | |||||
| puts "NoMemoryError on #{path}" | |||||
| GC.start | |||||
| rescue IOError | |||||
| puts "IOError on #{path}" | |||||
| GC.start | |||||
| rescue Errno::ENOSYS; next | |||||
| rescue Errno::EACCES; next | |||||
| rescue Errno::EINVAL; next | |||||
| rescue => e | |||||
| puts "Unhandled error on #{path}, exception #{e}" | |||||
| p e | |||||
| exit 255 | |||||
| end | |||||
| end | |||||
| if (hashes[hash]) then | |||||
| hashes[hash].add(path) | |||||
| else | |||||
| hashes[hash] = this_hash.add(path) | |||||
| end | |||||
| end | |||||
| puts "Digest generation complete." | |||||
| hashes.each_pair do |key, val| | |||||
| files = val.to_a | |||||
| files.delete(nil) | |||||
| files.delete_if {|x| "#{x}" =~ /^\s*$/} | |||||
| next if (files.size < 2) | |||||
| puts "Duplicate digest <#{key}> for files:\n #{files.join("\n ")}" | |||||
| end | |||||
| @@ -0,0 +1,26 @@ | |||||
| #!/usr/bin/env perl | |||||
| # | |||||
| # Because all find implementations, that is, everything but gnu find. | |||||
| # lack -find as an option. | |||||
| # | |||||
| use File::Find; | |||||
| my $debug; | |||||
| (exists($ENV{"DEBUG"})) ? $debug++ : undef; | |||||
| my $dir = $ARGV[-1] || '/tmp'; | |||||
| find(\&sieve, $dir); | |||||
| sub sieve { | |||||
| my $file = $File::Find::name; | |||||
| my $filedir = $File::Find::dir; | |||||
| my ($dev,$inode,undef,undef,undef,undef,undef,$size) = lstat($file); | |||||
| next if !(-d $file); # Only zie diectories BITTE! | |||||
| # | |||||
| # Ok, lets see if readdir returns more than 2 entries. | |||||
| opendir my $H, $file or next; | |||||
| print "$file\n" unless (grep !/^\.{1,2}/, readdir $H); | |||||
| close $H; | |||||
| }; | |||||
| @@ -0,0 +1,15 @@ | |||||
| #!/usr/bin/env perl | |||||
| # | |||||
| # Dumb wrapper to get the gecos information from a uid/username. | |||||
| foreach my $input (@ARGV){ | |||||
| my $gecos = undef; | |||||
| my $uid = undef; | |||||
| my $name = undef; | |||||
| if ( $input =~ m/^\d+$/ ) { | |||||
| ( $name,$uid,$gecos ) = ( getpwuid($input) )[0,2,6]; | |||||
| } else { | |||||
| ( $name,$uid,$gecos ) = ( getpwnam($input) )[0,2,6]; | |||||
| } | |||||
| print "$name is '$gecos' uid '$uid'\n" if $gecos; | |||||
| } | |||||
| @@ -0,0 +1,62 @@ | |||||
| #!/usr/bin/env perl | |||||
| # | |||||
| # hatimerun in perl, sorta | |||||
| # | |||||
| use Getopt::Long; | |||||
| my $opt_exitcode = 99; | |||||
| my $opt_killcode = 9; | |||||
| my $opt_timeout = 60; | |||||
| GetOptions( 'e=i' => \$opt_exitcode, | |||||
| 'k=i' => \$opt_killcode, | |||||
| 't=i' => \$opt_timeout, | |||||
| 'h' => \&opt_help, | |||||
| 'help' => \&opt_help, | |||||
| ); | |||||
| sub opt_help{ | |||||
| my $message = <<__END__; | |||||
| UX: ERROR: invalid syntax | |||||
| usage: [-e return code][-k kill signal][-t seconds to wait] | |||||
| [-h][--help] | |||||
| Options | |||||
| --help, -h Prints this help text. | |||||
| -e Exit code to return on timeout. | |||||
| NOTE: 99 by default. | |||||
| -k Signal number to send via kill. | |||||
| NOTE: 9 by default. | |||||
| -t Timeout in seconds before alarming. | |||||
| NOTE: 60 by default. | |||||
| __END__ | |||||
| print $message; | |||||
| exit 1; | |||||
| }; | |||||
| my $pid; | |||||
| local $SIG{ALRM} = sub { kill $opt_killcode, $pid or die "Kill failed: $!"; | |||||
| die "Timeout!\n"}; | |||||
| eval{ | |||||
| my $x = defined($pid = fork()); | |||||
| unless ($pid){ | |||||
| print qx(@ARGV); | |||||
| die "Exec of ", join(' ', @ARGV), " failed at $!\n"; | |||||
| }; | |||||
| alarm $opt_timeout; | |||||
| waitpid $pid => 0; | |||||
| alarm 0; | |||||
| exit 0; | |||||
| }; | |||||
| if ($@){ | |||||
| die "Nothing to do!\n" unless $@ eq "Timeout!\n"; | |||||
| exit $opt_exitcode; | |||||
| }else{ | |||||
| exit 0; | |||||
| }; | |||||
| @@ -0,0 +1,209 @@ | |||||
| #!/usr/bin/env perl | |||||
| # | |||||
| # Because ifconfig output is... overly verbose. | |||||
| # | |||||
| # Output information from ifconfig -a like so: | |||||
| # interface:mtu ipv4/cidr mac_address ipv6_addr(if applicable) | |||||
| # ipv6 is not yet in place due to a: lazy, b: can't use it yet. | |||||
| # | |||||
| use strict; | |||||
| use Socket; | |||||
| use Sys::Hostname; | |||||
| $ENV{'PATH'}='/sbin:/usr/sbin:/bin:/usr/bin'; | |||||
| my ($fqdn_regexp) = qr/([0-9,a-z,A-Z,\-,\_]+)\.([0-9,a-z,A-Z,\-,\_]+)\.(com|gov)/; | |||||
| # | |||||
| # converts a 1-word (4 byte) signed or unsigned integer into a dotted decimal | |||||
| # ip address. | |||||
| # | |||||
| sub int2ip { | |||||
| my $n=int(pop); | |||||
| return(sprintf("%d.%d.%d.%d", ($n>>24)&0xff,($n>>16)&0xff, | |||||
| ($n>>8)&0xff,$n&0xff)); | |||||
| }; | |||||
| # | |||||
| # Convert a host/ip/netmask/cidr/etc.... to a hash of information | |||||
| # Example: host.domain.tld/24 will get the ip and calculate the netmask info | |||||
| # equally if host.domain.tld corresponds with 1.2.3.4 the following is valid | |||||
| # 1.2.3.4/255.255.255.0 would obtain the same information. | |||||
| # | |||||
| # die()'s if anything isn't kosher. | |||||
| # | |||||
| # Ultra long function, probably needs to be looked at for condensing/splitting. | |||||
| # | |||||
| sub cidr2raw { | |||||
| my $rawinput = pop; | |||||
| my ($lhs, $rhs, $j, $uip) = (undef, undef, undef, undef); | |||||
| my ($ucidr) = 0; | |||||
| my ($network, $bits, $netmask, $broadcast, $low, $high); | |||||
| if ($rawinput =~ qr/(.*)\/(.*)/){ | |||||
| $lhs = $1; $rhs = $2; | |||||
| }else{ | |||||
| die "Input: $rawinput not expected.\n"; | |||||
| }; | |||||
| # | |||||
| # Handle ip/hostname for left hand side. | |||||
| if ($lhs =~ qr/(\d+)\.(\d+)\.(\d+)\.(\d+)/){ | |||||
| foreach my $dotted (($1,$2,$3,$4)){ | |||||
| if (($dotted > 255) or ($dotted < 0)){ | |||||
| die "FATAL: ipv4 address entered, $lhs entered is impossible, $dotted is not between 0-255.\n"; | |||||
| }; | |||||
| }; | |||||
| $uip = "$1.$2.$3.$4"; | |||||
| }; | |||||
| # | |||||
| # Handle the netmask/cidr for the right hand side, | |||||
| # | |||||
| # All input netmasks are converted to a cidr address for notation | |||||
| if ($rhs =~ qr/^(\d+)$/){ # /cidr | |||||
| $ucidr = $1; | |||||
| die "FATAL: Invalid CIDR <$ucidr>.$!\n" if (($ucidr > 32) or ($ucidr < 0)); | |||||
| }elsif ($rhs =~ qr/(0[xX])?([0-9,a-f,A-F]{7})/){ # /0xhexnetmask | |||||
| my $trimmed = $2; | |||||
| my $insane = 0; | |||||
| foreach my $byte (split('', unpack("B32", pack("H*", $trimmed)))){ | |||||
| ($byte) ? $ucidr++ : $insane++; | |||||
| die "FATAL: $rhs is not a valid hex netmask.$!\n" if ($insane and $byte); | |||||
| }; | |||||
| }elsif ($rhs =~ qr/(\d+)\.(\d+)\.(\d+)\.(\d+)/){ # /255.255.255.0 form | |||||
| my @a = ($1, $2, $3, $4); | |||||
| my $insane = 0; | |||||
| foreach my $t (@a){ | |||||
| die "FATAL: Netmask out of range. Input <$rhs> Invalid <$t>$!\n" if (($t < 0) or ($t > 255)); | |||||
| }; | |||||
| foreach my $byte (split('', unpack("B32", pack("C4", @a)))){ | |||||
| ($byte) ? $ucidr++ : $insane++; | |||||
| die "FATAL: $rhs is not a valid netmask.$!\n" if ($insane and $byte); | |||||
| }; | |||||
| }else{ | |||||
| die "FATAL: Unknown or invalid netmask value entered. <$rhs>\n"; | |||||
| }; | |||||
| # | |||||
| # Network math GO! This is the meat of the function. | |||||
| my (@uip) = split(/\./, $uip); | |||||
| $network = 0; | |||||
| for ($j = 0; $j <= $#uip; $j++){ | |||||
| $network += int($uip[$j])<<((3-$j)*8); | |||||
| }; | |||||
| $bits = 0; $j = 0; | |||||
| for ($j = 31 - $ucidr; $j >= 0; $j--){ | |||||
| $bits |= 1<<$j; | |||||
| }; | |||||
| $netmask = 0xffffffff^$bits; | |||||
| $low = ($network&$netmask); | |||||
| $high = ($network&$netmask)+$bits-1; | |||||
| $broadcast = ($network&$netmask)|$bits; | |||||
| # | |||||
| # Throw the info back, they get a hash with zie info they may/may not need. | |||||
| # All up to the caller what they want to use. | |||||
| # | |||||
| return ("inet4" => $uip, | |||||
| "netmask" => int2ip($netmask), | |||||
| "broadcast" => int2ip($broadcast), | |||||
| "cidr" => $ucidr, | |||||
| "router" => int2ip($low+1), | |||||
| "network" => int2ip($low), | |||||
| "high" => int2ip($high), | |||||
| ); | |||||
| }; | |||||
| my @ifout; | |||||
| if ($ENV{'TESTING'} ne '') { | |||||
| while(<>){ | |||||
| chomp($_); | |||||
| last if ($_ eq ''); | |||||
| push(@ifout, $_); | |||||
| # sleep 1; | |||||
| # print STDERR $_ . "\n"; | |||||
| } | |||||
| }else{ | |||||
| open IFCONFIG, "ifconfig -a |"; | |||||
| @ifout = <IFCONFIG>; | |||||
| close IFCONFIG; | |||||
| } | |||||
| # This seems wrong but it makes parsing easier due to solaris | |||||
| # non root ifconfig not displaying the mac address. Reverse the output. | |||||
| # | |||||
| @ifout = reverse(@ifout); | |||||
| my @output = (); | |||||
| my ($ifname, $ifether, $ifmtu, $ifipv4, $ifnetmask, $ifipv6) = (undef,undef,undef,undef,undef,undef); | |||||
| sub printiface{ | |||||
| # assume a /32 if we don't know it | |||||
| unless (defined($ifnetmask)) { | |||||
| warn "$ifname has indeterminant netmask assuming /32\n"; | |||||
| $ifnetmask = '32'; | |||||
| } | |||||
| unless (defined($ifnetmask)) { | |||||
| $ifether = 'unknown'; | |||||
| } | |||||
| unless ($ifname =~ m/lo.*/){ | |||||
| my %netinfo = cidr2raw("$ifipv4\/$ifnetmask"); | |||||
| $ifnetmask = $netinfo{"cidr"}; | |||||
| $ifether = lc($ifether); | |||||
| my $line = sprintf "%-16s %-18s %-17s\n", "$ifname\@$ifmtu", "$ifipv4\/$ifnetmask", $ifether; | |||||
| push @output, $line; | |||||
| } | |||||
| # reset vars | |||||
| ($ifname, $ifether, $ifmtu, $ifipv4, $ifnetmask, $ifipv6) = (undef,undef,undef,undef,undef,undef); | |||||
| }; | |||||
| foreach my $line (@ifout) { | |||||
| if ($line =~ /inet\s+(\d+[.]\d+[.]\d+[.]\d+)\s+/){ | |||||
| $ifipv4 = $1; | |||||
| } | |||||
| if ($line =~ m/ether\s([:,0-9,a-f,A-F]{11,})/){ | |||||
| $ifether =$1; | |||||
| } | |||||
| if ($line =~ m/^([\w,\:\d+]+)\s+.*HWaddr\s([:,0-9,a-f,A-F]{11,})/){ | |||||
| $ifname = $1; | |||||
| $ifether = $2; | |||||
| } | |||||
| if ($line =~ m/^(.*)\:\s+.*mtu\s(\d+)/){ | |||||
| $ifname = $1; | |||||
| $ifmtu = $2; | |||||
| } | |||||
| if ($line =~ m/MTU[:](\d+)/){ | |||||
| $ifmtu = $1; | |||||
| } | |||||
| if ($line =~ m/inet\saddr\:(\d+[.]\d+[.]\d+[.]\d+)/){ | |||||
| $ifipv4 = $1; | |||||
| } | |||||
| if ($line =~ m/netmask\s+(0[xX])?([a-f,A-F,0-9]{8})/){ | |||||
| $ifnetmask = $2; | |||||
| } | |||||
| if ($line =~ m/Mask[:](\d+\.\d+\.\d+\.\d+)/){ | |||||
| $ifnetmask = $1; | |||||
| } | |||||
| if ($line =~ m/netmask\s+(\d+[.]\d+[.]\d+[.]\d+)/){ | |||||
| $ifnetmask = $1; | |||||
| } | |||||
| if ($line =~ m/netmask\s+0\s+broadcast/){ | |||||
| $ifnetmask = '0'; | |||||
| } | |||||
| print ":$ifether:$ifname:$ifmtu:$ifipv4:$ifnetmask:$ifipv6:\n" if ($ENV{'DEBUG'} ne ''); | |||||
| printiface() if ($ifname and $ifmtu and $ifipv4 ); | |||||
| }; | |||||
| if (scalar(@output) < 1){ | |||||
| warn "No interfaces? Scripts busted yo.\n"; | |||||
| }else{ | |||||
| foreach my $line (reverse(@output)){ | |||||
| print $line; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,13 @@ | |||||
| #!/usr/bin/env perl | |||||
| #-*-mode: Perl; coding: utf-8;-*- | |||||
| use strict; | |||||
| use warnings; | |||||
| use POSIX qw(strftime); | |||||
| my $now = time; | |||||
| my $local_now = localtime $now; | |||||
| my $tz = strftime '%z', $local_now; | |||||
| $tz =~ s/(\d{2})(\d{2})/$1:$2/smx; | |||||
| my $time = strftime '%Y-%m-%dT%H:%M:%S', $local_now; | |||||
| print "$time$tz\n"; | |||||
| exit 0; | |||||
| @@ -0,0 +1,18 @@ | |||||
| #!/usr/bin/env perl | |||||
| # | |||||
| # Just opens a socket and tries to connect() to it. rc = 1 on failure, 0 success | |||||
| # | |||||
| use Socket; | |||||
| local $where = $ARGV[0]; | |||||
| local $port = $ARGV[1]; | |||||
| socket(SOCKET,PF_INET,SOCK_STREAM,(getprotobyname("tcp"))[2]); | |||||
| if(connect(SOCKET,sockaddr_in($port,inet_aton($where)))){ | |||||
| print "connect($where, $port) succeeded\n"; | |||||
| exit 0; | |||||
| }else{ | |||||
| print "connect($where, $port) failed\n"; | |||||
| exit 1; | |||||
| }; | |||||
| @@ -0,0 +1,171 @@ | |||||
| #!/usr/bin/env perl | |||||
| # | |||||
| # ptree for linux/darwin/solaris. I got sick of ps and pstree on linux. | |||||
| # ptree works on solaris fine, but doesn't exist for darwin/linux/etc... | |||||
| # | |||||
| # TODO: Allow passing a regexp instead of a pid and passing multiple pids. | |||||
| # | |||||
| local $ENV{"PATH"} = '/bin:/usr/bin:/sbin:/usr/sbin'; | |||||
| local $debug = 0; | |||||
| (exists($ENV{"DEBUG"})) ? $debug = 1 : undef; | |||||
| ($debug) ? local $| = 1 : undef; # disable buffering for STDERR and STDOUT | |||||
| sub debug_print { | |||||
| ($debug) && warn pop; | |||||
| }; | |||||
| local @cmd = ('/bin/ps'); | |||||
| local $init = 0; | |||||
| local $start = 1; | |||||
| if ($^O eq "linux"){ | |||||
| push(@cmd, 'ajxSw'); | |||||
| $start = 0; | |||||
| }elsif ($^O =~ m/darwin|freebsd/){ | |||||
| push(@cmd, 'Ajwww'); | |||||
| }elsif ($^O eq "solaris"){ | |||||
| @cmd = ('/usr/ucb/ps'); | |||||
| if ((-x "/bin/zonename") && !(qx(zonename) eq "global\n")){ | |||||
| $init = qx(pgrep zsched); | |||||
| chomp($init); | |||||
| $start = $init; | |||||
| }; | |||||
| push(@cmd, 'laxwww'); | |||||
| }else{ | |||||
| die "$^O isn't a known os to this script\n"; | |||||
| }; | |||||
| local @ps = qx(@cmd); | |||||
| ($?) ? die $cmd[0]." posix return code $?\n" : undef; | |||||
| local %proc; | |||||
| local @trail; | |||||
| (defined($ARGV[0])) ? $start = $ARGV[0] : undef; | |||||
| debug_print("Dump of raw line array data:\n"); | |||||
| foreach my $x (@ps){ | |||||
| my $cmd_index = 9; | |||||
| my $ppid = -1; | |||||
| my $pid = -1; | |||||
| next if ($x =~ m/.*PID.*/); | |||||
| my @line = split(m/\s+/,$x); | |||||
| splice(@line, 0, 1) unless ($line[0] =~ m/\d+/); | |||||
| splice(@line, 0, 1) if ("$line[0]" eq ""); | |||||
| if ($^O eq "linux"){ | |||||
| ($ppid,$pid) = @line; | |||||
| $cmd_index = 9; | |||||
| }elsif ($^O =~ m/darwin|freebsd/){ | |||||
| ($pid,$ppid) = @line; | |||||
| $cmd_index = 8; | |||||
| }elsif ($^O eq "solaris"){ | |||||
| (undef, undef, $pid,$ppid) = @line; | |||||
| for($x=$cmd_index; $x < 14; $x++){ | |||||
| $cmd_index = ($line[$x] =~ m/\d+\:\d+/) ? ($x + 1) : $cmd_index; | |||||
| }; | |||||
| }; | |||||
| my $command = join(' ', @line[$cmd_index..$#line++]); | |||||
| (!defined $proc{$pid}) ? $proc{$pid}->{"children"} = [ ] : undef; | |||||
| (!defined $proc{$ppid}) ? $proc{$ppid}->{"children"} = [ ] : undef; | |||||
| $proc{$pid}->{"pid"} = $pid; | |||||
| $proc{$pid}->{"command"} = $command; | |||||
| $proc{$pid}->{"ppid"} = $ppid; | |||||
| push(@{$proc{$ppid}->{"children"}},$pid); | |||||
| debug_print(join(',', @line[0..($#line-1)])."\n"); | |||||
| }; | |||||
| if ($debug){ | |||||
| debug_print("Done reading ps output\nDump of Hash\n"); | |||||
| foreach my $key (sort({$a <=> $b} (keys %proc))){ | |||||
| $ppid = $proc{$key}->{"ppid"}; | |||||
| $command = $proc{$key}->{"command"}; | |||||
| $children = join(',', @{$proc{$key}->{"children"}}); | |||||
| debug_print("PID<$key> PPID<$ppid> Children<$children> Command<$command>\n"); | |||||
| }; | |||||
| }; | |||||
| sub intrail{ | |||||
| my $crumb = pop; | |||||
| my $ret = 0; | |||||
| map {$ret++ if ($crumb == $_)} @trail; | |||||
| return $ret; | |||||
| }; | |||||
| sub addchildren{ | |||||
| my $start_node = pop; | |||||
| foreach my $child (@{$proc{$start_node}->{"children"}}){ | |||||
| next if (!defined($child) || ($start_node == $child)); | |||||
| debug_print("Start ($start_node) Add child $child.\n"); | |||||
| push(@trail, $child); | |||||
| addchildren($child); | |||||
| }; | |||||
| }; | |||||
| sub addparents{ | |||||
| my $start_node = pop; | |||||
| my $parent = $proc{$start_node}->{"ppid"}; | |||||
| return unless (defined($start_node)); | |||||
| return if (($parent == $start_node) || !(defined($parent))); # At the top of the tree, or in a zone | |||||
| debug_print("Start ($start_node) Add parent $parent.\n"); | |||||
| push(@trail, $parent); | |||||
| addparents($parent) if ($parent != $init); | |||||
| }; | |||||
| sub printnode{ | |||||
| my $start_node = pop; | |||||
| my $indent = pop; | |||||
| if (intrail($start_node)){ | |||||
| my $pid = $proc{$start_node}->{"pid"}; | |||||
| my $ppid = $proc{$start_node}->{"ppid"}; | |||||
| my $cmdline = $proc{$start_node}->{"command"}; | |||||
| my $indentation = ' 'x($indent); | |||||
| if ($pid == $init){ | |||||
| my $s = $^O." kernel"; | |||||
| if ($cmdline ne ''){ | |||||
| $s = $s." <$cmdline>"; | |||||
| }; | |||||
| $cmdline = $s; | |||||
| }; | |||||
| printf("%s%d %s\n", $indentation, $pid, $cmdline); | |||||
| foreach my $child (@{$proc{$start_node}->{"children"}}){ | |||||
| next if ($pid == $child); | |||||
| printnode($indent+1,$child); | |||||
| }; | |||||
| }; | |||||
| }; | |||||
| my $valid = 0; | |||||
| foreach my $j (keys %proc){ ($j == $start) ? $valid++ : undef; }; | |||||
| debug_print("Starting from <$start>, validity is<$valid>\n"); | |||||
| if ($valid){ | |||||
| if (!$start){ | |||||
| @trail = keys %proc; | |||||
| push(@trail, $start); push(@trail, 1); | |||||
| debug_print("Done with adding $start to trail.\n"); | |||||
| }else{ | |||||
| push(@trail, $start); | |||||
| debug_print("Adding children from $start.\n"); | |||||
| addchildren($start); | |||||
| debug_print("Adding parents from $start.\n"); | |||||
| addparents($start); | |||||
| }; | |||||
| @trail = sort(@trail); | |||||
| debug_print("Trail is: ".join(',', @trail)."\nStarting at pid $start\ninit pid $init\n"); | |||||
| print "PID COMMAND\n"; | |||||
| my $startindent = 0; | |||||
| (intrail($startindent)) ? $startindent = -1 : undef; | |||||
| printnode($startindent,$init); | |||||
| }else{ | |||||
| die "pid $start doesn't exist.\n"; | |||||
| }; | |||||
| exit 0; | |||||
| @@ -0,0 +1,20 @@ | |||||
| #!/usr/bin/env ruby | |||||
| # | |||||
| cal, today, week_color, day_color, reset = %x(cal).split(%r(\n)), Time.now.day, %x(tput sgr0;tput setab 4;tput setaf 7), %x(tput sgr0; tput setab 0;tput setaf 7;tput bold), %x(tput sgr0) | |||||
| done=false | |||||
| cal.each do |line| | |||||
| if done then | |||||
| puts line | |||||
| next | |||||
| end | |||||
| if(line =~ /^(.*\s+?)#{today}(\s+?.*)$/ or | |||||
| line =~ /^(.*\s+?)#{today}$/ or | |||||
| line =~ /^()#{today}(\s+?.*)$/ or | |||||
| line =~ /^#{today}$/ ) then | |||||
| puts "#{week_color}#{$1}#{day_color}#{today}#{week_color}#{$2}#{reset}" | |||||
| done=true | |||||
| else | |||||
| puts line | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,12 @@ | |||||
| #!/usr/bin/env perl | |||||
| # | |||||
| # Timestamp stdin and then print to stdout and flush. | |||||
| # | |||||
| # Thats about it. Might add a quick and dirty option to allow you to | |||||
| # specify the time output whatnot. But this is intended to be simple. | |||||
| # | |||||
| while(<STDIN>){ | |||||
| print localtime()." : ".$_; | |||||
| $stdout.flush; | |||||
| }; | |||||
| @@ -0,0 +1,31 @@ | |||||
| #!/usr/bin/env perl | |||||
| # | |||||
| # Because i'm lazy and sick of typing in getent passwd $someusername/uid | |||||
| # | |||||
| my %who_cmds = ("solaris", "/bin/who -q", | |||||
| "linux", "/usr/bin/who -q", | |||||
| "darwin", "/usr/bin/who -q", | |||||
| ); | |||||
| my $who_cmd = $who_cmds{$^O}; | |||||
| local %users = (); | |||||
| foreach my $l (qx/$who_cmd/){ | |||||
| next if($l =~ m/^\#.*/); | |||||
| foreach my $user (split(/\s+/,$l)){ | |||||
| unless(exists($users{$user})){ | |||||
| $users{$user} = 0; | |||||
| }else{ | |||||
| $users{$user}++; | |||||
| }; | |||||
| }; | |||||
| }; | |||||
| foreach my $user (keys %users){ | |||||
| my $gecos = ( getpwnam($user) )[6]; | |||||
| my $count = $users{$user} + 1; | |||||
| my $output = "$user\, ".((defined($gecos)) ? "$gecos, " : '')."is logged in on $count tty".(($count>1) ? "\'s" : '')."\n"; | |||||
| print $output; | |||||
| }; | |||||
| @@ -0,0 +1,7 @@ | |||||
| session* | |||||
| elpa | |||||
| tramp | |||||
| url | |||||
| ac-dict | |||||
| ac-comphist.dat | |||||
| .emacs.desktop* | |||||
| @@ -0,0 +1,12 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (require 'haskell-mode) | |||||
| (require 'haskell-process) | |||||
| (require 'haskell-simple-indent) | |||||
| (require 'haskell-interactive-mode) | |||||
| (require 'haskell-font-lock) | |||||
| (require 'haskell-debug) | |||||
| (require 'sgml-mode) | |||||
| (require 'css-mode) | |||||
| (require 'helm-config) | |||||
| (helm-mode 1) | |||||
| (color-theme-solarized-light) | |||||
| @@ -0,0 +1,68 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (require 'package) | |||||
| (setq my-packages | |||||
| '( | |||||
| helm | |||||
| dash | |||||
| s | |||||
| string-utils | |||||
| list-utils | |||||
| flycheck | |||||
| expand-region | |||||
| auto-complete | |||||
| auto-complete-clang-async | |||||
| magit | |||||
| smex | |||||
| column-marker | |||||
| ruby-end | |||||
| multi-term | |||||
| dropdown-list | |||||
| popup | |||||
| org-plus-contrib | |||||
| org-bullets | |||||
| org-pomodoro | |||||
| org-present | |||||
| color-theme | |||||
| perl-completion | |||||
| workgroups | |||||
| yasnippet | |||||
| figlet | |||||
| org-readme | |||||
| move-text | |||||
| smartparens | |||||
| markdown-mode | |||||
| yaml-mode | |||||
| go-mode | |||||
| rust-mode | |||||
| haskell-mode | |||||
| color-theme-solarized | |||||
| )) | |||||
| (package-initialize) | |||||
| (add-to-list 'package-archives | |||||
| '("melpa" . "http://melpa.milkbox.net/packages/")) | |||||
| (add-to-list 'package-archives | |||||
| '("gnu" . "http://elpa.gnu.org/packages/")) | |||||
| (add-to-list 'package-archives | |||||
| '("org" . "http://orgmode.org/elpa/")) | |||||
| ;; TODO: maybe set an ENV var to force refresh at startup? | |||||
| (when (not package-archive-contents) | |||||
| (package-refresh-contents)) | |||||
| (dolist (pkg my-packages) | |||||
| (when (and (not (package-installed-p pkg)) | |||||
| (assoc pkg package-archive-contents)) | |||||
| (package-install pkg))) | |||||
| (defun package-list-unaccounted-packages () | |||||
| "Like `package-list-packages', but shows only the packages that | |||||
| are installed and are not in `my-packages'. Useful for | |||||
| cleaning out unwanted packages." | |||||
| (interactive) | |||||
| (package-show-package-list | |||||
| (remove-if-not (lambda (x) (and (not (memq x my-packages)) | |||||
| (not (package-built-in-p x)) | |||||
| (package-installed-p x))) | |||||
| (mapcar 'car package-archive-contents)))) | |||||
| @@ -0,0 +1,66 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; In case I screw up something later, debug stuff | |||||
| (setq debug-on-error t) | |||||
| ;; Simplify os detection a skosh | |||||
| (defvar mswindows-p (string-match "windows" (symbol-name system-type)) | |||||
| "Am I running under windows?") | |||||
| (defvar osx-p (string-match "darwin" (symbol-name system-type)) | |||||
| "Am I running under osx?") | |||||
| (defvar linux-p (string-match "gnu/linux" (symbol-name system-type)) | |||||
| "Am I running under linux?") | |||||
| ;; Yes, I miss perl chomp, sue me | |||||
| (defun chomp (str) | |||||
| "Chomp leading and trailing whitespace from STR." | |||||
| (let ((s (if (symbolp str) (symbol-name str) str))) | |||||
| (replace-regexp-in-string "\\(^[[:space:]\n]*\\|[[:space:]\n]*$\\)" "" s))) | |||||
| ;; I'm not about to redo logic to setup PATH in emacs that I have in | |||||
| ;; .profile/.*shrc crap. | |||||
| ;; So, just use whatever PATH had when we were run. | |||||
| (defun set-exec-path-from-shell-PATH () | |||||
| (let ((path-from-shell | |||||
| (shell-command-to-string "$SHELL -i -c 'echo $PATH'"))) | |||||
| (setenv "PATH" path-from-shell) | |||||
| (setq exec-path (split-string path-from-shell path-separator)))) | |||||
| ;; This is really only needed when the gui emacs runs. | |||||
| (if osx-p | |||||
| (set-exec-path-from-shell-PATH) | |||||
| ) | |||||
| ;; Base directory | |||||
| (defvar load-base "~/.emacs.d" "Where the emacs directory is kept") | |||||
| ;; Bootstrap load path | |||||
| (add-to-list 'load-path load-base) | |||||
| ;; Temp file dir (unixes) | |||||
| (setq temporary-file-directory "/tmp") | |||||
| ;; Set the default temp file dir for the current user based off username | |||||
| (defvar user-temporary-file-directory | |||||
| (format "%s/%s" temporary-file-directory user-login-name)) | |||||
| ;; mkdir for temporary-file-directory if needed | |||||
| (unless (file-accessible-directory-p user-temporary-file-directory) | |||||
| (make-directory user-temporary-file-directory t)) | |||||
| ;; Load up settings of things, in no particular order or anything | |||||
| (mapcar 'load-file (directory-files "~/.emacs.d/settings/" t ".*.el$")) | |||||
| ;; Setup/install third party packages using builtin package manager. | |||||
| (load "emacs-package") | |||||
| ;; Load up settings for things that el-get installed | |||||
| (mapcar 'load-file (directory-files "~/.emacs.d/package-settings/" t ".*.el$")) | |||||
| ;; Cleanup startup buffers | |||||
| (add-hook 'after-init-hook | |||||
| '(lambda () (load "after-init"))) | |||||
| ;; Fine, emacsclient -c and emacs --daemon don't mix well | |||||
| ;; From now on I start emacs as a gui and have this startup the daemon | |||||
| (load "server") | |||||
| (unless (server-running-p) (server-start)) | |||||
| @@ -0,0 +1,56 @@ | |||||
| ;;; Clang-format emacs integration for use with C/Objective-C/C++. | |||||
| ;; This defines a function clang-format-region that you can bind to a key. | |||||
| ;; A minimal .emacs would contain: | |||||
| ;; | |||||
| ;; (load "<path-to-clang>/tools/clang-format/clang-format.el") | |||||
| ;; (global-set-key [C-M-tab] 'clang-format-region) | |||||
| ;; | |||||
| ;; Depending on your configuration and coding style, you might need to modify | |||||
| ;; 'style' in clang-format, below. | |||||
| (require 'json) | |||||
| ;; *Location of the clang-format binary. If it is on your PATH, a full path name | |||||
| ;; need not be specified. | |||||
| (defvar clang-format-binary "clang-format") | |||||
| (defun clang-format-region () | |||||
| "Use clang-format to format the currently active region." | |||||
| (interactive) | |||||
| (let ((beg (if mark-active | |||||
| (region-beginning) | |||||
| (min (line-beginning-position) (1- (point-max))))) | |||||
| (end (if mark-active | |||||
| (region-end) | |||||
| (line-end-position)))) | |||||
| (clang-format beg end))) | |||||
| (defun clang-format-buffer () | |||||
| "Use clang-format to format the current buffer." | |||||
| (interactive) | |||||
| (clang-format (point-min) (point-max))) | |||||
| (defun clang-format (begin end) | |||||
| "Use clang-format to format the code between BEGIN and END." | |||||
| (let* ((orig-windows (get-buffer-window-list (current-buffer))) | |||||
| (orig-window-starts (mapcar #'window-start orig-windows)) | |||||
| (orig-point (point)) | |||||
| (style "file")) | |||||
| (unwind-protect | |||||
| (call-process-region (point-min) (point-max) clang-format-binary | |||||
| t (list t nil) nil | |||||
| "-offset" (number-to-string (1- begin)) | |||||
| "-length" (number-to-string (- end begin)) | |||||
| "-cursor" (number-to-string (1- (point))) | |||||
| "-assume-filename" (buffer-file-name) | |||||
| "-style" style) | |||||
| (goto-char (point-min)) | |||||
| (let ((json-output (json-read-from-string | |||||
| (buffer-substring-no-properties | |||||
| (point-min) (line-beginning-position 2))))) | |||||
| (delete-region (point-min) (line-beginning-position 2)) | |||||
| (goto-char (1+ (cdr (assoc 'Cursor json-output)))) | |||||
| (dotimes (index (length orig-windows)) | |||||
| (set-window-start (nth index orig-windows) | |||||
| (nth index orig-window-starts))))))) | |||||
| @@ -0,0 +1,7 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (auto-complete-mode) | |||||
| (whitespace-mode) | |||||
| (smartparens-mode) | |||||
| (visual-line-mode) | |||||
| (setq indent-tabs-mode nil) | |||||
| (setq tab-width 2) | |||||
| @@ -0,0 +1,28 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (add-to-list 'auto-mode-alist '("\\.[chm]\\'" . c-mode)) | |||||
| (add-hook 'c-mode-common-hook | |||||
| '(lambda () | |||||
| (global-set-key "\C-x\C-m" 'compile) | |||||
| ;; c11 is best standard, silly c++11. | |||||
| (setq flycheck-clang-language-standard "c11") | |||||
| ;; Wait a bit for me to type things out guy. | |||||
| (setq flycheck-idle-change-delay 2) | |||||
| (setq flycheck-highlighting-mode 'symbols) | |||||
| (add-hook 'before-save-hook 'clang-format-buffer nil t) | |||||
| (auto-complete-mode) | |||||
| (whitespace-mode) | |||||
| (hl-line-mode) | |||||
| (visual-line-mode) | |||||
| (smartparens-mode) | |||||
| (flycheck-mode) | |||||
| (c-toggle-auto-state 1) | |||||
| (setq-default c-basic-offset 2 | |||||
| tab-width 2 | |||||
| indent-tabs-mode nil | |||||
| c-electric-flag t | |||||
| indent-level 2 | |||||
| c-default-style "bsd" | |||||
| backward-delete-function nil) | |||||
| )) | |||||
| @@ -0,0 +1,15 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (add-to-list 'auto-mode-alist '("\\.el" . emacs-lisp-mode)) | |||||
| (add-hook 'emacs-lisp-hook | |||||
| (lambda () | |||||
| (hl-line-mode) | |||||
| (whitespace-mode) | |||||
| (flycheck-mode) | |||||
| (setq-default tab-width 2) | |||||
| (setq-default indent-tabs-mode nil) | |||||
| (define-key emacs-lisp-map | |||||
| "\C-x\C-e" 'pp-eval-last-sexp) | |||||
| (define-key emacs-lisp-map | |||||
| "\r" 'reindent-then-newline-and-indent))) | |||||
| @@ -0,0 +1,11 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (add-hook 'go-mode-hook '(lambda () | |||||
| (add-hook 'before-save-hook #'gofmt-before-save) | |||||
| (smartparens-mode) | |||||
| (auto-complete-mode) | |||||
| (hl-line-mode) | |||||
| (visual-line-mode) | |||||
| (whitespace-mode) | |||||
| (setq tab-width 8) | |||||
| )) | |||||
| @@ -0,0 +1,89 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (custom-set-variables | |||||
| '(haskell-process-type 'ghci) | |||||
| '(haskell-process-args-ghci '()) | |||||
| '(haskell-notify-p t) | |||||
| '(haskell-stylish-on-save nil) | |||||
| '(haskell-tags-on-save t) | |||||
| '(haskell-process-suggest-remove-import-lines t) | |||||
| '(haskell-process-auto-import-loaded-modules t) | |||||
| '(haskell-process-log t) | |||||
| '(haskell-process-reload-with-fbytecode nil) | |||||
| '(haskell-process-use-presentation-mode t) | |||||
| '(haskell-interactive-mode-include-file-name nil) | |||||
| '(haskell-interactive-mode-eval-pretty nil) | |||||
| ;; '(shm-use-hdevtools t) | |||||
| ;; '(shm-use-presentation-mode t) | |||||
| ;; '(shm-auto-insert-skeletons t) | |||||
| ;; '(shm-auto-insert-bangs t) | |||||
| '(haskell-process-show-debug-tips nil) | |||||
| '(haskell-process-suggest-hoogle-imports nil) | |||||
| '(haskell-process-suggest-haskell-docs-imports t)) | |||||
| (setq haskell-complete-module-preferred | |||||
| '("Data.ByteString" | |||||
| "Data.ByteString.Lazy" | |||||
| "Data.Function" | |||||
| "Data.List" | |||||
| "Data.Map" | |||||
| "Data.Maybe" | |||||
| "Data.Monoid" | |||||
| "Data.Ord")) | |||||
| (autoload 'ghc-init "ghc" nil t) | |||||
| (autoload 'ghc-debug "ghc" nil t) | |||||
| (add-hook | |||||
| 'haskell-mode-hook | |||||
| '(lambda () | |||||
| (ghc-init) | |||||
| (setq haskell-interactive-mode-eval-mode 'haskell-mode) | |||||
| '(turn-on-haskell-indentation) | |||||
| (interactive-haskell-mode) | |||||
| (custom-set-variables | |||||
| '(haskell-process-suggest-remove-import-lines t) | |||||
| '(haskell-process-auto-import-loaded-modules t) | |||||
| '(haskell-process-log t) | |||||
| '(haskell-tags-on-save t) | |||||
| '(haskell-process-type 'cabal-repl) | |||||
| ) | |||||
| (define-key haskell-mode-map (kbd "C-c C-l") 'haskell-process-load-or-reload) | |||||
| (define-key haskell-mode-map (kbd "C-`") 'haskell-interactive-bring) | |||||
| (define-key haskell-mode-map (kbd "C-c C-n C-t") 'haskell-process-do-type) | |||||
| (define-key haskell-mode-map (kbd "C-c C-n C-i") 'haskell-process-do-info) | |||||
| (define-key haskell-mode-map (kbd "C-c C-n C-c") 'haskell-process-cabal-build) | |||||
| (define-key haskell-mode-map (kbd "C-c C-n c") 'haskell-process-cabal) | |||||
| (define-key haskell-mode-map (kbd "SPC") 'haskell-mode-contextual-space) | |||||
| (define-key haskell-mode-map (kbd "M-.") 'haskell-mode-jump-to-def-or-tag) | |||||
| (define-key haskell-mode-map [f8] 'haskell-navigate-imports) | |||||
| ) | |||||
| ) | |||||
| (add-hook 'cabal-mode-hook (lambda () | |||||
| (define-key haskell-cabal-mode-map (kbd "C-`") 'haskell-interactive-bring) | |||||
| (define-key haskell-cabal-mode-map (kbd "C-c C-k") 'haskell-interactive-ode-clear) | |||||
| (define-key haskell-cabal-mode-map (kbd "C-c C-c") 'haskell-process-cabal-build) | |||||
| (define-key haskell-cabal-mode-map (kbd "C-c c") 'haskell-process-cabal))) | |||||
| ;; (stylish-haskell-mode) | |||||
| ;; (define-key haskell-mode-map | |||||
| ;; (kbd "C-x C-s") 'haskell-mode-save-buffer) | |||||
| ;; (add-to-list 'align-rules-list | |||||
| ;; '(haskell-types | |||||
| ;; (regexp . "\\(\\s-+\\)\\(::\\|∷\\)\\s-+") | |||||
| ;; (modes quote (haskell-mode literate-haskell-mode)))) | |||||
| ;; (add-to-list 'align-rules-list | |||||
| ;; '(haskell-assignment | |||||
| ;; (regexp . "\\(\\s-+\\)=\\s-+") | |||||
| ;; (modes quote (haskell-mode literate-haskell-mode)))) | |||||
| ;; (add-to-list 'align-rules-list | |||||
| ;; '(haskell-arrows | |||||
| ;; (regexp . "\\(\\s-+\\)\\(->\\|→\\)\\s-+") | |||||
| ;; (modes quote (haskell-mode literate-haskell-mode)))) | |||||
| ;; (add-to-list 'align-rules-list | |||||
| ;; '(haskell-left-arrows | |||||
| ;; (regexp . "\\(\\s-+\\)\\(<-\\|←\\)\\s-+") | |||||
| ;; (modes quote (haskell-mode literate-haskell-mode)))) | |||||
| ;; )) | |||||
| ;; MOVE ME | |||||
| (global-set-key (kbd "C-x a r") 'align-regexp) | |||||
| @@ -0,0 +1,14 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (autoload 'makefile-mode "makefile-mode" "mode for makefile stuff" t) | |||||
| (add-to-list 'auto-mode-alist '("\\.[Mm]akefile\\'" . makefile-mode)) | |||||
| (add-to-list 'auto-mode-alist '("\\.GNUMakefile\\'" . makefile-mode)) | |||||
| (add-hook 'makefile-mode-hook | |||||
| '(lambda () | |||||
| (hl-line-mode) | |||||
| (smartparens-mode) | |||||
| (whitespace-mode) | |||||
| (visual-line-mode) | |||||
| (setq tab-width 4))) | |||||
| @@ -0,0 +1,14 @@ | |||||
| ;;-*-mode: Emacs-Lisp; coding: utf-8;-*- | |||||
| (add-to-list 'auto-mode-alist '("\\.org\>" . org-mode)) | |||||
| (add-hook 'org-mode-hook | |||||
| (lambda () | |||||
| (ispell-minor-mode) | |||||
| (visual-line-mode) | |||||
| (hl-line-mode) | |||||
| (delete '("\\.pdf\\'" . default) org-file-apps) | |||||
| (if osx-p | |||||
| (add-to-list 'org-file-apps '("\\.pdf\\'" . "open %s")) | |||||
| (add-to-list 'org-file-apps '("\\.pdf\\'" . "evince %s"))) | |||||
| )) | |||||
| @@ -0,0 +1,12 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (autoload 'cperl-mode "cperl-mode" "mode for perl scripts" t) | |||||
| (add-to-list 'auto-mode-alist '("\\.[Pp][LlMm]\\'" . cperl-mode)) | |||||
| (add-hook 'cperl-mode-hook | |||||
| '(lambda () | |||||
| (load "mode-defaults") | |||||
| (smartparens-mode) | |||||
| (flycheck-mode) | |||||
| )) | |||||
| @@ -0,0 +1,9 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (add-hook 'python-mode-hook | |||||
| '(lambda () | |||||
| (load "mode-defaults") | |||||
| (smartparens-mode) | |||||
| (flycheck-mode) | |||||
| (flycheck-select-checker 'python-flake8) | |||||
| )) | |||||
| @@ -0,0 +1,18 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (autoload 'ruby-mode "ruby-mode" "mode for Ruby formatted stuff" t) | |||||
| (add-to-list 'auto-mode-alist '("\\.rb\\'" . ruby-mode)) | |||||
| (add-to-list 'auto-mode-alist '("\\.rake\\'" . ruby-mode)) | |||||
| (add-to-list 'auto-mode-alist '("\\.gemspec\\'" . ruby-mode)) | |||||
| (add-to-list 'auto-mode-alist '("Gemfile\\'" . ruby-mode)) | |||||
| (add-to-list 'auto-mode-alist '("Rakefile\\'" . ruby-mode)) | |||||
| (add-to-list 'auto-mode-alist '("Vagrantfile\\'" . ruby-mode)) | |||||
| (add-hook 'ruby-mode-hook | |||||
| '(lambda () | |||||
| (load "mode-defaults") | |||||
| (smartparens-mode) | |||||
| (ruby-end-mode) | |||||
| (flycheck-mode) | |||||
| )) | |||||
| @@ -0,0 +1,33 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (add-hook 'rust-mode-hook '(lambda () (interactive) (column-marker-1 80))) | |||||
| (add-hook 'rust-mode-hook '(lambda () | |||||
| (smartparens-mode) | |||||
| (auto-complete-mode) | |||||
| (hl-line-mode) | |||||
| (visual-line-mode) | |||||
| (whitespace-mode) | |||||
| (setq tab-width 8) | |||||
| (flycheck-mode) | |||||
| )) | |||||
| (defun rust-run-current-buffers-file () | |||||
| "run a command on the current file" | |||||
| (interactive) | |||||
| (shell-command | |||||
| (format "rust run %s 2>&1 | grep -v 'no debug symbols in executable'" | |||||
| (shell-quote-argument (buffer-file-name)))) | |||||
| ) | |||||
| (defun rust-test-current-buffers-file () | |||||
| "run a command on the current file" | |||||
| (interactive) | |||||
| (shell-command | |||||
| (format "rust test %s 2>&1 | grep -v 'no debug symbols in executable'" | |||||
| (shell-quote-argument (buffer-file-name)))) | |||||
| ) | |||||
| (eval-after-load 'rust-mode | |||||
| '(define-key rust-mode-map (kbd "C-c C-r") 'rust-run-current-buffers-file)) | |||||
| (eval-after-load 'rust-mode | |||||
| '(define-key rust-mode-map (kbd "C-S-t") 'rust-test-current-buffers-file)) | |||||
| @@ -0,0 +1,18 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (autoload 'sh--mode "sh-mode" "mode for shell stuff" t) | |||||
| (add-to-list 'auto-mode-alist '("\\.sh$\\'" . sh-mode)) | |||||
| (add-to-list 'auto-mode-alist '("\\.[zk]sh$\\'" . sh-mode)) | |||||
| (add-to-list 'auto-mode-alist '("\\.bash$\\'" . sh-mode)) | |||||
| (add-to-list 'auto-mode-alist '("\\[.].*shrc$\\'" . sh-mode)) | |||||
| (add-to-list 'auto-mode-alist '("sourceme$\\'" . sh-mode)) | |||||
| (add-hook 'sh-mode-hook | |||||
| '(lambda () | |||||
| (load "mode-defaults") | |||||
| (smartparens-mode) | |||||
| (flycheck-mode) | |||||
| (setq-default indent-tabs-mode nil) | |||||
| (setq sh-basic-offset 2 sh-indentation 4 | |||||
| sh-indent-for-case-label 0 sh-indent-for-case-alt '+))) | |||||
| @@ -0,0 +1,5 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; autopair, its awesome for non lisps and ()'s []'s etc... | |||||
| (require 'autopair nil 'noerror) | |||||
| (setq autopair-blink 'nil) | |||||
| @@ -0,0 +1,21 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; use gtk-ide for my color theme, solarized has... issues. | |||||
| ;; aka with it setup, even from latest git source, it seems to crash | |||||
| ;; connections with emacsclient due to some face issue. | |||||
| ;; so eff it, ignore the thing. TODO: find out how/why | |||||
| ;; emacs segv's on linux/osx with it on, but i'm lazy prolly won't | |||||
| (color-theme-initialize) | |||||
| (if (or window-system osx-p) | |||||
| (color-theme-gtk-ide) | |||||
| (color-theme-hober)) | |||||
| (unless (or window-system osx-p) | |||||
| (color-theme-install-frame-params | |||||
| '((background-color . "white")))) | |||||
| ;; fixup multi-term fg/bg color support as it doesn't always | |||||
| ;; pickup defaults | |||||
| (setq term-default-bg-color (face-background 'default)) | |||||
| (setq term-default-fg-color (face-foreground 'default)) | |||||
| @@ -0,0 +1,4 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; expand region is awesome for selecting ever increasing regions. | |||||
| (global-set-key (kbd "C-]") 'er/expand-region) | |||||
| @@ -0,0 +1,26 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; flymake is old, lets use something better. | |||||
| (setq flycheck-indication-mode 'right-fringe) | |||||
| ;; Test out grizzl for completions. | |||||
| ;;(setq flycheck-select-checker 'grizzl) | |||||
| ;; Make flycheck able to parse CFLAGS from pkg-config | |||||
| (defun pkg-config-add-lib-cflags (pkg-config-lib) | |||||
| "This function will add necessary header file path of a | |||||
| specified by `pkg-config-lib' to `flycheck-clang-include-path', which make it | |||||
| completionable by auto-complete-clang" | |||||
| (interactive "spkg-config lib: ") | |||||
| (if (executable-find "pkg-config") | |||||
| (if (= (shell-command | |||||
| (format "pkg-config %s" pkg-config-lib)) | |||||
| 0) | |||||
| (setq flycheck-clang-include-path | |||||
| (append flycheck-clang-include-path | |||||
| (split-string | |||||
| (shell-command-to-string | |||||
| (format "pkg-config --cflags-only-I %s" | |||||
| pkg-config-lib))))) | |||||
| (message "Error, pkg-config lib %s not found." pkg-config-lib)) | |||||
| (message "Error: pkg-config tool not found."))) | |||||
| @@ -0,0 +1,4 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; make magit mode simpler to use | |||||
| (global-set-key (kbd "C-x m") 'magit-status) | |||||
| @@ -0,0 +1,2 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (move-text-default-bindings) | |||||
| @@ -0,0 +1,26 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; multi-term only on non-windows, stupid windows command line | |||||
| (unless mswindows-p | |||||
| ;; multi-term setup | |||||
| (autoload 'multi-term "multi-term" nil t) | |||||
| (autoload 'multi-term-next "multi-term" nil t) | |||||
| ;; fuck you audible beeps | |||||
| (setq ring-bell-function (lambda () (message "*beep beep imma jeep*"))) | |||||
| ;; try and use zsh when we can, cause bourne/bourne-again are the suck | |||||
| (setq multi-term-program (cond | |||||
| ((file-exists-p "/bin/zsh") "/bin/zsh") | |||||
| ((file-exists-p "/usr/bin/zsh") "/usr/bin/zsh") | |||||
| ((t) "/bin/sh");; fine use whatever the hell /bin/sh is | |||||
| )) | |||||
| ;; allow switching to the next terminal in line | |||||
| (global-set-key (kbd "C-c C-t") 'multi-term-next) | |||||
| ;; zomg annoying, term-unbind-key-list is what it unbinds, not what you want | |||||
| ;; to unbind. bit of a logic weirdout in my mind. | |||||
| ;; aka, what is in the term-unbind-key-list is what you can type to the terminal | |||||
| (setq term-unbind-key-list '("C-x" "C-y" "M-x")) | |||||
| ) | |||||
| @@ -0,0 +1,12 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (require 'org-install) | |||||
| (add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) | |||||
| (define-key global-map "\C-ca" 'org-agenda) | |||||
| (define-key global-map "\C-cb" 'org-iswitchb) | |||||
| (define-key global-map "\C-cc" 'org-capture) | |||||
| (define-key global-map "\C-cl" 'org-store-link) | |||||
| (define-key global-map "\C-cp" 'org-latex-export-to-pdf) | |||||
| (setq org-log-done t) | |||||
| @@ -0,0 +1,5 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; setup uniquify for buffer names | |||||
| (require 'uniquify) | |||||
| (setq uniquify-buffer-name-style 'post-forward) | |||||
| @@ -0,0 +1,11 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (when osx-p | |||||
| (setq exec-path | |||||
| (append exec-path | |||||
| '("/Users/mitch/homebrew/Cellar/llvm/3.4/bin")))) | |||||
| (when linux-p | |||||
| (setq exec-path (append '("/home/mitch/local/bin") exec-path))) | |||||
| (load "~/.emacs.d/misc/clang-format.el") | |||||
| (global-set-key [C-M-tab] 'clang-format-region) | |||||
| @@ -0,0 +1,9 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; Get rid of all of the stupid "look here's emacs" kthxbai | |||||
| (setq inhibit-startup-message t) | |||||
| (setq inhibit-startup-screen t) | |||||
| (setq inhibit-startup-echo-area-message t) | |||||
| ;; Update non-edited files changed on disk automatically | |||||
| (setq global-auto-revert-mode t) | |||||
| @@ -0,0 +1,18 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; desktop saving for session sanity, add a hook into auto-save-hook | |||||
| ;; to save it at logical times | |||||
| (require 'desktop) | |||||
| (desktop-save-mode 1) | |||||
| (setq desktop-path '("~/.emacs.d/")) | |||||
| (setq desktop-dirname "~/.emacs.d") | |||||
| (setq desktop-base-file-name ".emacs.desktop") | |||||
| (defun local-desktop-save () | |||||
| (interactive) | |||||
| (if (eq (desktop-owner) (emacs-pid)) | |||||
| (desktop-save desktop-dirname))) | |||||
| (add-hook 'auto-save-hook 'desktop-save-in-desktop-dir) | |||||
| @@ -0,0 +1,2 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (add-hook 'dired-load-hook (function (lambda () (load "dired-x")))) | |||||
| @@ -0,0 +1,25 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; if I selected it, deleting it is OK kthxbai | |||||
| (delete-selection-mode 1) | |||||
| ;; be more like vi, display line/col always | |||||
| (custom-set-variables '(line-number-mode t)) | |||||
| (custom-set-variables '(column-number-mode t)) | |||||
| ;; 80 char lines not 72 | |||||
| (custom-set-variables '(fill-column 80)) | |||||
| ;; ok, double spacing after a period for sentences | |||||
| ;; is fucking archaic, we don't use typewriters any longer | |||||
| (set-default 'sentence-end-double-space nil) | |||||
| ;; What emacs thinks a sentence ending is, make it less derp. | |||||
| (custom-set-variables '(sentence-end "[.?!][]\"')]*\\($\\|\t\\| \\)[ \t\n]*")) | |||||
| (custom-set-variables '(sentence-end-double-space nil)) | |||||
| ;; Tabs suck, no | |||||
| (custom-set-variables '(default-tab-width 2)) | |||||
| ;; Always remove trailing whitespace | |||||
| (add-hook 'before-save-hook 'delete-trailing-whitespace) | |||||
| @@ -0,0 +1,4 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (setq ediff-window-setup-function 'ediff-setup-windows-plain) | |||||
| (setq ediff-split-window-function 'split-window-horizontally) | |||||
| @@ -0,0 +1,8 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; utf8 by default | |||||
| (custom-set-variables '(locale-coding-system 'utf-8)) | |||||
| (set-terminal-coding-system 'utf-8) | |||||
| (set-keyboard-coding-system 'utf-8) | |||||
| (set-selection-coding-system 'utf-8) | |||||
| (prefer-coding-system 'utf-8) | |||||
| @@ -0,0 +1,45 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; Default file template definitions | |||||
| (add-hook 'find-file-hooks 'maybe-load-template) | |||||
| (setq template-file-prefix (concat (getenv "HOME") "/.emacs.d/templates")) | |||||
| (defun maybe-load-template () | |||||
| (interactive) | |||||
| (when (and | |||||
| (string-match "\\.rb$" (buffer-file-name)) | |||||
| (eq 1 (point-max))) | |||||
| (insert-file (concat template-file-prefix "/ruby.rb")) | |||||
| (ruby-mode)) | |||||
| (when (and | |||||
| (string-match "\\.sh$" (buffer-file-name)) | |||||
| (eq 1 (point-max))) | |||||
| (insert-file (concat template-file-prefix "/shell.sh")) | |||||
| (sh-mode)) | |||||
| (when (and | |||||
| (string-match "\\.ksh$" (buffer-file-name)) | |||||
| (eq 1 (point-max))) | |||||
| (insert-file (concat template-file-prefix "/shell.ksh")) | |||||
| (sh-mode)) | |||||
| (when (and | |||||
| (string-match "\\.pl$" (buffer-file-name)) | |||||
| (eq 1 (point-max))) | |||||
| (insert-file (concat template-file-prefix "/perl.pl")) | |||||
| (perl-mode)) | |||||
| (when (and | |||||
| (string-match "\\.py$" (buffer-file-name)) | |||||
| (eq 1 (point-max))) | |||||
| (insert-file (concat template-file-prefix "/python.py")) | |||||
| (python-mode)) | |||||
| (when (and | |||||
| (string-match "\\.pm$" (buffer-file-name)) | |||||
| (eq 1 (point-max))) | |||||
| (insert-file (concat template-file-prefix "/perl-module.pm")) | |||||
| (perl-mode)) | |||||
| (when (and | |||||
| (string-match "\\.el$" (buffer-file-name)) | |||||
| (eq 1 (point-max))) | |||||
| (insert-file (concat template-file-prefix "/elisp.el")) | |||||
| (emacs-lisp-mode)) | |||||
| ) | |||||
| @@ -0,0 +1,21 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (when window-system | |||||
| (require 'cl) | |||||
| (defun font-candidate (&rest fonts) | |||||
| "Return first font that matches list of provided fonts." | |||||
| (find-if (lambda (f) (find-font (font-spec :name f))) fonts)) | |||||
| ;; Try out these fonts in order of preference depending on install status. | |||||
| (set-face-attribute 'default nil :font | |||||
| (font-candidate '"Source Code Pro-14:weight=normal" | |||||
| "Menlo-12:weight=normal" | |||||
| "Monaco-12:weight=normal")) | |||||
| (cond (linux-p | |||||
| (setq interprogram-paste-function 'x-cut-buffer-or-selection-value) | |||||
| (setq x-select-enable-clipboard t) | |||||
| ) | |||||
| ) | |||||
| ) | |||||
| @@ -0,0 +1,16 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; show what is being typed quicker | |||||
| (custom-set-variables '(echo-keystrokes 0.1)) | |||||
| ;; Let shift+arrow keys change panes | |||||
| (require 'windmove) | |||||
| (windmove-default-keybindings) | |||||
| ;; Ok, so make it possible to use option+char on osx to type accented | |||||
| ;; chars in cocoa emacs. | |||||
| ;; Also makes command is meta. | |||||
| (when window-system | |||||
| (cond (osx-p | |||||
| (setq mac-option-modifier 'none) | |||||
| (setq mac-command-modifier 'meta)))) | |||||
| @@ -0,0 +1,9 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (when window-system | |||||
| (tool-bar-mode -1)) | |||||
| (when window-system | |||||
| (scroll-bar-mode -1)) | |||||
| (menu-bar-mode -1) | |||||
| @@ -0,0 +1,33 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; use incremental complete mode for the minibuffer | |||||
| (icomplete-mode) | |||||
| ;; highlight parens n stuff | |||||
| (show-paren-mode) | |||||
| ;; y/n is good enough | |||||
| (defalias 'yes-or-no-p 'y-or-n-p) | |||||
| ;; Default major mode is just text | |||||
| (custom-set-variables '(default-major-mode 'text-mode)) | |||||
| ;; Don't clobber minibuffer text | |||||
| (custom-set-variables '(help-at-pt-timer-delay 0.9)) | |||||
| ;; Auto chmod u+x on scripts, because why wouldn't you? | |||||
| (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) | |||||
| ;; Ok backup files are annoying | |||||
| (setq make-backup-files nil) | |||||
| (setq auto-save-default nil) | |||||
| ;; What to do with backup crap/autosave files | |||||
| (setq backup-by-copying t) | |||||
| (setq backup-directory-alist | |||||
| `((".*" . ,user-temporary-file-directory) | |||||
| (,tramp-file-name-regexp nil))) | |||||
| (setq auto-save-list-file-prefix | |||||
| (concat user-temporary-file-directory ".auto-saves-")) | |||||
| (setq auto-save-file-name-transforms | |||||
| `((".*" ,user-temporary-file-directory t))) | |||||
| @@ -0,0 +1,33 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (custom-set-variables '(mode-line-format | |||||
| (list | |||||
| '(:eval (propertize "%b " 'face 'font-lock-keyword-face | |||||
| 'help-echo (buffer-file-name))) | |||||
| (propertize "%02l" 'face 'font-lock-type-face) "," | |||||
| (propertize "%02c" 'face 'font-lock-type-face) | |||||
| " [" | |||||
| '(:eval (propertize "%m" 'face 'font-lock-string-face | |||||
| 'help-echo buffer-file-coding-system)) | |||||
| minor-mode-alist | |||||
| "] " | |||||
| "[" | |||||
| '(:eval (propertize (if overwrite-mode "Ovr" "Ins") | |||||
| 'face 'font-lock-preprocessor-face | |||||
| 'help-echo (concat "Buffer is in " | |||||
| (if overwrite-mode "overwrite" "insert") " mode"))) | |||||
| '(:eval (when (buffer-modified-p) | |||||
| (concat "," (propertize "Mod" | |||||
| 'face 'font-lock-warning-face | |||||
| 'help-echo "Buffer has been modified")))) | |||||
| '(:eval (when buffer-read-only | |||||
| (concat "," (propertize "RO" | |||||
| 'face 'font-lock-type-face | |||||
| 'help-echo "Buffer is read-only")))) "] " | |||||
| '(:eval (propertize (format-time-string "%H:%M:%S") | |||||
| 'help-echo | |||||
| (concat (format-time-string "%c; ") | |||||
| (emacs-uptime "Uptime:%hh")))) | |||||
| " --" | |||||
| "%-" | |||||
| ))) | |||||
| @@ -0,0 +1,4 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; Load/setup mode hook file(s) in ~/modes | |||||
| (mapcar 'load-file (directory-files "~/.emacs.d/modes" t ".*.el$")) | |||||
| @@ -0,0 +1,9 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (unless window-system | |||||
| (require 'mouse) | |||||
| (xterm-mouse-mode t) | |||||
| (defun track-mouse (e)) | |||||
| (setq mouse-sel-mode t) | |||||
| (global-set-key [mouse-5] '(lambda () (interactive) (scroll-up 1))) | |||||
| (global-set-key [mouse-4] '(lambda () (interactive) (scroll-down 1)))) | |||||
| @@ -0,0 +1,5 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| (require 'recentf) | |||||
| (recentf-mode 1) | |||||
| (setq recentf-max-menu-items 25) | |||||
| (global-set-key "\C-x\ \C-r" 'recentf-open-files) | |||||
| @@ -0,0 +1,11 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; I only want the time in my modeline, not system load | |||||
| ;; %T is HH:MM:SS basically | |||||
| ;; Also update every 5 seconds instead of 60 | |||||
| (custom-set-variables '(display-time-default-load-average nil)) | |||||
| (custom-set-variables '(display-time-format "%T")) | |||||
| (custom-set-variables '(display-time-interval 5)) | |||||
| ;; Set the time in the mode line | |||||
| (display-time-mode) | |||||
| @@ -0,0 +1,27 @@ | |||||
| ;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ; Tramp mode setup | |||||
| (require 'tramp) | |||||
| ; Make the default proxy list sane(r) | |||||
| (set-default 'tramp-default-proxies-alist | |||||
| (quote ((".*" "\\`root\\'" "/ssh:%h:")))) | |||||
| ; Since work sudo only allows for su with sudo. | |||||
| ; We add a new 'susudo' method that uses | |||||
| ; sudo args USER su -c 'command you wanted to run' | |||||
| ; instead of sudo command | |||||
| ; gay but pci "security" can be pretty dumb | |||||
| (add-to-list 'tramp-methods | |||||
| '("susudo" | |||||
| (tramp-login-program "sudo") | |||||
| (tramp-login-args | |||||
| (("-u" "%u") | |||||
| ("-H") | |||||
| ("-p" "Password:") | |||||
| ("su -c /bin/sh"))) | |||||
| (tramp-remote-sh "/bin/sh") | |||||
| (tramp-copy-program nil) | |||||
| (tramp-copy-args nil) | |||||
| (tramp-copy-keep-date nil) | |||||
| (tramp-password-end-of-line nil))) | |||||
| @@ -0,0 +1,14 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| ;; Setup whitespace mode to highlight tabs and over 80 char spaces | |||||
| (require 'whitespace) | |||||
| (setq whitespace-style '(face tabs trailing)) | |||||
| (set-face-attribute 'whitespace-tab nil | |||||
| :foreground "#2075c7" | |||||
| :background "lightgrey") | |||||
| (set-face-attribute 'whitespace-line nil | |||||
| :foreground "#2075c7" | |||||
| :background "lightgrey") | |||||
| @@ -0,0 +1 @@ | |||||
| ;;-*-mode: emacs-lisp; coding: utf-8;-*- | |||||
| @@ -0,0 +1,18 @@ | |||||
| #-*-mode: Perl; coding: utf-8;-*- | |||||
| package MyModule; | |||||
| use strict; | |||||
| use Exporter; | |||||
| use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); | |||||
| $VERSION = 1.00; | |||||
| @ISA = qw(Exporter); | |||||
| @EXPORT = (); | |||||
| @EXPORT_OK = qw(func1 func2); | |||||
| %EXPORT_TAGS = ( DEFAULT => [qw(&func1)], | |||||
| Both => [qw(&func1 &func2)]); | |||||
| sub func1 { return reverse @_ } | |||||
| sub func2 { return map{ uc }@_ } | |||||
| 1; | |||||
| @@ -0,0 +1,3 @@ | |||||
| #!/usr/bin/env perl | |||||
| #-*-mode: Perl; coding: utf-8;-*- | |||||
| @@ -0,0 +1,3 @@ | |||||
| #!/usr/bin/env python | |||||
| # -*-mode: Python; coding: utf-8;-*- | |||||
| @@ -0,0 +1,3 @@ | |||||
| #!/usr/bin/env ruby | |||||
| #-*-mode: Ruby; coding: utf-8;-*- | |||||
| @@ -0,0 +1,5 @@ | |||||
| #!/usr/bin/env ksh | |||||
| #-*-mode: Shell-script; coding: utf-8;-*- | |||||
| script=$(basename $0) | |||||
| dir=$(cd $(dirname $0); pwd) | |||||
| iam=${dir}/${script} | |||||
| @@ -0,0 +1,5 @@ | |||||
| #!/usr/bin/env sh | |||||
| #-*-mode: Shell-script; coding: utf-8;-*- | |||||
| script=$(basename $0) | |||||
| dir=$(cd $(dirname $0); pwd) | |||||
| iam=${dir}/${script} | |||||
| @@ -0,0 +1,5 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: assert(...); | |||||
| # key: assert/ | |||||
| # -- | |||||
| assert(${1:0 == 1}); | |||||
| @@ -0,0 +1,5 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: {...} *... = ({...}[]){...}; | |||||
| # key: literal/ | |||||
| # -- | |||||
| ${1:double} *${2:name} = ($1[]){${3:1.1, NAN}}; | |||||
| @@ -0,0 +1,10 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: doxygen comment | |||||
| # key: dox/ | |||||
| # -- | |||||
| /** | |||||
| \brief ${1:brief comment} | |||||
| ${0:long explanation of boring} | |||||
| \param ${3:param1}, ${4:value} | |||||
| \returns ${5:returns whatever} | |||||
| */ | |||||
| @@ -0,0 +1,7 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: typedef enum { ... } ...; | |||||
| # key: enum/ | |||||
| # -- | |||||
| typedef enum { | |||||
| ${0:values_and_such} | |||||
| } ${1:name}_t; | |||||
| @@ -0,0 +1,7 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: for (...; ...; ...) { ... } | |||||
| # key: for/ | |||||
| # -- | |||||
| for (${1:int i = 0}; ${2:i < N}; ${3:i++}){ | |||||
| ${0:0 == 0;} | |||||
| } | |||||
| @@ -0,0 +1,6 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: for (...; ...; ...) ... | |||||
| # key: for/ | |||||
| # -- | |||||
| for (${1:int i = 0}; ${2:i < N}; ${3:i++}) | |||||
| ${0:0 == 0;} | |||||
| @@ -0,0 +1,5 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: free(...); | |||||
| # key: free/ | |||||
| # -- | |||||
| free(${1:stuff}); | |||||
| @@ -0,0 +1,8 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: insert a function | |||||
| # key: fn/ | |||||
| # -- | |||||
| ${1:void} ${2:function_name}(${3:args}) { | |||||
| $0 | |||||
| return ${4:NULL}; | |||||
| } | |||||
| @@ -0,0 +1,5 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: insert a function prototype | |||||
| # key: fnp/ | |||||
| # -- | |||||
| ${1:void} ${2:function_name}(${3:args}); | |||||
| @@ -0,0 +1,9 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: insert a function with prototype | |||||
| # key: func/ | |||||
| # -- | |||||
| ${1:void} ${2:function_name}(${3:args}); | |||||
| $1 $2($3){ | |||||
| $0 | |||||
| return ${4:NULL}; | |||||
| } | |||||
| @@ -0,0 +1,8 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: #ifndef XXX; #define XXX; #endif | |||||
| # key: guard/ | |||||
| # -- | |||||
| #ifndef ${1:_`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_H_} | |||||
| #define $1 | |||||
| ${0:some_header_guarded_stuff} | |||||
| #endif /* $1 */ | |||||
| @@ -0,0 +1,7 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: #ifdef ...; ...; #endif | |||||
| # key: ifdef/ | |||||
| # -- | |||||
| #ifdef ${1:somedef} | |||||
| ${0:somedef_guarded_junk} | |||||
| #endif | |||||
| @@ -0,0 +1,5 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: #include "...\.h" | |||||
| # key: inc/ | |||||
| # -- | |||||
| #include "${1:someuserheader}.h" | |||||
| @@ -0,0 +1,5 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: #include <...\.h> | |||||
| # key: inc/ | |||||
| # -- | |||||
| #include <${1:somesystemheader}.h> | |||||
| @@ -0,0 +1,7 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: int main(argc, argv) { ... } | |||||
| # key: main/ | |||||
| # -- | |||||
| int main(int argc, char *argv[]) { | |||||
| $0 | |||||
| } | |||||
| @@ -0,0 +1,7 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: int main(void) { ... } | |||||
| # key: main/ | |||||
| # -- | |||||
| int main(void) { | |||||
| $0 | |||||
| } | |||||
| @@ -0,0 +1,5 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: malloc(...); | |||||
| # key: malloc/ | |||||
| # -- | |||||
| malloc(${1:stuff}); | |||||
| @@ -0,0 +1,12 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: insert clang pragma to ignore some warning | |||||
| # key: cprag/ | |||||
| # -- | |||||
| #ifdef __clang__ | |||||
| #pragma clang diagnostic push | |||||
| #pragma clang diagnostic ignored "-W${1:somewarning}" | |||||
| #endif | |||||
| ${0:some_evil_codez} | |||||
| #ifdef __clang__ | |||||
| #pragma clang diagnostic pop | |||||
| #endif | |||||
| @@ -0,0 +1,12 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: insert gcc pragma to ignore some warning | |||||
| # key: gprag/ | |||||
| # -- | |||||
| #ifdef __GNUC__ | |||||
| #pragma GCC diagnostic push | |||||
| #pragma GCC diagnostic ignored "-W${1:somewarning}" | |||||
| #endif | |||||
| ${0:some_evil_codez} | |||||
| #ifdef __GNUC__ | |||||
| #pragma GCC diagnostic pop | |||||
| #endif | |||||
| @@ -0,0 +1,7 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: printf | |||||
| # contributor: joaotavora | |||||
| # key: printf/ | |||||
| # -- | |||||
| printf("${1:%s}\\n"${1:$(if (string-match "%" yas-text) "," "\);") | |||||
| }$2${1:$(if (string-match "%" yas-text) "\);" "")} | |||||
| @@ -0,0 +1,5 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: puts(...); | |||||
| # key: puts/ | |||||
| # -- | |||||
| puts(${1:stuff}); | |||||
| @@ -0,0 +1,5 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: static const ... ... = ...; | |||||
| # key: sconst/ | |||||
| # -- | |||||
| static const ${1:int} ${2:FOO} = 1; | |||||
| @@ -0,0 +1,7 @@ | |||||
| #-*- mode: snippet; coding: utf-8 -*- | |||||
| # name: struct ... { ... } | |||||
| # key: struct/ | |||||
| # -- | |||||
| typedef struct { | |||||
| ${0:some_struct_stuffs} | |||||
| } ${1:name}_s; | |||||