From cb5a72ad406bbfb8fe16c977ef791b23c2035f50 Mon Sep 17 00:00:00 2001 From: Mark Niedzielski Date: Sat, 15 Feb 2020 21:34:00 -0500 Subject: [PATCH] Move from Dropbox. --- .aliases.common | 196 ++- .aliases.csh | 13 +- .aliases.tcsh | 18 +- .common-completion.tcsh | 99 +- .cshrc | 228 ++- .emacs | 378 ++++- .git-completion.bash | 3051 ++++++++++++++++++++++++++++++++++++++- .git-completion.tcsh | 115 +- .login | 63 +- .logout | 2 +- .puppet-lint.rc | 6 +- 11 files changed, 4158 insertions(+), 11 deletions(-) mode change 120000 => 100644 .aliases.common mode change 120000 => 100644 .aliases.csh mode change 120000 => 100644 .aliases.tcsh mode change 120000 => 100644 .common-completion.tcsh mode change 120000 => 100644 .cshrc mode change 120000 => 100644 .emacs mode change 120000 => 100644 .git-completion.bash mode change 120000 => 100644 .git-completion.tcsh mode change 120000 => 100644 .login mode change 120000 => 100644 .logout mode change 120000 => 100644 .puppet-lint.rc diff --git a/.aliases.common b/.aliases.common deleted file mode 120000 index 4e649a5..0000000 --- a/.aliases.common +++ /dev/null @@ -1 +0,0 @@ -Dropbox/Work/.aliases.common \ No newline at end of file diff --git a/.aliases.common b/.aliases.common new file mode 100644 index 0000000..9948eb1 --- /dev/null +++ b/.aliases.common @@ -0,0 +1,195 @@ +# +# .aliases.common +# +# aliases for csh and tcsh +# +# Wed Nov 30 1988 Mark Niedzielski (niedziel@copper) +# Tue Feb 11 1992 mark niedzielski (min@iclil) + + + alias acreds gimme-aws-creds + alias back 'cd $old' + alias bye logout + alias c 'set d=`echo \!^* | sed "s/./\/&*/g"`; set d = `dirp $d`; cd $d || echo $d' + alias cd 'set tmp=$cwd; chdir \!*; set old=$tmp; sethdr' + alias cgrep "grep \!* *.[Cch]" + alias clean "\rm -f #* *~ .*~ *%" + alias nclone 'for i in aws-account aws-acra aws-lock aws-noc aws-supportbridge aws-updates devops-docs devops-tools puppet-acra puppet-base puppet-noc puppet-supportbridge puppet-updates python-lock python-noc retired-nasuni retired-rackspace static-dashboard; do git clone ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/$i; done' + alias clpr 'vgrind \!* -t | lpr -t -h' + alias cprgb "cp \!:1.red \!:2.red; cp \!:1.grn \!:2.grn; cp \!:1.blu \!:2.blu; cp \!:1.doc \!:2.doc; cp \!:1.xbgr \!:2.xbgr" + alias cptree 'cd \!:1; tar cf - . | (cd \!:2; tar xpf -)' + alias debug 'dbxtool < /dev/null >& /dev/null \!* &' + alias df 'df -h' + alias dm gcloud deployment-manager + alias dmc gcloud deployment-manager deployments create + alias dmd gcloud deployment-manager deployments delete + alias dml gcloud deployment-manager deployments list + alias dmdes gcloud deployment-manager deployments describe + alias dots '/usr/bin/git --git-dir=$HOME/.dots.git/ --work-tree=$HOME' + alias du 'du -sch' + alias ekdir 'ekfinger \!* | grep -v Connecting | less' + alias elpr 'enscript -r -B -h \!*' + alias emac emacsclient + alias f finger + alias ff 'find . -name \*\!*\* -print' + alias forall "find . -name '[a-z]*' -maxdepth 1 -type d -exec sh -c 'echo "\$0" && cd "\$0" && \!*' {} \;" + alias gab "find . -name '[a-z]*' -maxdepth 1 -type d -exec sh -c 'echo "\$0" && git -C "\$0" branch' {} \;" + alias gap "find . -name '[a-z]*' -maxdepth 1 -type d -exec sh -c 'echo "\$0" && git -C "\$0" pull --tags' {} \;" +# alias gaps "find . -name '[a-z]*' -maxdepth 1 -type d -exec sh -c 'echo "\$0" && git -C "\$0" status|grep Your|grep -v up-to-date' {} \;" + alias gaps "find . -name '[a-z]*' -maxdepth 1 -type d -exec sh -c 'echo "\$0" && git -C "\$0" status|grep Your|grep -v up-to-date;git -C "\$0" --no-pager log origin/master..HEAD --oneline' {} \;" + alias gc gcloud + alias gcl gcloud config list + alias gcp gcloud config set project + alias gcssh gcloud compute --project=thinking-cacao-499 ssh \!:1 -- bash + alias gcco 'gcc -O -fstrength-reduce -fforce-mem -fomit-frame-pointer -finline-functions' + alias gfind 'find \!:2 -type f -exec grep \!:1 {} \; -print' + alias gg 'grep -Rni \!:1 *' + alias gita "find . -name '[a-z]*' -maxdepth 1 -type d -exec sh -c 'echo "\$0" && git -C "\$0" \!*' {} \;" + # Git Branch Check + alias gitbc 'git for-each-ref --format="%(refname:short) %(push:track)" refs/heads' + alias gits 'git -C \!*' + alias h history + alias hdr 'echo -n "]l\!*\"' + alias hp 'tooltool -f hp.tt' + alias ifd input_from_defaults + alias ihdr 'echo -n "]L\!*\"' + alias ip 'set h=`ypmatch \!:1 hosts`; echo $h[1]' + alias isp tooltool -f ispell.tt + alias index 'ctags -v \!* | sort -f > index; vgrind -t -x index | lpr -t -JIndex; \rm -f index' + alias j jobs -l +# alias la '/bin/ls -FaC' + alias la '/bin/ls -a' +# alias ll '/bin/ls -FlaC' + alias ll '/bin/ls -lah' + alias l '/bin/ls -lh' + alias lb librato-spark.bash + alias lman 'nroff -man \!:1 | less' + alias lnrgb "ln -s \!:2.red \!:1.red; ln -s \!:2.grn \!:1.grn; ln -s \!:2.blu \!:1.blu; ln -s \!:2.doc \!:1.doc; ln -s \!:2.xbgr \!:1.xbgr" + alias ls '/bin/ls -C' + alias lpr2 'enscript -2rBh' + alias lt 'last | less' + alias ltc 'lastcomm | less' + alias mail Mail + alias mk 'rsh isis "cd `pwd`; make -k"' + alias mvrgb "mv \!:1.red \!:2.red; mv \!:1.grn \!:2.grn; mv \!:1.blu \!:2.blu; mv \!:1.doc \!:2.doc; mv \!:1.xbgr \!:2.xbgr" + alias nms 'tbl \!* | nroff -ms | more' + alias noc 'python $HOME/src/nasuni/devops-tools/nasunienv.py' + alias nocl 'python $HOME/src/nasuni/devops-tools/nasunienv.py list' + alias open 'chmod go+r' + alias p 'set d=`echo \!^* | sed "s/./\/&*/g"`; set d = `dirp $d`; pd $d || echo $d' + alias pd 'set old=$cwd; pushd \!*; sethdr' + alias pd2 'set old=$cwd; pushd +2\!*; sethdr' + alias pd3 'set old=$cwd; pushd +3\!*; sethdr' + alias pd4 'set old=$cwd; pushd +4\!*; sethdr' + alias pd5 'set old=$cwd; pushd +5\!*; sethdr' + alias pd6 'set old=$cwd; pushd +6\!*; sethdr' + alias play 'gomf \!:*' + alias pn 'set x = `grep -i \!* ~/h/phones`; echo $x[3*] $x[2] $x[1]' + alias pop 'set old=$cwd; popd; sethdr' +# alias psg 'ps --no-headers -C \!*' + alias psg 'ps -ef | grep \!* | grep -v grep' +# alias psg- 'ps -auxww | grep \!* | grep -v grep' +# alias psg2 'ps -xuww | grep \!* | grep -v grep' + alias r "on -i \!:1 \!:2*" + alias rkill 'on \!:1 kill \!:2*' + alias rplay 'set tmp=`on -n \!:1 arch`; on -i \!:1 /local/wizards.$tmp/gomf \!:2*' + alias rm 'rm -i' + alias rpmq 'rpm -qa \*\!*\*' + alias rps "on \!:1 ps \!:2*" + alias rpsg 'on \!:1 ps -auxww | grep \!:2 | grep -v grep' + alias rpt "on \!:1 pt \!:2*" + alias rstart "on \!:1 kill -19 \!:2*" + alias rstop "on \!:1 kill -17 \!:2*" + alias rtop 'set tmp=`on -n \!:1 arch`; on -i \!:1 /local/wizards.$tmp/top \!:2*' + alias rw 'on \!:1 w' + alias rzap 'set j=`rps \!:1 ax | grep \!:2* | grep -v grep`; rkill \!:1 -9 `echo $j[1]`' +# alias rzap 'set j=`rpsg \!:1 \!:2*`; rkill \!:1 -9 `echo $j[1]`' + alias sd 'screendump | rasfilter8to1 | pssun -r -S 8 | lpr' + alias shut 'chmod go-r' + alias start kill -19 + alias stop kill -17 + alias sys "(uptime; ps -auxww) | less" + alias the 'll `which \!:1`' + alias trigp 'aws --profile production_account codecommit put-repository-triggers --repository-name \!:1 --cli-input-json file://\!:1.triggers.json' + alias tt 'tooltool -f \!*.tt' + alias ucon '\rm ~/.exit' + alias x exit + alias xb 'setenv DISPLAY 208.133.210.25:0' + alias xd 'setenv DISPLAY `ip develop`:0' + alias ymlint ruby -r yaml -e "YAML.load_file\(\'\!:1\'\)" + alias halint "find . -name '*.yaml' -exec ruby -debug -r yaml -e 'YAML.load_file('{}')' \;" + alias z suspend +# alias zap 'set j=`ps x | grep \!* | grep -v grep`; kill -9 `echo $j[1]`' + alias zap 'set j=`ps -ef | grep \!* | grep -v grep`; kill -9 `echo $j[2]`' +# alias zap 'kill -TERM `ps --no-headers -o pid -C \!*`' + + alias 24z screen off + alias 25z screen on + + + # + # sccs stuff + # +# alias delta sccs delta +# alias deledit sccs deledit +# alias delget sccs delget +# alias edit sccs edit +# alias fix sccs fix +# alias get sccs get +# alias info sccs info +# alias prt sccs prt + + + alias .. 'cd ..' + + alias + %+ + alias - %- + + alias 1 %1 + alias 2 %2 + alias 3 %3 + alias 4 %4 + alias 5 %5 + alias 6 %6 + alias 7 %7 + alias 8 %8 + alias 9 %9 + alias 10 %10 + alias 11 %11 + alias 12 %12 + alias 13 %13 + alias 14 %14 + alias 15 %15 + alias 16 %16 + + alias k1 kill -9 %1 + alias k2 kill -9 %2 + alias k3 kill -9 %3 + alias k4 kill -9 %4 + alias k5 kill -9 %5 + alias k6 kill -9 %6 + alias k7 kill -9 %7 + alias k8 kill -9 %8 + alias k9 kill -9 %9 + alias k10 kill -9 %10 + alias k11 kill -9 %11 + alias k12 kill -9 %12 + alias k13 kill -9 %13 + alias k14 kill -9 %14 + alias k15 kill -9 %15 + alias k16 kill -9 %16 + + +# +# aliases.fun +# +# real bizzare things .... +# +# Thu Jul 7 07:59:11 1988 Mark Reichert x25948 (niedziel@copper) +# + +#alias worm_on "rsh \!:1 \"setenv TERM sun; worms \!:3* | cat -u > /dev/\!:2\"" +alias ow on \!:1 "echo -n '' > /dev/\!:2" +alias cw on \!:1 "echo -n '' > /dev/\!:2" +alias ew on \!:1 "echo -n '' > /dev/\!:2" +alias hw on \!:1 "echo -n '' > /dev/\!:2" diff --git a/.aliases.csh b/.aliases.csh deleted file mode 120000 index d38a628..0000000 --- a/.aliases.csh +++ /dev/null @@ -1 +0,0 @@ -Dropbox/Work/.aliases.csh \ No newline at end of file diff --git a/.aliases.csh b/.aliases.csh new file mode 100644 index 0000000..d700ed9 --- /dev/null +++ b/.aliases.csh @@ -0,0 +1,12 @@ +# +# .aliases.csh +# +# aliases for csh and tcsh +# +# Wed Nov 30 1988 Mark Niedzielski (niedziel@copper) +# Thu Oct 7 1993 Mark Niedzielski v1.4 (min@napa) +# + + alias sethdr 'set prompt="\\ +`hostname`\\ +`basename $cwd` \! > "; if ("${tty}" != /dev/console) echo -n "]l${user}@${hostname}: ${cwd}\"' diff --git a/.aliases.tcsh b/.aliases.tcsh deleted file mode 120000 index 542feb7..0000000 --- a/.aliases.tcsh +++ /dev/null @@ -1 +0,0 @@ -Dropbox/Work/.aliases.tcsh \ No newline at end of file diff --git a/.aliases.tcsh b/.aliases.tcsh new file mode 100644 index 0000000..6f678cc --- /dev/null +++ b/.aliases.tcsh @@ -0,0 +1,17 @@ +# +# .aliases.tcsh +# +# aliases for tcsh (obviously) +# +# Mon July 18 10:11:22 1988 Mark Niedzielski (niedziel@snowmass) +# + + # cmd executed before every prompt, see tcsh(1) + #alias precmd 'echo " " ; echo $HOST' + alias precmd 'history -S' + alias postcmd 'history -M' + + #alias sethdr 'echo -n "]l${USER}@${HOST} ${cwd} \ "' + #alias sethdr 'echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"' + alias sethdr 'echo -n "]l${USER}@${HOST} ${cwd} \ "' + alias clrhdr 'echo -n "]l \ "' diff --git a/.common-completion.tcsh b/.common-completion.tcsh deleted file mode 120000 index ef5d241..0000000 --- a/.common-completion.tcsh +++ /dev/null @@ -1 +0,0 @@ -Dropbox/Work/.common-completion.tcsh \ No newline at end of file diff --git a/.common-completion.tcsh b/.common-completion.tcsh new file mode 100644 index 0000000..0fc3a25 --- /dev/null +++ b/.common-completion.tcsh @@ -0,0 +1,98 @@ + # directories + complete cd 'C/*/d/' + complete rmdir 'C/*/d/' + complete lsd 'C/*/d/' + + # signal names + # also note that the initial - can be created with the first completion + # but without appending a space (note the extra slash with no + # append character specified) + complete kill 'c/-/S/' 'p/1/(-)//' + + # use available commands as arguments for which, where, and man + complete which 'p/1/c/' + complete where 'p/1/c/' + complete man 'p/1/c/' + + # aliases + complete alias 'p/1/a/' + complete unalias 'p/1/a/' + + # variables + complete unset 'p/1/s/' + complete set 'p/1/s/' + + # environment variables + complete unsetenv 'p/1/e/' + complete setenv 'p/1/e/' + #(kinda cool: complete first arg with an env variable, and add an =, + # continue completion of first arg with a filename. complete 2nd arg + # with a command) + complete env 'c/*=/f/' 'p/1/e/=/' 'p/2/c/' + + # limits + complete limit 'p/1/l/' + + # key bindings + complete bindkey 'C/*/b/' + + # groups + complete chgrp 'p/1/g/' + + # users + complete chown 'p/1/u/' + + + # You can use complete to provide extensive help for complex commands + # like find. + # Please check your version before using these completions, as some + # differences may exist. + complete find 'n/-name/f/' 'n/-newer/f/' 'n/-{,n}cpio/f/' \ + 'n/-exec/c/' 'n/-ok/c/' 'n/-user/u/' 'n/-group/g/' \ + 'n/-fstype/(nfs 4.2)/' 'n/-type/(b c d f l p s)/' \ + 'c/-/(name newer cpio ncpio exec ok user group fstype type atime \ + ctime depth inum ls mtime nogroup nouser perm print prune \ + size xdev)/' \ + 'p/*/d/' + + # set up cc to complete only with files ending in .c, .a, and .o + complete cc 'p/*/f:*.[cao]/' + + # of course, this completes with all current completions + complete uncomplete 'p/*/X/' + + # complex completion for ln + # In all cases, if you start typing, it completes with a filename + # But if you complete without typing anything you get this: + # first argument: adds "-s" + # arguments that follow -s: reminds you of which argument is expected + complete ln 'C/?/f/' 'p/1/(-s)/' 'n/-s/x:[first arg is path to original file]/' 'N/-s/x:[second arg is new link]/' + + # set a printer list, for use with all print related commands + set printerlist=(hp1 hp2 color) + complete lp 'c/-d/$printerlist/' + complete lpstat 'p/1/$printerlist/' + complete lpq 'c/-P/$printerlist/' + complete lpr 'c/-P/$printerlist/' + complete enscript 'c/-d/$printerlist/' + + # set a list of hosts, for use with rlogin + set hostlist=(foo bar baz) + complete rlogin 'p/1/$hostlist/' + complete rsh 'p/1/$hostlist/' 'p/2/c/' + complete ssh 'p/1/$hostlist/' 'p/2/c/' + + # rcp and scp allow arguments to be references to either local or remote + # files. It's impossible to complete remote files, but its useful to assume + # that the remote file structure is similar to the local one. + # + # when you first start typing, it could be any of a username, hostname, + # or filename. But filename is probably the most useful case, so: + # + # complete arguments as regular filenames, with following exceptions + # if "@" has been typed, complete with a hostname, and append a colon (:) + # if ":" has been typed, complete with a filename relative to home directory + # if ":/" has been typed, complete with a filename relative to root directory + # + complete rcp "c,*:/,F:/," "c,*:,F:$HOME," 'c/*@/$hostlist/:/' + complete scp "c,*:/,F:/," "c,*:,F:$HOME," 'c/*@/$hostlist/:/' diff --git a/.cshrc b/.cshrc deleted file mode 120000 index 113804a..0000000 --- a/.cshrc +++ /dev/null @@ -1 +0,0 @@ -Dropbox/Work/.cshrc \ No newline at end of file diff --git a/.cshrc b/.cshrc new file mode 100644 index 0000000..e495070 --- /dev/null +++ b/.cshrc @@ -0,0 +1,227 @@ +# +# .cshrc +# +# Mon July 18 10:08:32 1988 Mark Niedzielski (niedziel@snowmass) +# Wed Dec 11 14:37:12 1991 mark niedzielski (min@iclil) +# Mon Apr 27 10:28:13 2015 Mark Niedzielski (min@wayback) +# + +limit coredumpsize 0m +limit descriptors 256 +#umask 007 +umask 022 + +# +# filec, fignore, and nobeep all relate to csh file name completion +# 'man csh' +# +set filec +set fignore = ( .o .out ) +set nobeep +#unset savehist + +# +# identify where we are +# +set hostname = `uname -n` +set tty = `tty` +set arch = `uname -m` +if ( ($arch == 'sun4c') || ($arch == 'sun4m') ) then + set arch = sun4 +endif + +set ostype = `uname -s` +set osversion = `uname -r` +set osrev = `uname -r | sed -n 's/^\([^\.]*\).*/\1/p'` +setenv OSREV $osrev + +if ( ($osrev == '4') && ($arch == 'sun4') ) then + set mach = `mach` +else + set mach = `uname -p` +endif + +# +# be notified upon completion of background jobs +# +set notify + +# +# so that ^D doesn't kick us out of a csh +# +set ignoreeof + +#setenv LANG en_US +setenv NOREBIND true + +setenv LESS cCdeMqsw +setenv MORE '-c' +setenv PAGER less +#setenv PRINTER lp2 +#setenv TERMCAP ~/.termcap +setenv PS1 'oslo > ' +setenv PS2 ' ? ' +#setenv NNTPSERVER newsserver.questra +#setenv JAVA_HOME /usr/java +#setenv CLASSPATH .:$JAVA_HOME/lib:$HOME/src/java/classes:/local/lib + +# +# DATED: XWindows +#setenv OPENWINHOME /usr/openwin +setenv INDEXDIR $HOME/h +#setenv XENVIRONMENT /local/src/xrainbow/Xrainbow +#setenv XAPPLRESDIR $OPENWINHOME/lib/app-defaults +#setenv XDVIFONTS /packages/latex/cmfonts/%p/%p%d/%f.%d%p +#setenv XFILESEARCHPATH $OPENWINHOME/bin + +#setenv PYTHONPATH .:/lib/python2.7/site-packages:/usr/local/lib/python2.7/site-packages:/usr/lib/python2.7:$HOME/src +##setenv PYTHONPATH .:/lib/python2.7/site-packages:/usr/local/lib/python2.7/site-packages:/usr/lib/python2.7:$HOME/src:$HOME/src/nasuni +#setenv SLACK_TOKEN xoxb-14929910341-Xfug3Kv9p9R0CY78LtI4vj5B +#setenv LIBRATO_USERID noc@nasuni.com +#setenv LIBRATO_API_TOKEN d8412b51660e9035209898fd8d1e934e379a97bc57a867af7693344f9a87fd11 + +# +# DATED: environment variables dependent upon OS revision +# +#if ( ($osrev == '5') ) then +# setenv CCROOTDIR /opt/SUNWspro +# setenv CCBINDIR $CCROOTDIR/bin +#else +# setenv CCROOTDIR /opt/lang +# setenv CCBINDIR $CCROOTDIR +#endif + +#setenv LD_LIBRARY_PATH $CCROOTDIR/lib:$OPENWINHOME/lib:/usr/lib:$JAVA_HOME/lib:/pkgs/X11R6/lib +#setenv MANPATH $CCROOTDIR/man:$OPENWINHOME/man:/usr/local/man:/usr/man + +# +# everywhere... +# +set path = (\ + ~/bin\ + ~/bin/ec\ +# /lib/python2.7/site-packages\ +# /usr/local/opt/python/libexec/bin\ +# ~/Library/Python/2.7/bin\ + /usr/local/bin\ + /usr/local/bin/bin\ + /usr/local/sbin\ + /bin\ + /sbin\ + /usr/bin\ + /usr/sbin\ + /opt/local/bin\ + /opt/local/sbin\ + /opt/puppetlabs/bin\ + /usr/local/opt/openssl/bin\ +# /Library/Ruby/Gems/2.0.0/gems/puppet-lint-2.0.2/bin\ +# /usr/X11R6/bin\ +# /Applications/Emacs.app/Contents/MacOS/bin\ + .\ + ) + +# +# the 'if($?prompt)' assures us that the following only +# happens in interactive shells. this gives 'rsh' a +# big performance boost. +# +if($?prompt == 0) then + exit +endif + +# Yes, reset hostname to an abbreviated version of that used by non-interactive shells. +set hostname = `uname -n | sed -e 's/\..*//'` +set history = 30000 + +# +# cdpath is a list of places to check for a cd +# +set cdpath = (\ + ~\ + /\ + ~/src\ + /export\ + /opt\ + /var\ + ..\ + ) + +# +# if we have a meta key, pass 8bit characters for meta characters in tcsh +# +#if ( "`echotc meta`" == "yes" ) then +# stty pass8 +#endif +# +#setenv LC_CTYPE iso_8859_1 +#stty -parenb -istrip cs8 + +#setenv EDITOR /packages/gnu/bin.$arch/emacsclient +#setenv VISUAL /packages/gnu/bin.$arch/emacsclient +setenv EDITOR vi +setenv VISUAL vi +setenv ESHELL /bin/csh + +if($?tcsh) then + source ~/.common-completion.tcsh + complete aws 'p/*/`aws_completer`/' + # /~https://github.com/git/git/tree/master/contrib/completion + source ~/.git-completion.tcsh + + # Make command completion (TAB key) cycle through all possible choices + # (The default is to simply display a list of all choices when more than one + # match is available.) + bindkey "^I" complete-word-fwd + bindkey "^H" i-search-back + + # Make command history (arrow keys) use history search operations + # (The default is to simply display the next item in the history list.) + bindkey -k down history-search-forward + bindkey -k up history-search-backward + + set autoexpand + set autolist = ambiguous + set complete + set chase_symlinks + set color + set correct + set dextract + #set expand-glob + set histdup = erase + set implicitcd = verbose + set listjobs + set listlinks + set printexitvalue + set recexact + set savedirs + set savehist = (${history} merge lock) + set watch = (5 any any) + + unset autologout + bindkey -e + source .aliases.tcsh +else + source .aliases.csh +endif +source .aliases.common + +#if("$tty" != '/dev/console') then +# cd . +# ihdr $hostname +#endif + +if ($term == xterm || $term == xterms || $term == xterml || $term == xterm-color || $term == xterm-256color) then + set prompt="%{\e]2\;%m:%/^g\e]1\;%m^g\r%}%m %h %# " +else + set prompt = "%c %h > " +endif + +# +# correct the errors of silly terminal servers +# +#if(($term != 'sun') && ($term != 'sun-cmd') && ($term != 'xterm') && ($term != 'xterm-color') && ($term != 'xterm-256color')) then +# set term = vt220 +# stty rows 24 columns 80 +#endif + +#eval $(docker-machine env default) diff --git a/.emacs b/.emacs deleted file mode 120000 index 4e276d4..0000000 --- a/.emacs +++ /dev/null @@ -1 +0,0 @@ -Dropbox/Work/.emacs \ No newline at end of file diff --git a/.emacs b/.emacs new file mode 100644 index 0000000..414ff4f --- /dev/null +++ b/.emacs @@ -0,0 +1,377 @@ +;;; +;;; .emacs +;;; +;;; Wed 12 October 1988 Mark Niedzielski (niedziel@copper) +;;; Tue 2 November 2004 Mark Niedzielski (min@savantis) +;;; Fri 11 April 2014 Mark Niedzielski (mniedzielski@paypal) +;;; Wed 11 March 2015 Mark Niedzielski (mniedzielski@nasuni) +;;; Mon 9 July 2018 Mark Niedzielski (min@gamalon) +;;; + +; +; Note: recall this is lisp, 't' is true, and 'nil' is false +; + +( setq load-path (cons "~/emacs" load-path) ) +;( setq load-path +; ( append (list (expand-file-name "/home/min/emacs/") +; (expand-file-name "~/.xemacs") +; load-path) +; ) +;) + +( defvar using-server nil ) ; if you want to use emacsclient +( defvar using-abbrevs nil ) ; if you have a file of abbreviations +( defvar using-unix t ) ; enable server and extended controls +( defvar using-sun nil ) ; +( defvar using-osx t ) ; +( defvar sun-esc-bracket nil ) ; for sun function keys +( defvar display-time-interval 5 ) ; update rate for time on mode line +( defvar c-tabs-should-be-tabs t ) ; is a tab, or an indent line +( defvar extra-click-wait 300 ) + +( let ((gc-cons-threshold 1000000)) + +;; Install package repositories: +( require 'package ) +( package-initialize ) +( add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/" ) ) +( add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/" ) ) +( add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/" ) ) +;( add-to-list 'package-archives '("marmalade" . "https://marmalade-repo.org/packages/") ) ; Defunct? +( package-refresh-contents ) + +; ( load "newtime" nil t ) + ( if (eq window-system 'x) + ( let nil + ( load "blink-paren" nil t ) + ) + ) + ( if (eq using-unix t) + ( let nil + ( load "server" nil t ) + ) + ) + ( if (eq using-sun t) + ( let nil + ( load "term/sun" nil t ) + ( load "sunkeys" nil t ) + ( load "sunX-keys" nil t ) + ( load "mouse-bits" nil t ) + ( load "x-sb-mouse" nil t ) + ( load "xsbm-userfuns" nil t ) + ) + ) + ( load "scroll-in-place.el" nil t ) + ( load "smooth-scroll.el/smooth-scroll.el" nil t ) + ( load "ebuff-menu" nil t ) + ( load "echistory" nil t ) + ( load "man" nil t ) + ( load "saveconf" nil t ) + ( load "ispell" nil t ) + ( load "longlines.el" nil t ) ; Manually wrap long lines + ( load "mic-paren.el" nil t ) ; Advanced Paren Matching + ( load "cc-mode" nil t ) + ( load ".emacs_init" nil t ) + ( load "desktop" nil t ) +; ( load "cplus-md" nil t ) +; ( load "c-mode" nil t ) +; ( load "thing" nil t ) +; ( load "positions" nil t ) +; ( load "pos-help" nil t ) +; ( load "cmacexp" nil t ) +; ( load "custom.el" nil t ) ; XEmacs layout variables +; ( load "hhm-config.el" nil t ) ; HTML Helper Mode configuration + + ( garbage-collect ) +) + +; check if the packages is installed; if not, install it. +( mapc + ( lambda (package) + ( or ( package-installed-p package ) + ( package-install package) + ) + ) + '( ace-jump-mode + json-mode flymake-json + ;ssh-config-mode + flymake + ;puppetfile-mode + puppet-mode flymake-puppet + ;flymake-jshint helm-flymake + ;flyspell-lazy + gist ; /~https://github.com/defunkt/gist.el + yaml-mode + web-mode + ;elpy + ;yasnippet + ;project-explorer + ;rinari ruby-mode robe enh-ruby-mode flymake-ruby + ;git-gutter+ magit git-gutter-fringe + ;;magithub + ;terraform-mode + ;mediawiki + ) +) + +;; magithub configuration (github integration) +;; /~https://github.com/vermiculus/magithub/blob/master/magithub.org +;(magithub-feature-autoinject t) +;(setq magithub-clone-default-directory "~/src/celect") + +;; set keys for Apple keyboard, for emacs in OS X +;(setq mac-command-modifier 'meta) ; make cmd key do Meta +(setq mac-option-modifier 'super) ; make opt key do Super +;(setq mac-control-modifier 'control) ; make Control key do Control +;(setq ns-function-modifier 'hyper) ; make Fn key do Hyper + +; Associate keycodes to logical keys. Move to .emacs_init.el. +;( when ( >= emacs-major-version 23 ) + ( define-key input-decode-map "\e[1;5A" [C-up] ) + ( define-key input-decode-map "\e[1;5B" [C-down] ) + ( define-key input-decode-map "\e[1;5C" [C-right] ) + ( define-key input-decode-map "\e[1;5D" [C-left] ) + ( define-key input-decode-map "\e[1;2A" [S-up] ) + ( define-key input-decode-map "\e[1;2B" [S-down] ) + ( define-key input-decode-map "\e[1;2C" [S-right] ) + ( define-key input-decode-map "\e[1;2D" [S-left] ) + ( define-key input-decode-map "\e[1;7A" [O-up] ) + ( define-key input-decode-map "\e[1;7B" [O-down] ) + ( define-key input-decode-map "\e[1;7C" [O-right] ) + ( define-key input-decode-map "\e[1;7D" [O-left] ) +;) + +; Keymap function assignments. These will move to .emacs_init.el. +( define-key global-map [f1] 'shrink-window ) +( define-key global-map [27 f1] 'shrink-window-horizontally ) +( define-key global-map [f2] 'enlarge-window ) +( define-key global-map [27 f2] 'enlarge-window-horizontally ) +( define-key global-map [f3] 'isearch-forward ) +( define-key global-map [27 f3] 'isearch-forward-regexp ) +( define-key global-map [f4] 'query-replace ) +( define-key global-map [27 f4] 'replace-regexp ) +( define-key global-map [f5] 'replace-string ) +( define-key global-map [f6] 'goto-line ) +( define-key global-map [27 f6] 'regexp-builder ) + +( define-key global-map [f7] 'beginning-of-buffer ) +( define-key global-map [f8] 'electric-buffer-list ) +( define-key global-map [f9] 'end-of-buffer ) +( define-key global-map [f10] 'comment-dwim ) + +( define-key global-map [f11] 'split-window-below ) +( define-key global-map [f12] 'delete-other-windows-vertically ) + +( define-key global-map [f13] 'backward-paragraph ) +( define-key global-map [f14] 'beginning-of-buffer ) +( define-key global-map [27 f14] 'end-of-buffer ) ; ESC f14 +( define-key global-map [f15] 'forward-paragraph ) + +( define-key global-map [f16] 'research-backward ) ; shift-f5 +( define-key global-map [27 f16] 'isearch-backward ) +( define-key global-map [f17] 'research-forward ) ; shift-f6 +( define-key global-map [27 f17] 'isearch-forward ) +( define-key global-map [f18] 'describe-key ) +( define-key global-map [f19] 'describe-function ) ; shift-f7 + +( define-key global-map [f20] 'scroll-down-command ) ; shift-f8 +( define-key global-map [f21] 'scroll-up-command ) ; shift-f9 +( define-key global-map [f22] 'backward-paragraph ) ; shift-f10 +;( define-key global-map [f23] 'beginning-of-buffer ) ; shift-f11 +( define-key global-map [f23] 'end-of-buffer ) ; shift-f14 on full keyboard +( define-key global-map [f24] 'forward-paragraph ) ; shift-f12 + +( define-key global-map [S-up] 'backward-to-indentation ) +( define-key global-map [S-down] 'forward-to-indentation ) +( define-key global-map [C-up] 'backward-paragraph ) +( define-key global-map [C-down] 'forward-paragraph ) +( define-key global-map [O-up] 'scroll-up-in-place ) +( define-key global-map [O-down] 'scroll-down-in-place ) + +( define-key global-map [S-right] 'forward-word ) +( define-key global-map [S-left] 'backward-word ) +( define-key global-map [C-left] 'previous-multiframe-window ) +( define-key global-map [C-right] 'next-multiframe-window ) +;( define-key global-map (kbd "C-[") 'python-indent-shift-left ) +;( define-key global-map (kbd "C-]") 'python-indent-shift-right ) + +( define-key global-map [27 f22] 'scroll-down ) ; 27 == ESC +( define-key global-map [27 f24] 'scroll-up ) +( define-key global-map [prior] 'scroll-down ) +( define-key global-map [next] 'scroll-up ) + +( define-key global-map [O-left] 'previous-buffer ) +( define-key global-map [O-right] 'next-buffer ) + +( define-key global-map [27 deletechar] 'kill-word ) ; ESC DEL +;( define-key global-map [control-delete] 'delete-backwards ) +;( define-key global-map [pause] 'shell ) +;( define-key global-map [control-pause] 'long-lines ) + +( define-key global-map [M-O x] 'replace-string ) +( define-key global-map [M-O o] 'replace-regexp ) +( define-key global-map [M-O j] 'replace-regexp ) + +;; ACE-JUMP: http://www.emacswiki.org/emacs/AceJump +;; -------------------- +;; Set mark +;; C-SPC +;; Jump to word +;; C-c SPC +;; Jump Back to mark +;; C-U C-SPC +(require 'ace-jump-mode) +(define-key global-map (kbd "C-c SPC") 'ace-jump-mode) + +;; Helm +;(require 'helm-config) +;(require 'helm-flymake) +;(global-set-key (kbd "C-c h") 'helm-mini) +;(helm-mode 1) + +;; Improve flyspell responsiveness +;(require 'flyspell-lazy) +;(flyspell-lazy-mode 0) +;(flyspell-mode 1) + +; Puppetfile +;(require 'puppetfile-mode) +;(add-to-list 'auto-mode-alist '("Puppetfile\\'" . puppetfile-mode)) + +;; Puppet +;(add-to-list 'auto-mode-alist '("pp$" . puppet-mode)) +;; (add-hook 'puppet-mode 'flymake-puppet-load) +(autoload 'puppet-mode "puppet-mode" "Major mode for editing puppet manifests") +(add-to-list 'auto-mode-alist '("\\.pp$" . puppet-mode)) +(require 'flymake-puppet) +(add-hook 'puppet-mode-hook (lambda () (flymake-puppet-load))) + +;; JSON +(require 'flymake-json) +(add-hook 'json-mode-hook (lambda () (flymake-json-load))) + +;; Jinja2 +(add-to-list 'auto-mode-alist '("\\.jinja\\'" . web-mode)) + +;; Flymake +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(flymake-error ((((class color)) (:underline "red")))) + '(flymake-warning ((((class color)) (:underline "yellow")))) + '(font-lock-keyword-face ((t (:foreground "magenta" :weight normal)))) + '(font-lock-string-face ((t (:foreground "blue")))) + '(font-lock-type-face ((t (:foreground "green" :weight semi-bold)))) + '(font-lock-variable-face ((t (:foreground "cyan" :weight normal)))) + '(font-lock-variable-name-face ((t (:foreground "cyan" :weight normal)))) + '(region ((t (:background "white"))))) +(require 'flymake-cursor) + +;; ;; Terraform Mode +;; (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. +;; '(mediawiki-site-alist +;; (quote +;; (("Wikipedia" "https://en.wikipedia.org/w/" "username" "password" nil "Main Page") +;; ;("Nasuni" "http://wiki.nasuni.net/" "Mniedzielski" "Nasuni313" nil "NOC")))) +;; '(package-selected-packages +;; (quote +;; ;(terraform-mode terraform mediawiki gist flymake-json yaml-mode puppetfile-mode puppet-mode magit json-mode git-gutter-fringe git-gutter+ flymake-puppet ace-jump-mode))) +;; (terraform-mode terraform mediawiki gist flymake-json yaml-mode puppetfile-mode puppet-mode json-mode git-gutter-fringe git-gutter+ flymake-puppet ace-jump-mode))) +;; '(terraform-indent-level 4)) + + +;; ( load "cloudformation-mode/cloudformation-mode.el" nil t ) +;; (require 'cloudformation-mode) +;; (add-to-list 'auto-mode-alist '("\\.cf$" . cloudoformation-mode)) +;; (add-to-list 'auto-mode-alist '("\\.cloudformation$" . cloudoformation-mode)) +;; (add-to-list +;; 'magic-mode-alist +;; '("\\(.\\|\n\\)*AWSTemplateFormatVersion" . cloudformation-mode)) + +; /~https://github.com/nonsequitur/git-gutter-plus +;( global-git-gutter+-mode t ) + +( setq column-number-mode t ) +;( paren-set-mode 'sexp ) +( setq show-paren-delay 0 ) +( show-paren-mode ) +( setq show-paren-style 'parenthesis) ; highlight just brackets +;( setq show-paren-style 'expression) ; highlight entire bracket expression + +;; Show offscreen parens +(defadvice show-paren-function + (after show-matching-paren-offscreen activate) + "If the matching paren is offscreen, show the matching line in the echo area. + Has no effect if the character before point is not of the syntax class ')'." + (interactive) + (let* ((cb (char-before (point))) + (matching-text (and cb + (char-equal (char-syntax cb) ?\) ) + (blink-matching-open)))) + (when matching-text (message matching-text)))) + +;; Emacs gurus don't need no stinking scroll bars +( when (fboundp 'toggle-scroll-bar ) + ( toggle-scroll-bar -1 ) +) + +( linum-mode -1 ) + +;; Explicitly show the end of a buffer +( set-default 'indicate-empty-lines t ) + +( if using-server ( server-start ) ) + +( setq display-time-day-and-date nil ) ; show day, date and time +( setq display-time-mail-file t ) ; don't check mail +( setq display-time-24hr-format t ) ; in 24hr format +( display-time ) + +( if using-abbrevs ( read-abbrev-file nil t ) ) + +( setenv "SLACK_TOKEN" "xoxb-14929910341-Xfug3Kv9p9R0CY78LtI4vj5B" ) +(defvar slackcat-bin "slackcat" "Command to invoke slackcat.") +(defvar slackcat-args "-c noc" "Default arguments to pass to slackcat.") + +(defun slackcat (&optional b e) + "Upload contents of region to slack chat." + (interactive "r") + (let ((args (read-from-minibuffer "slackcat args: " slackcat-args))) + (shell-command-on-region b e (format "%s %s" slackcat-bin args)))) + +;; Backup files in one spot +(setq backup-directory-alist nil ) +(setq backup-directory-alist + (cons (cons "\\.*$" (expand-file-name "~/.emacs.d/backups")) + backup-directory-alist)) + +( setq make-backup-files nil ) ; this ought to be interactive +( setq desktop-save-mode t ) ; +( setq desktop-path '("~/.emacs.d/") ) ; +( setq auto-save-and-recover-context t ) ; to save context upon exit +( setq save-buffer-context t ) ; to save context of all buffers +;; +( recover-context ) +;( desktop-recover ) + +;; ( split-window-horizontally ) ; Start with a split view + +;( ecb-activate ) ; enable Emacs Code Browser by default +(put 'narrow-to-region 'disabled nil) +(put 'upcase-region 'disabled nil) +(put 'downcase-region 'disabled nil) +(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. + '(package-selected-packages + (quote + (visible-mark web-mode elpy yaml-mode terraform-mode puppet-mode magithub json-mode git-gutter-fringe git-gutter+ gist flymake-puppet flymake-json ace-jump-mode)))) diff --git a/.git-completion.bash b/.git-completion.bash deleted file mode 120000 index 30988b8..0000000 --- a/.git-completion.bash +++ /dev/null @@ -1 +0,0 @@ -Dropbox/Work/.git-completion.bash \ No newline at end of file diff --git a/.git-completion.bash b/.git-completion.bash new file mode 100644 index 0000000..5eca08c --- /dev/null +++ b/.git-completion.bash @@ -0,0 +1,3050 @@ +# bash/zsh completion support for core Git. +# +# Copyright (C) 2006,2007 Shawn O. Pearce +# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). +# Distributed under the GNU General Public License, version 2.0. +# +# The contained completion routines provide support for completing: +# +# *) local and remote branch names +# *) local and remote tag names +# *) .git/remotes file names +# *) git 'subcommands' +# *) git email aliases for git-send-email +# *) tree paths within 'ref:path/to/file' expressions +# *) file paths within current working directory and index +# *) common --long-options +# +# To use these routines: +# +# 1) Copy this file to somewhere (e.g. ~/.git-completion.bash). +# 2) Add the following line to your .bashrc/.zshrc: +# source ~/.git-completion.bash +# 3) Consider changing your PS1 to also show the current branch, +# see git-prompt.sh for details. +# +# If you use complex aliases of form '!f() { ... }; f', you can use the null +# command ':' as the first command in the function body to declare the desired +# completion style. For example '!f() { : git commit ; ... }; f' will +# tell the completion to use commit completion. This also works with aliases +# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". +# +# Compatible with bash 3.2.57. +# +# You can set the following environment variables to influence the behavior of +# the completion routines: +# +# GIT_COMPLETION_CHECKOUT_NO_GUESS +# +# When set to "1", do not include "DWIM" suggestions in git-checkout +# completion (e.g., completing "foo" when "origin/foo" exists). + +case "$COMP_WORDBREAKS" in +*:*) : great ;; +*) COMP_WORDBREAKS="$COMP_WORDBREAKS:" +esac + +# Discovers the path to the git repository taking any '--git-dir=' and +# '-C ' options into account and stores it in the $__git_repo_path +# variable. +__git_find_repo_path () +{ + if [ -n "$__git_repo_path" ]; then + # we already know where it is + return + fi + + if [ -n "${__git_C_args-}" ]; then + __git_repo_path="$(git "${__git_C_args[@]}" \ + ${__git_dir:+--git-dir="$__git_dir"} \ + rev-parse --absolute-git-dir 2>/dev/null)" + elif [ -n "${__git_dir-}" ]; then + test -d "$__git_dir" && + __git_repo_path="$__git_dir" + elif [ -n "${GIT_DIR-}" ]; then + test -d "${GIT_DIR-}" && + __git_repo_path="$GIT_DIR" + elif [ -d .git ]; then + __git_repo_path=.git + else + __git_repo_path="$(git rev-parse --git-dir 2>/dev/null)" + fi +} + +# Deprecated: use __git_find_repo_path() and $__git_repo_path instead +# __gitdir accepts 0 or 1 arguments (i.e., location) +# returns location of .git repo +__gitdir () +{ + if [ -z "${1-}" ]; then + __git_find_repo_path || return 1 + echo "$__git_repo_path" + elif [ -d "$1/.git" ]; then + echo "$1/.git" + else + echo "$1" + fi +} + +# Runs git with all the options given as argument, respecting any +# '--git-dir=' and '-C ' options present on the command line +__git () +{ + git ${__git_C_args:+"${__git_C_args[@]}"} \ + ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null +} + +# Removes backslash escaping, single quotes and double quotes from a word, +# stores the result in the variable $dequoted_word. +# 1: The word to dequote. +__git_dequote () +{ + local rest="$1" len ch + + dequoted_word="" + + while test -n "$rest"; do + len=${#dequoted_word} + dequoted_word="$dequoted_word${rest%%[\\\'\"]*}" + rest="${rest:$((${#dequoted_word}-$len))}" + + case "${rest:0:1}" in + \\) + ch="${rest:1:1}" + case "$ch" in + $'\n') + ;; + *) + dequoted_word="$dequoted_word$ch" + ;; + esac + rest="${rest:2}" + ;; + \') + rest="${rest:1}" + len=${#dequoted_word} + dequoted_word="$dequoted_word${rest%%\'*}" + rest="${rest:$((${#dequoted_word}-$len+1))}" + ;; + \") + rest="${rest:1}" + while test -n "$rest" ; do + len=${#dequoted_word} + dequoted_word="$dequoted_word${rest%%[\\\"]*}" + rest="${rest:$((${#dequoted_word}-$len))}" + case "${rest:0:1}" in + \\) + ch="${rest:1:1}" + case "$ch" in + \"|\\|\$|\`) + dequoted_word="$dequoted_word$ch" + ;; + $'\n') + ;; + *) + dequoted_word="$dequoted_word\\$ch" + ;; + esac + rest="${rest:2}" + ;; + \") + rest="${rest:1}" + break + ;; + esac + done + ;; + esac + done +} + +# The following function is based on code from: +# +# bash_completion - programmable completion functions for bash 3.2+ +# +# Copyright © 2006-2008, Ian Macdonald +# © 2009-2010, Bash Completion Maintainers +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# The latest version of this software can be obtained here: +# +# http://bash-completion.alioth.debian.org/ +# +# RELEASE: 2.x + +# This function can be used to access a tokenized list of words +# on the command line: +# +# __git_reassemble_comp_words_by_ref '=:' +# if test "${words_[cword_-1]}" = -w +# then +# ... +# fi +# +# The argument should be a collection of characters from the list of +# word completion separators (COMP_WORDBREAKS) to treat as ordinary +# characters. +# +# This is roughly equivalent to going back in time and setting +# COMP_WORDBREAKS to exclude those characters. The intent is to +# make option types like --date= and : easy to +# recognize by treating each shell word as a single token. +# +# It is best not to set COMP_WORDBREAKS directly because the value is +# shared with other completion scripts. By the time the completion +# function gets called, COMP_WORDS has already been populated so local +# changes to COMP_WORDBREAKS have no effect. +# +# Output: words_, cword_, cur_. + +__git_reassemble_comp_words_by_ref() +{ + local exclude i j first + # Which word separators to exclude? + exclude="${1//[^$COMP_WORDBREAKS]}" + cword_=$COMP_CWORD + if [ -z "$exclude" ]; then + words_=("${COMP_WORDS[@]}") + return + fi + # List of word completion separators has shrunk; + # re-assemble words to complete. + for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do + # Append each nonempty word consisting of just + # word separator characters to the current word. + first=t + while + [ $i -gt 0 ] && + [ -n "${COMP_WORDS[$i]}" ] && + # word consists of excluded word separators + [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] + do + # Attach to the previous token, + # unless the previous token is the command name. + if [ $j -ge 2 ] && [ -n "$first" ]; then + ((j--)) + fi + first= + words_[$j]=${words_[j]}${COMP_WORDS[i]} + if [ $i = $COMP_CWORD ]; then + cword_=$j + fi + if (($i < ${#COMP_WORDS[@]} - 1)); then + ((i++)) + else + # Done. + return + fi + done + words_[$j]=${words_[j]}${COMP_WORDS[i]} + if [ $i = $COMP_CWORD ]; then + cword_=$j + fi + done +} + +if ! type _get_comp_words_by_ref >/dev/null 2>&1; then +_get_comp_words_by_ref () +{ + local exclude cur_ words_ cword_ + if [ "$1" = "-n" ]; then + exclude=$2 + shift 2 + fi + __git_reassemble_comp_words_by_ref "$exclude" + cur_=${words_[cword_]} + while [ $# -gt 0 ]; do + case "$1" in + cur) + cur=$cur_ + ;; + prev) + prev=${words_[$cword_-1]} + ;; + words) + words=("${words_[@]}") + ;; + cword) + cword=$cword_ + ;; + esac + shift + done +} +fi + +# Fills the COMPREPLY array with prefiltered words without any additional +# processing. +# Callers must take care of providing only words that match the current word +# to be completed and adding any prefix and/or suffix (trailing space!), if +# necessary. +# 1: List of newline-separated matching completion words, complete with +# prefix and suffix. +__gitcomp_direct () +{ + local IFS=$'\n' + + COMPREPLY=($1) +} + +__gitcompappend () +{ + local x i=${#COMPREPLY[@]} + for x in $1; do + if [[ "$x" == "$3"* ]]; then + COMPREPLY[i++]="$2$x$4" + fi + done +} + +__gitcompadd () +{ + COMPREPLY=() + __gitcompappend "$@" +} + +# Generates completion reply, appending a space to possible completion words, +# if necessary. +# It accepts 1 to 4 arguments: +# 1: List of possible completion words. +# 2: A prefix to be added to each possible completion word (optional). +# 3: Generate possible completion matches for this word (optional). +# 4: A suffix to be appended to each possible completion word (optional). +__gitcomp () +{ + local cur_="${3-$cur}" + + case "$cur_" in + --*=) + ;; + --no-*) + local c i=0 IFS=$' \t\n' + for c in $1; do + if [[ $c == "--" ]]; then + continue + fi + c="$c${4-}" + if [[ $c == "$cur_"* ]]; then + case $c in + --*=*|*.) ;; + *) c="$c " ;; + esac + COMPREPLY[i++]="${2-}$c" + fi + done + ;; + *) + local c i=0 IFS=$' \t\n' + for c in $1; do + if [[ $c == "--" ]]; then + c="--no-...${4-}" + if [[ $c == "$cur_"* ]]; then + COMPREPLY[i++]="${2-}$c " + fi + break + fi + c="$c${4-}" + if [[ $c == "$cur_"* ]]; then + case $c in + --*=*|*.) ;; + *) c="$c " ;; + esac + COMPREPLY[i++]="${2-}$c" + fi + done + ;; + esac +} + +# Clear the variables caching builtins' options when (re-)sourcing +# the completion script. +if [[ -n ${ZSH_VERSION-} ]]; then + unset $(set |sed -ne 's/^\(__gitcomp_builtin_[a-zA-Z0-9_][a-zA-Z0-9_]*\)=.*/\1/p') 2>/dev/null +else + unset $(compgen -v __gitcomp_builtin_) +fi + +# This function is equivalent to +# +# __gitcomp "$(git xxx --git-completion-helper) ..." +# +# except that the output is cached. Accept 1-3 arguments: +# 1: the git command to execute, this is also the cache key +# 2: extra options to be added on top (e.g. negative forms) +# 3: options to be excluded +__gitcomp_builtin () +{ + # spaces must be replaced with underscore for multi-word + # commands, e.g. "git remote add" becomes remote_add. + local cmd="$1" + local incl="$2" + local excl="$3" + + local var=__gitcomp_builtin_"${cmd/-/_}" + local options + eval "options=\$$var" + + if [ -z "$options" ]; then + # leading and trailing spaces are significant to make + # option removal work correctly. + options=" $incl $(__git ${cmd/_/ } --git-completion-helper) " + for i in $excl; do + options="${options/ $i / }" + done + eval "$var=\"$options\"" + fi + + __gitcomp "$options" +} + +# Variation of __gitcomp_nl () that appends to the existing list of +# completion candidates, COMPREPLY. +__gitcomp_nl_append () +{ + local IFS=$'\n' + __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" +} + +# Generates completion reply from newline-separated possible completion words +# by appending a space to all of them. +# It accepts 1 to 4 arguments: +# 1: List of possible completion words, separated by a single newline. +# 2: A prefix to be added to each possible completion word (optional). +# 3: Generate possible completion matches for this word (optional). +# 4: A suffix to be appended to each possible completion word instead of +# the default space (optional). If specified but empty, nothing is +# appended. +__gitcomp_nl () +{ + COMPREPLY=() + __gitcomp_nl_append "$@" +} + +# Fills the COMPREPLY array with prefiltered paths without any additional +# processing. +# Callers must take care of providing only paths that match the current path +# to be completed and adding any prefix path components, if necessary. +# 1: List of newline-separated matching paths, complete with all prefix +# path components. +__gitcomp_file_direct () +{ + local IFS=$'\n' + + COMPREPLY=($1) + + # use a hack to enable file mode in bash < 4 + compopt -o filenames +o nospace 2>/dev/null || + compgen -f /non-existing-dir/ >/dev/null || + true +} + +# Generates completion reply with compgen from newline-separated possible +# completion filenames. +# It accepts 1 to 3 arguments: +# 1: List of possible completion filenames, separated by a single newline. +# 2: A directory prefix to be added to each possible completion filename +# (optional). +# 3: Generate possible completion matches for this word (optional). +__gitcomp_file () +{ + local IFS=$'\n' + + # XXX does not work when the directory prefix contains a tilde, + # since tilde expansion is not applied. + # This means that COMPREPLY will be empty and Bash default + # completion will be used. + __gitcompadd "$1" "${2-}" "${3-$cur}" "" + + # use a hack to enable file mode in bash < 4 + compopt -o filenames +o nospace 2>/dev/null || + compgen -f /non-existing-dir/ >/dev/null || + true +} + +# Execute 'git ls-files', unless the --committable option is specified, in +# which case it runs 'git diff-index' to find out the files that can be +# committed. It return paths relative to the directory specified in the first +# argument, and using the options specified in the second argument. +__git_ls_files_helper () +{ + if [ "$2" == "--committable" ]; then + __git -C "$1" -c core.quotePath=false diff-index \ + --name-only --relative HEAD -- "${3//\\/\\\\}*" + else + # NOTE: $2 is not quoted in order to support multiple options + __git -C "$1" -c core.quotePath=false ls-files \ + --exclude-standard $2 -- "${3//\\/\\\\}*" + fi +} + + +# __git_index_files accepts 1 or 2 arguments: +# 1: Options to pass to ls-files (required). +# 2: A directory path (optional). +# If provided, only files within the specified directory are listed. +# Sub directories are never recursed. Path must have a trailing +# slash. +# 3: List only paths matching this path component (optional). +__git_index_files () +{ + local root="$2" match="$3" + + __git_ls_files_helper "$root" "$1" "$match" | + awk -F / -v pfx="${2//\\/\\\\}" '{ + paths[$1] = 1 + } + END { + for (p in paths) { + if (substr(p, 1, 1) != "\"") { + # No special characters, easy! + print pfx p + continue + } + # The path is quoted. + p = dequote(p) + if (p == "") + continue + # Even when a directory name itself does not contain + # any special characters, it will still be quoted if + # any of its (stripped) trailing path components do. + # Because of this we may have seen the same direcory + # both quoted and unquoted. + if (p in paths) + # We have seen the same directory unquoted, + # skip it. + continue + else + print pfx p + } + } + function dequote(p, bs_idx, out, esc, esc_idx, dec) { + # Skip opening double quote. + p = substr(p, 2) + # Interpret backslash escape sequences. + while ((bs_idx = index(p, "\\")) != 0) { + out = out substr(p, 1, bs_idx - 1) + esc = substr(p, bs_idx + 1, 1) + p = substr(p, bs_idx + 2) + if ((esc_idx = index("abtvfr\"\\", esc)) != 0) { + # C-style one-character escape sequence. + out = out substr("\a\b\t\v\f\r\"\\", + esc_idx, 1) + } else if (esc == "n") { + # Uh-oh, a newline character. + # We cant reliably put a pathname + # containing a newline into COMPREPLY, + # and the newline would create a mess. + # Skip this path. + return "" + } else { + # Must be a \nnn octal value, then. + dec = esc * 64 + \ + substr(p, 1, 1) * 8 + \ + substr(p, 2, 1) + out = out sprintf("%c", dec) + p = substr(p, 3) + } + } + # Drop closing double quote, if there is one. + # (There isnt any if this is a directory, as it was + # already stripped with the trailing path components.) + if (substr(p, length(p), 1) == "\"") + out = out substr(p, 1, length(p) - 1) + else + out = out p + return out + }' +} + +# __git_complete_index_file requires 1 argument: +# 1: the options to pass to ls-file +# +# The exception is --committable, which finds the files appropriate commit. +__git_complete_index_file () +{ + local dequoted_word pfx="" cur_ + + __git_dequote "$cur" + + case "$dequoted_word" in + ?*/*) + pfx="${dequoted_word%/*}/" + cur_="${dequoted_word##*/}" + ;; + *) + cur_="$dequoted_word" + esac + + __gitcomp_file_direct "$(__git_index_files "$1" "$pfx" "$cur_")" +} + +# Lists branches from the local repository. +# 1: A prefix to be added to each listed branch (optional). +# 2: List only branches matching this word (optional; list all branches if +# unset or empty). +# 3: A suffix to be appended to each listed branch (optional). +__git_heads () +{ + local pfx="${1-}" cur_="${2-}" sfx="${3-}" + + __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ + "refs/heads/$cur_*" "refs/heads/$cur_*/**" +} + +# Lists tags from the local repository. +# Accepts the same positional parameters as __git_heads() above. +__git_tags () +{ + local pfx="${1-}" cur_="${2-}" sfx="${3-}" + + __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ + "refs/tags/$cur_*" "refs/tags/$cur_*/**" +} + +# Lists refs from the local (by default) or from a remote repository. +# It accepts 0, 1 or 2 arguments: +# 1: The remote to list refs from (optional; ignored, if set but empty). +# Can be the name of a configured remote, a path, or a URL. +# 2: In addition to local refs, list unique branches from refs/remotes/ for +# 'git checkout's tracking DWIMery (optional; ignored, if set but empty). +# 3: A prefix to be added to each listed ref (optional). +# 4: List only refs matching this word (optional; list all refs if unset or +# empty). +# 5: A suffix to be appended to each listed ref (optional; ignored, if set +# but empty). +# +# Use __git_complete_refs() instead. +__git_refs () +{ + local i hash dir track="${2-}" + local list_refs_from=path remote="${1-}" + local format refs + local pfx="${3-}" cur_="${4-$cur}" sfx="${5-}" + local match="${4-}" + local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers + + __git_find_repo_path + dir="$__git_repo_path" + + if [ -z "$remote" ]; then + if [ -z "$dir" ]; then + return + fi + else + if __git_is_configured_remote "$remote"; then + # configured remote takes precedence over a + # local directory with the same name + list_refs_from=remote + elif [ -d "$remote/.git" ]; then + dir="$remote/.git" + elif [ -d "$remote" ]; then + dir="$remote" + else + list_refs_from=url + fi + fi + + if [ "$list_refs_from" = path ]; then + if [[ "$cur_" == ^* ]]; then + pfx="$pfx^" + fer_pfx="$fer_pfx^" + cur_=${cur_#^} + match=${match#^} + fi + case "$cur_" in + refs|refs/*) + format="refname" + refs=("$match*" "$match*/**") + track="" + ;; + *) + for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do + case "$i" in + $match*) + if [ -e "$dir/$i" ]; then + echo "$pfx$i$sfx" + fi + ;; + esac + done + format="refname:strip=2" + refs=("refs/tags/$match*" "refs/tags/$match*/**" + "refs/heads/$match*" "refs/heads/$match*/**" + "refs/remotes/$match*" "refs/remotes/$match*/**") + ;; + esac + __git_dir="$dir" __git for-each-ref --format="$fer_pfx%($format)$sfx" \ + "${refs[@]}" + if [ -n "$track" ]; then + # employ the heuristic used by git checkout + # Try to find a remote branch that matches the completion word + # but only output if the branch name is unique + __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ + --sort="refname:strip=3" \ + "refs/remotes/*/$match*" "refs/remotes/*/$match*/**" | \ + uniq -u + fi + return + fi + case "$cur_" in + refs|refs/*) + __git ls-remote "$remote" "$match*" | \ + while read -r hash i; do + case "$i" in + *^{}) ;; + *) echo "$pfx$i$sfx" ;; + esac + done + ;; + *) + if [ "$list_refs_from" = remote ]; then + case "HEAD" in + $match*) echo "${pfx}HEAD$sfx" ;; + esac + __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ + "refs/remotes/$remote/$match*" \ + "refs/remotes/$remote/$match*/**" + else + local query_symref + case "HEAD" in + $match*) query_symref="HEAD" ;; + esac + __git ls-remote "$remote" $query_symref \ + "refs/tags/$match*" "refs/heads/$match*" \ + "refs/remotes/$match*" | + while read -r hash i; do + case "$i" in + *^{}) ;; + refs/*) echo "$pfx${i#refs/*/}$sfx" ;; + *) echo "$pfx$i$sfx" ;; # symbolic refs + esac + done + fi + ;; + esac +} + +# Completes refs, short and long, local and remote, symbolic and pseudo. +# +# Usage: __git_complete_refs [