Browse Source

Massive spring cleaning

master
Peter J. Jones 2 years ago
parent
commit
21853d58da
Signed by: Peter Jones <pjones@devalot.com> GPG Key ID: 9DAFAA8D01941E49
43 changed files with 119 additions and 728 deletions
  1. 15
    23
      GNUmakefile
  2. 26
    0
      LICENSE
  3. 10
    0
      README.md
  4. 0
    40
      app/cltc.zsh
  5. 0
    10
      app/dict.zsh
  6. 0
    142
      app/git.zsh
  7. 0
    17
      app/gpg.zsh
  8. 0
    12
      app/mysql.zsh
  9. 0
    50
      app/nix.zsh
  10. 0
    12
      app/ruby.zsh
  11. 0
    7
      app/script.zsh
  12. 0
    1
      app/ssh.zsh
  13. 0
    83
      app/tmux.zsh
  14. 0
    122
      app/virsh.zsh
  15. 0
    33
      app/vmware.zsh
  16. 0
    14
      app/wmctrl.zsh
  17. 0
    1
      app/xcode.zsh
  18. 5
    7
      dot/zshenv
  19. 10
    20
      dot/zshrc
  20. 12
    14
      func/c
  21. 2
    3
      func/d
  22. 2
    2
      func/get
  23. 6
    0
      func/gpg-which
  24. 0
    17
      func/loop
  25. 7
    5
      func/mkpatches
  26. 0
    33
      func/send-key
  27. 0
    24
      func/st
  28. 2
    2
      func/untar
  29. 4
    7
      lib/aliases.zsh
  30. 2
    0
      lib/bindings.zsh
  31. 2
    0
      lib/completion.zsh
  32. 2
    0
      lib/directories.zsh
  33. 2
    0
      lib/editor.zsh
  34. 2
    0
      lib/history.zsh
  35. 2
    0
      lib/hosts.zsh
  36. 2
    0
      lib/prompt.zsh
  37. 0
    2
      local/beefy.local
  38. 0
    2
      local/skinny.local
  39. 1
    1
      os/darwin
  40. 1
    1
      os/linux
  41. 1
    1
      os/sunos
  42. 0
    19
      util/git-sb-info.zsh
  43. 1
    1
      wids/last-cmd-as-expansion

+ 15
- 23
GNUmakefile View File

@@ -1,32 +1,24 @@
1 1
 ################################################################################
2
-include ../mk/init.mk
3
-include ../mk/files.mk
2
+PREFIX ?= $(HOME)
4 3
 
5 4
 ################################################################################
6
-DEST = $(HOME)/.zsh
7
-HOST = $(shell hostname)
8
-OS   = $(shell uname -s | tr '[:upper:]' '[:lower:]')
5
+LIBS = $(shell find func lib os wids -type f)
6
+DOTS = $(shell find dot -type f)
9 7
 
10 8
 ################################################################################
11
-FILES  = $(wildcard lib/*.zsh)
12
-FILES += $(wildcard app/*.zsh)
13
-FILES += $(wildcard util/*.zsh)
14
-FILES += $(wildcard func/*)
15
-FILES += $(wildcard wids/*.zsh)
9
+.PHONEY: install
16 10
 
17 11
 ################################################################################
18
-$(foreach f,$(FILES),$(eval $(call PMADE_INSTALL_FILE,$(f),$(DEST)/$(f))))
19
-$(eval $(call PMADE_INSTALL_DOT,dot/zshrc))
20
-$(eval $(call PMADE_INSTALL_DOT,dot/zshenv))
12
+# $1: Source file.
13
+# $2: Destination name.
14
+define INSTALL_FILE
15
+install: $(PREFIX)/$(2)
16
+$(PREFIX)/$(2): $(1)
17
+	@ echo "==> $$@"
18
+	@ mkdir -p `dirname $$@`
19
+	@ sed "s|@prefix@|$(PREFIX)|g" < $$< > $$@
20
+endef
21 21
 
22 22
 ################################################################################
23
-# Local (hostname based) Override
24
-ifneq ($(wildcard local/$(HOSTNAME)),)
25
-  $(eval $(call PMADE_INSTALL_FILE,local/$(HOSTNAME),$(DEST)/local))
26
-endif
27
-
28
-################################################################################
29
-# OS (os name based) Override
30
-ifneq ($(wildcard os/$(OS)),)
31
-  $(eval $(call PMADE_INSTALL_FILE,os/$(OS),$(DEST)/os))
32
-endif
23
+$(foreach f,$(LIBS),$(eval $(call INSTALL_FILE,$(f),.zsh/$(f))))
24
+$(foreach f,$(DOTS),$(eval $(call INSTALL_FILE,$(f),.$(notdir $(f)))))

+ 26
- 0
LICENSE View File

@@ -0,0 +1,26 @@
1
+Copyright (c) 2002-2017, Peter J. Jones <pjones@devalot.com>
2
+All rights reserved.
3
+
4
+Redistribution and use in source and binary forms, with or without
5
+modification, are permitted provided that the following conditions are
6
+met:
7
+
8
+1. Redistributions of source code must retain the above copyright
9
+   notice, this list of conditions and the following disclaimer.
10
+
11
+2. Redistributions in binary form must reproduce the above copyright
12
+   notice, this list of conditions and the following disclaimer in the
13
+   documentation and/or other materials provided with the
14
+   distribution.
15
+
16
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 10
- 0
README.md View File

@@ -0,0 +1,10 @@
1
+# zshrc: Configuration for ZSH
2
+
3
+Peter's `zsh` configuration files.
4
+
5
+## Installing These Files
6
+
7
+By default, running `make` will install everything under $HOME.  To
8
+change that, set the `PREFIX` variable:
9
+
10
+    $ make PREFIX=/some/path install

+ 0
- 40
app/cltc.zsh View File

@@ -1,40 +0,0 @@
1
-if [ `hostname` = "cltc" ]; then
2
-
3
-  ##############################################################################
4
-  function _cltc-app {
5
-    name=$1
6
-    dir=$HOME/scors/$name
7
-
8
-    if [ -n "$shellHook" ]; then
9
-      echo "ERROR: you're already inside nix-shell"
10
-      exit 1
11
-    fi
12
-
13
-    if [ ! -d $dir ]; then
14
-      ( cd `dirname $dir`
15
-        git clone --recursive git@github.ors.sc.gov:ors/${name}.git
16
-      )
17
-    fi
18
-
19
-    ( export DEV_ENV=$name
20
-      cd $dir
21
-      nix-shell --command zsh ~/.nixpkgs/envs/scors/${name}.nix
22
-    )
23
-  }
24
-
25
-  ##############################################################################
26
-  function cltc-phoenix {
27
-    _cltc-app cltc-phoenix
28
-  }
29
-
30
-  ##############################################################################
31
-  function cltc-claims {
32
-    _cltc-app cltc-claims
33
-  }
34
-
35
-  ##############################################################################
36
-  function cltc-flock {
37
-    _cltc-app cltc-flock
38
-  }
39
-
40
-fi

+ 0
- 10
app/dict.zsh View File

@@ -1,10 +0,0 @@
1
-################################################################################
2
-dict_it () {
3
-  dict --database ita-eng "$@"
4
-}
5
-
6
-################################################################################
7
-dict_sounds_like () {
8
-  dict --match --strategy soundex "$@"
9
-  dict --match --strategy lev     "$@"
10
-}

+ 0
- 142
app/git.zsh View File

@@ -1,142 +0,0 @@
1
-################################################################################
2
-# Git Log
3
-glog ()
4
-{
5
-    git log --pretty=format:'%Cgreen%h%Creset %Cred%ci%Creset %Cblue%ae%Creset %s' --graph $@
6
-}
7
-
8
-################################################################################
9
-# Resolve conflicts by keeping the local changes and throwing away the
10
-# remote changes
11
-git_resolve_with_local ()
12
-{
13
-  if [ $# -eq 0 ]; then
14
-    FILES=`git ls-files -u | awk '{if ($3==1) print $4;}'`
15
-    test -z "$FILES" && exit
16
-  else
17
-    FILES=$*
18
-  fi
19
-
20
-  PREFIX=`git rev-parse --show-prefix`
21
-
22
-  # need the echo below because the files are someone all glued
23
-  # together in a single string
24
-  for f in `echo $FILES`; do
25
-    echo "--> Tossing remote changes for $f"
26
-    git cat-file blob ":2:${PREFIX}${f}" >| "$f" 2> /dev/null
27
-    touch "$f"
28
-    git add -- "$f"
29
-  done
30
-
31
-  echo "now run git commit"
32
-}
33
-
34
-################################################################################
35
-# Find out if a repo has uncommitted changes
36
-git_repo_has_changes ()
37
-{
38
-  if ! git status|grep -q -F 'working directory clean'; then
39
-    return 0
40
-  else
41
-    return 1
42
-  fi
43
-}
44
-
45
-################################################################################
46
-# Find out if a repo has changes that haven't been pushed
47
-git_repo_needs_push ()
48
-{
49
-  if git status|head -2|grep -q 'ahead of'; then
50
-    return 0
51
-  else
52
-    return 1
53
-  fi
54
-}
55
-
56
-################################################################################
57
-# Returns the name of the current git branch if we're in a git repo
58
-git_current_branch ()
59
-{
60
-  ref=$(git symbolic-ref HEAD 2> /dev/null) || return
61
-  echo ${ref#refs/heads/}
62
-}
63
-
64
-################################################################################
65
-# Create a new branch, and push it to the origin server
66
-git_mk_branch ()
67
-{
68
-  if [ $# -eq 0 ]; then
69
-    echo "Usage: $0 branch [remote]"
70
-    return 1
71
-  fi
72
-
73
-  branch=$1
74
-  remote=${2:-origin}
75
-
76
-  git checkout -b $branch || return 1
77
-  git config --add branch.${branch}.remote $remote || return 1
78
-  git push $remote $branch || return 1
79
-}
80
-
81
-################################################################################
82
-# Delete a branch: FIXME: remove from all remotes
83
-git_rm_branch ()
84
-{
85
-  if [ $# -eq 0 ]; then
86
-    echo "Usage: $0 branch"
87
-    return 1
88
-  fi
89
-
90
-  branch=$1
91
-  git branch -d $branch || return 1
92
-
93
-  if git branch -a | grep -q origin/$branch; then
94
-    git push origin :heads/$branch
95
-  fi
96
-}
97
-
98
-################################################################################
99
-# Pull master, and return to the current branch
100
-git_master_pull ()
101
-{
102
-  remote=origin
103
-  test $# -eq 1 && remote=$1
104
-
105
-  branch=`git_current_branch`
106
-  echo "==> Leaving branch ${branch}"
107
-  git checkout master  || return 1
108
-  git pull $remote     || return 1
109
-  git checkout $branch || return 1
110
-}
111
-
112
-################################################################################
113
-# List info about each sub-module
114
-function git-sb-info ()
115
-{
116
-  git submodule --quiet foreach 'zsh ~/.zsh/util/git-sb-info.zsh'
117
-}
118
-
119
-################################################################################
120
-# Create a new remote repo
121
-git_new_repo ()
122
-{
123
-  remote_path=$1
124
-  remote_name=origin
125
-  remote_host=dracula.pmade.com
126
-
127
-  test $# -gt 1 && remote_name=$2
128
-  test $# -gt 2 && remote_host=$3
129
-
130
-  ssh $remote_host "mkdir -p $remote_path && cd $remote_path && git init --bare"
131
-  git remote add $remote_name ${remote_host}:$remote_path
132
-  git config --add branch.master.remote $remote_name
133
-  git config --add branch.master.merge refs/heads/master
134
-  git push $remote_name master
135
-}
136
-
137
-################################################################################
138
-# Find out about the current repo.
139
-function git-what ()
140
-{
141
-  git describe --long --tags --dirty --always
142
-}

+ 0
- 17
app/gpg.zsh View File

@@ -1,17 +0,0 @@
1
-################################################################################
2
-alias gpg=gpg2
3
-
4
-################################################################################
5
-# Outputs which key was used to encrypt a file.
6
-gpg_which () {
7
-  file=$1
8
-  key=$(_gpg_which_key $file)
9
-  gpg2 --list-keys $key
10
-}
11
-
12
-################################################################################
13
-# Helper function.
14
-_gpg_which_key () {
15
-  gpg2 --batch --decrypt --list-only --status-fd 1 $1 2> /dev/null |\
16
-    awk '/ENC_TO/ {print $3}'
17
-}

+ 0
- 12
app/mysql.zsh View File

@@ -1,12 +0,0 @@
1
-# Create a new super user in mySQL
2
-mysql_create_super_user () {
3
-  if [ $# -ne 2 ]; then
4
-    echo "Usage: $0 username password"
5
-    return 1
6
-  fi
7
-  
8
-  for user in "'${1}'@'localhost'" "'${1}'@'%'"; do
9
-    echo CREATE USER "${user}" IDENTIFIED BY "'${2}'" | mysql -u root
10
-    echo GRANT ALL PRIVILEGES ON "*.*" TO "${user}" WITH GRANT OPTION | mysql -u root
11
-  done
12
-}

+ 0
- 50
app/nix.zsh View File

@@ -1,50 +0,0 @@
1
-################################################################################
2
-# Functions for making Nix and NixOS a bit easier.
3
-if [ -d /etc/nix ]; then
4
-
5
-  ##############################################################################
6
-  function _nix-inside-shell () {
7
-    if [[ -n $NIX_BUILD_TOP ]]; then
8
-      return 0
9
-    else
10
-      return 1
11
-    fi
12
-  }
13
-
14
-  ##############################################################################
15
-  # Run a Nix command with the correct options and environment for a
16
-  # local copy of nixpkgs.
17
-  function _nix-with-nixpkgs () {
18
-    command=$1
19
-    shift
20
-
21
-    typeset -a options
22
-    options=()
23
-
24
-    # Automatically add a binary cache when on my home network:
25
-    if iwgetid | cut -d: -f2 | grep -q "515"; then
26
-      options=($options --option extra-binary-caches http://10.0.1.10:8080)
27
-    fi
28
-
29
-    export NIX_PATH=nixpkgs=$HOME/develop/oss/nixpkgs:$NIX_PATH
30
-    $command $options "$@"
31
-  }
32
-
33
-  ##############################################################################
34
-  # Nix shell with a local clone of nixpkgs.
35
-  function nixpkgs-shell () {
36
-    _nix-with-nixpkgs nix-shell --command $(which zsh) "$@"
37
-  }
38
-
39
-  ##############################################################################
40
-  # Nix build with a local clone of nixpkgs.
41
-  function nixpkgs-build () {
42
-    _nix-with-nixpkgs nix-build "$@"
43
-  }
44
-
45
-################################################################################
46
-else
47
-
48
-  ##############################################################################
49
-  function _nix-inside-shell () {return 1}
50
-fi

+ 0
- 12
app/ruby.zsh View File

@@ -1,12 +0,0 @@
1
-################################################################################
2
-# If the rbenv tool is installed, use it.
3
-if [ -d ~/.rbenv/bin ]; then
4
-  path=(~/.rbenv/bin $path)
5
-  eval "$(rbenv init -)"
6
-fi
7
-
8
-################################################################################
9
-alias irb='irb --readline -r irb/completion'
10
-
11
-################################################################################
12
-rtags () { command rtags --quiet $(find . -type f -name '*.rb')}

+ 0
- 7
app/script.zsh View File

@@ -1,7 +0,0 @@
1
-# script
2
-script ()
3
-{
4
-    script_options='-a'
5
-    [[ $OSNAME == "FreeBSD" ]] && script_options="$script_options -k"
6
-    (export INSIDE_SCRIPT=yes; command script `eval echo $script_options` $*)
7
-}

+ 0
- 1
app/ssh.zsh View File

@@ -1 +0,0 @@
1
-alias add-key='ssh-add $HOME/.ssh/id_dsa'

+ 0
- 83
app/tmux.zsh View File

@@ -1,83 +0,0 @@
1
-################################################################################
2
-# Mount a virtual machine via SSHFS and then create a tmux session
3
-# inside it.
4
-tmux_mount () {
5
-  if [ $# -ne 1 ]; then
6
-    echo "Usage: tmux_mount name"
7
-    return 1
8
-  fi
9
-
10
-  name=$1
11
-  mount_point=$HOME/develop/hosts/$1
12
-  mount_options="-oauto_cache,reconnect,ControlMaster=no"
13
-  server=${name}.pmade.com
14
-
15
-  # If the host is a VM and it's not already running, start it.
16
-  virsh_is_registered $name && (virsh_running $name || virsh_start $name)
17
-
18
-  echo "==> Mounting $name on $mount_point"
19
-  mkdir -p $mount_point
20
-
21
-  if ssh $server test -d develop; then
22
-    server_dir=develop
23
-  elif ssh $server test -d Develop; then
24
-    server_dir=Develop
25
-  else
26
-    server_dir=""
27
-  fi
28
-
29
-  sshfs "${server}:${server_dir}" $mount_point $mount_options || return 1
30
-  cp ~/.emacs.d/server/server $mount_point/emacs.server
31
-
32
-  echo "==> Starting tmux session $name"
33
-  (cd $mount_point && tmux new-session -d -s $name)
34
-
35
-  return $?
36
-}
37
-
38
-################################################################################
39
-# Mount and attach to a new session
40
-tmux_mount_attach () {
41
-  tmux_mount $1 && tmux attach -t $1
42
-}
43
-
44
-################################################################################
45
-# Kill a tmux session and un-mount the sshfs file system.
46
-tmux_umount () {
47
-  if [ $# -ne 1 ]; then
48
-    echo "Usage: tmux_umount name"
49
-    return 1
50
-  fi
51
-
52
-  name=$1
53
-  mount_point=$HOME/develop/hosts/$1
54
-
55
-  if tmux list-sessions | awk '{print $1}' | grep -q ^${name}:\$; then
56
-    echo "==> Killing tmux session $name"
57
-    tmux kill-session -t $name || return 1
58
-    sleep 2 # Wait for all processes accessing the VM to die
59
-  fi
60
-
61
-  # Avoid my 'df' alias below by giving the full path
62
-  if /bin/df -P | awk 'NR > 1 {print $6}' | grep -q hosts/$name\$; then
63
-    echo "==> Un-mounting $mount_point"
64
-    fusermount -u $mount_point || return 1
65
-  fi
66
-}
67
-
68
-################################################################################
69
-# Runs tmux_umount and then stops the VM
70
-tmux_umount_stop () {
71
-  if [ $# -ne 1 ]; then
72
-    echo "Usage: tmux_umount_stop name"
73
-    return 1
74
-  fi
75
-
76
-  name=$1
77
-  tmux_umount $name || return 1
78
-
79
-  if virsh_running $name; then
80
-    echo "==> Stopping $name virtual machine"
81
-    virsh_stop $name || return 1
82
-  fi
83
-}

+ 0
- 122
app/virsh.zsh View File

@@ -1,122 +0,0 @@
1
-################################################################################
2
-# Returns 0 if a VM is running, otherwise 1.
3
-virsh_running () {
4
-  if [ $# -ne 1 ]; then
5
-    echo "Usage: virsh_running name"
6
-    return 2
7
-  fi
8
-
9
-  name=$1
10
-  state=`virsh dominfo $name | grep ^State | awk '{print $2}'`
11
-
12
-  if [ "$state" = "running" ]; then
13
-    return 0
14
-  else
15
-    return 1
16
-  fi
17
-}
18
-
19
-################################################################################
20
-# Returns 0 if the given VM is registered with libvirt, otherwise 1.
21
-virsh_is_registered () {
22
-  if [ $# -ne 1 ]; then
23
-    echo "Usage: virsh_is_registered name"
24
-    return 2
25
-  fi
26
-
27
-  name=$1
28
-
29
-  if virsh dominfo $name > /dev/null 2>&1; then
30
-    return 0
31
-  else
32
-    return 1
33
-  fi
34
-}
35
-
36
-################################################################################
37
-# Returns 0 if the VM has managed save info, otherwise 1.
38
-virsh_has_managed_save () {
39
-  if [ $# -ne 1 ]; then
40
-    echo "Usage: virsh_has_managed_save name"
41
-    return 2
42
-  fi
43
-
44
-  name=$1
45
-  save=`virsh dominfo $name | grep '^Managed save' | awk '{print $3}'`
46
-
47
-  if [ "$save" = "yes" ]; then
48
-    return 0
49
-  else
50
-    return 1
51
-  fi
52
-}
53
-
54
-################################################################################
55
-# Returns the current version of libvirt
56
-virsh_version () {
57
-  virsh version | head -1 | awk -F: '{print $2}' | awk '{print $2}'
58
-}
59
-
60
-################################################################################
61
-# Start a VM and wait for it to be running.
62
-virsh_start () {
63
-  if [ $# -ne 1 ]; then
64
-    echo "Usage: virsh_start name"
65
-    return 1
66
-  fi
67
-
68
-  name=$1
69
-  hostname="${name}.pmade.com"
70
-
71
-  # First check to see if we're already running.
72
-  virsh_running $name && return 0
73
-
74
-  # Record if we have managed state
75
-  if virsh_has_managed_save $name; then
76
-    with_save=1
77
-  else
78
-    with_save=0
79
-  fi
80
-
81
-  # Start it and wait for it to be pingable
82
-  virsh start $name || return 1
83
-  echo "==> Waiting for $name to start..."
84
-  [ $with_save -eq 0 ] && sleep 60
85
-  ping -c 5 -q -w 120 $hostname
86
-}
87
-
88
-################################################################################
89
-# Stop a running VM using managedsave.
90
-virsh_stop () {
91
-  if [ $# -ne 1 ]; then
92
-    echo "Usage: virsh_stop name"
93
-    return 1
94
-  fi
95
-
96
-  name=$1
97
-  flags=""
98
-
99
-  if [ $(virsh_version) != '0.9.8' ]; then
100
-    flags="--verbose"
101
-  fi
102
-
103
-  # Can't stop a domain unless it's running
104
-  virsh_running $name || return 0
105
-
106
-  echo "==> Waiting for $name to stop"
107
-  virsh managedsave $name $flags
108
-}
109
-
110
-################################################################################
111
-# Open a vnc connection to a virtual machine
112
-virsh_vnc () {
113
-  if [ $# -ne 1 ]; then
114
-    echo "Usage: virsh_vnc name"
115
-    return 1
116
-  fi
117
-
118
-  name=$1
119
-  port=$(virsh vncdisplay $name|head -1|sed 's/^.*://')
120
-  port=$(expr 5900 + $port)
121
-  vnc localhost:$port
122
-}

+ 0
- 33
app/vmware.zsh View File

@@ -1,33 +0,0 @@
1
-################################################################################
2
-# Access the vmrun tool.
3
-vmware_vmrun () {
4
-  "/Library/Application Support/VMware Fusion/vmrun" $@
5
-}
6
-
7
-################################################################################
8
-# Returns the base directory where we mount things.
9
-vmware_base_mount_point () {
10
-  echo ~/Develop/hosts
11
-}
12
-
13
-################################################################################
14
-# Mount a VMWare virtual machine using sshfs
15
-vmware_mount () {
16
-  name=$1
17
-
18
-  server="sshfs.${name}.pmade.com"
19
-  directory=`vmware_base_mount_point`"/$name"
20
-  
21
-  mkdir -p $directory
22
-  sshfs "${server}:" $directory -oauto_cache,reconnect,volname=$name
23
-}
24
-
25
-################################################################################
26
-# Mount a virtual machine and create a tmux session
27
-vmware_session () {
28
-  name=$1
29
-  
30
-  vmware_mount $name || return 1
31
-  directory=`vmware_base_mount_point`"/$name"
32
-  (cd $directory/develop && tmux new-session -d -s $name)
33
-}

+ 0
- 14
app/wmctrl.zsh View File

@@ -1,14 +0,0 @@
1
-################################################################################
2
-wmctrl_activate_emacs () {
3
-  win_id=$(wmctrl -l |awk '$4 ~ /emacs/ && $2 == 0 {print $1}'|head -1)
4
-  
5
-  if [[ -n $win_id ]]; then
6
-    wmctrl -ia $win_id
7
-  fi
8
-}
9
-
10
-################################################################################
11
-# Activates the biggest Conkeror window.
12
-wmctrl_activate_conkeror () {
13
-  wmctrl -ia $(wmctrl -lG|grep Conkeror|sort -nk 5|tail -1|awk '{print $1}')
14
-}

+ 0
- 1
app/xcode.zsh View File

@@ -1 +0,0 @@
1
-alias xc='xcodebuild -alltargets -configuration Debug && xcodebuild -alltargets -configuration Release'

+ 5
- 7
dot/zshenv View File

@@ -1,4 +1,4 @@
1
-#!/usr/bin/env zsh
1
+#!zsh
2 2
 
3 3
 # Set default path
4 4
 typeset -U path
@@ -7,14 +7,12 @@ typeset -U path
7 7
 path=(~/bin $path)
8 8
 
9 9
 # Load core environment variables.
10
-source ~/.zsh/lib/editor.zsh
10
+source @prefix@/.zsh/lib/editor.zsh
11 11
 
12 12
 # Other environment variables:
13 13
 export VIRSH_DEFAULT_CONNECT_URI="qemu:///system"
14
-export GPG_TTY=`tty`
14
+export GPG_TTY=$(tty)
15
+export OS=$(uname -s | tr '[A-Z]' '[a-z]')
15 16
 
16 17
 # Load in optional operating system override
17
-[ -r ~/.zsh/os ] && source ~/.zsh/os
18
-
19
-# Load in optional local override file
20
-[ -r ~/.zsh/local ] && source ~/.zsh/local
18
+[ -r "@prefix@/.zsh/$OS" ] && source "@prefix@/.zsh/$OS"

+ 10
- 20
dot/zshrc View File

@@ -1,4 +1,4 @@
1
-#!/usr/local/bin/zsh
1
+#!zsh
2 2
 
3 3
 # keep some arrays unique
4 4
 typeset -U fpath
@@ -6,13 +6,12 @@ typeset -U cdpath
6 6
 typeset -U manpath
7 7
 
8 8
 # some variables to export
9
-export OSNAME=`uname -s`
10 9
 export LESS="-SRiJMW"
11 10
 export PAGER=less
12 11
 
13 12
 # add our function path
14
-functions_directory=~/.zsh/func
15
-widgets_directory=~/.zsh/wids
13
+functions_directory=@prefix@/.zsh/func
14
+widgets_directory=@prefix@/.zsh/wids
16 15
 fpath=($functions_directory $widgets_directory $fpath)
17 16
 
18 17
 # clober stuff
@@ -44,19 +43,10 @@ autoload -U ${fpath[1]}/*(:t)
44 43
 zmodload zsh/datetime
45 44
 
46 45
 # bring in other files
47
-source ~/.zsh/lib/bindings.zsh
48
-source ~/.zsh/lib/aliases.zsh
49
-source ~/.zsh/lib/hosts.zsh
50
-source ~/.zsh/lib/completion.zsh
51
-source ~/.zsh/lib/directories.zsh
52
-source ~/.zsh/lib/history.zsh
53
-source ~/.zsh/lib/prompt.zsh
54
-
55
-# Application files are autoloaded, if I can get it to freaking work:
56
-# http://zsh.sourceforge.net/Doc/Release/Functions.html
57
-# fpath=(~/.zsh/app $fpath)
58
-
59
-for file in $(find ~/.zsh/app -type f -name '*.zsh'); do
60
-  source $file
61
-  #autoload -w $file
62
-done
46
+source @prefix@/.zsh/lib/bindings.zsh
47
+source @prefix@/.zsh/lib/aliases.zsh
48
+source @prefix@/.zsh/lib/hosts.zsh
49
+source @prefix@/.zsh/lib/completion.zsh
50
+source @prefix@/.zsh/lib/directories.zsh
51
+source @prefix@/.zsh/lib/history.zsh
52
+source @prefix@/.zsh/lib/prompt.zsh

+ 12
- 14
func/c View File

@@ -1,22 +1,20 @@
1
-#!/usr/local/bin/zsh
1
+#!zsh
2 2
 
3
-####
4
-#
5
-# Help print out columns
6
-#
7
-####
3
+################################################################################
4
+# Given input on STDIN, print only column number $1.
8 5
 
6
+################################################################################
9 7
 if [ "$#" -eq 1 ]; then
10
-    awk "{print \$$1}"
8
+  cut -f $1
11 9
 else
12
-    read -A cols
13
-    read -t -k 1 && cat > /dev/null
10
+  read -A cols
11
+  read -t -k 1 && cat > /dev/null
14 12
 
15
-    echo 1 | \
13
+  echo 1 | \
16 14
     (
17
-	 PROMPT3=""
18
-	 select i in $cols; do
19
-	     break
20
-	 done
15
+      PROMPT3=""
16
+      select i in $cols; do
17
+        break
18
+      done
21 19
     )
22 20
 fi

+ 2
- 3
func/d View File

@@ -1,8 +1,7 @@
1 1
 #!zsh
2 2
 
3
-#
4
-# change to a directory in the directory stack
5
-#
3
+################################################################################
4
+# Change to a directory in the directory stack
6 5
 
7 6
 typeset -a dlist
8 7
 dlist=(`dirs`)

+ 2
- 2
func/get View File

@@ -1,10 +1,10 @@
1
-#!/usr/local/bin/zsh
1
+#!zsh
2 2
 
3 3
 if which wget > /dev/null; then
4 4
     wget $1
5 5
 
6 6
 elif which curl > /dev/null; then
7
-    curl -o `basename $1` $1
7
+    curl -Lo `basename $1` $1
8 8
 
9 9
 elif which fetch > /dev/null; then
10 10
     fetch $1

+ 6
- 0
func/gpg-which View File

@@ -0,0 +1,6 @@
1
+#!zsh
2
+
3
+################################################################################
4
+# Given a file name, print which key encrypted that file.
5
+key=`gpg2 --batch --decrypt --list-only --status-fd 1 $1 2> /dev/null | awk '/ENC_TO/ {print $3}'`
6
+gpg2 --list-keys $key

+ 0
- 17
func/loop View File

@@ -1,17 +0,0 @@
1
-#!/usr/bin/env zsh
2
-
3
-sleep_for=30
4
-[ $# -eq 1 ] && sleep_for=$1
5
-
6
-hist_number=1
7
-while :; do
8
-    [ $hist_number -eq 10 ] && return
9
-    the_command=`fc -l -$hist_number -$hist_number|sed 's/ *[0-9]* *//'`
10
-    [[ $the_command != loop* ]] && break
11
-    let "hist_number++"
12
-done
13
-
14
-while :; do
15
-    eval $the_command
16
-    sleep $sleep_for
17
-done

+ 7
- 5
func/mkpatches View File

@@ -1,9 +1,11 @@
1
-#!/usr/local/bin/zsh
1
+#!zsh
2 2
 
3
+################################################################################
4
+# Generate a patch set from files that end in .orig.
3 5
 for orig in `find . -name '*.orig'`; do
4
-    name=`echo $orig | sed 's/\.orig$//g'`
5
-    patch="$name.patch"
6
+  name=`echo $orig | sed 's/\.orig$//g'`
7
+  patch="$name.patch"
6 8
 
7
-    echo "$orig $name ==> $patch"
8
-    diff -u $orig $name > $patch
9
+  echo "$orig $name ==> $patch"
10
+  diff -u $orig $name > $patch
9 11
 done

+ 0
- 33
func/send-key View File

@@ -1,33 +0,0 @@
1
-#!zsh
2
-
3
-#
4
-# send your SSH public key to another host
5
-#
6
-if [ $# -lt 1 ]; then
7
-    echo "Usage: $0 <host> [ssh-options]"
8
-    return 1
9
-fi
10
-
11
-to_host=$1
12
-shift
13
-
14
-tmp=newkey
15
-agent_key=$(ssh-add -L|awk '{print $3}'|head -1)
16
-
17
-if [ -r "$agent_key".pub ]; then
18
-  src="$agent_key".pub
19
-elif [ -r ~/.ssh/id_dsa.pub ]; then
20
-  src=~/.ssh/id_dsa.pub
21
-elif [ -r ~/.ssh/id_rsa.pub ]; then
22
-  src=~/.ssh/id_rsa.pub
23
-else
24
-  echo "ERROR: no public key found"
25
-  return 1
26
-fi
27
-
28
-cat $src | ssh $@ $to_host "
29
-    mkdir -p ~/.ssh;
30
-    chmod 700 ~/.ssh;
31
-    cat >> ~/.ssh/authorized_keys;
32
-    chmod 600 ~/.ssh/authorized_keys;
33
-"

+ 0
- 24
func/st View File

@@ -1,24 +0,0 @@
1
-#!/usr/bin/env zsh
2
-
3
-typeset -axU st
4
-
5
-OLD_IFS=$IFS
6
-IFS="
7
-"
8
-
9
-if [ -d .svn ]; then
10
-    # Subversion Status
11
-    st=(`svn status --ignore-externals | egrep -v '^X'`)
12
-    index=1
13
-
14
-    while [ $index -le $#st ]; do
15
-        printf "%2d %s\n" $index "$st[$index]"
16
-        st[$index]=`echo $st[$index] | sed 's/^[^[:space:]]*[[:space:]]*//'`
17
-        let "++index"
18
-    done
19
-else
20
-    # Git Status
21
-    git status
22
-fi
23
-
24
-IFS=$OLD_IFS

+ 2
- 2
func/untar View File

@@ -1,4 +1,4 @@
1
-#!/usr/local/bin/zsh
1
+#!zsh
2 2
 
3 3
 if [[ $1 == *.gz || $1 == *.tgz ]]; then
4 4
     gunzip -c $1 | tar xvf -
@@ -13,7 +13,7 @@ elif [[ $1 == *.zip ]]; then
13 13
     unzip $1
14 14
 
15 15
 elif [[ $1 == *.tar ]]; then
16
-    cat $1 | tar xvf -
16
+    tar xvf $1
17 17
 
18 18
 else
19 19
     echo "Unknow file type: $1"

+ 4
- 7
lib/aliases.zsh View File

@@ -1,3 +1,5 @@
1
+#!zsh
2
+
1 3
 # stuff for every os
2 4
 alias vared="IFS=\$'\n' vared"
3 5
 alias bc='bc -q'
@@ -50,12 +52,7 @@ if [[ $OSNAME == "Darwin" ]]; then
50 52
     alias ldd='otool -L'
51 53
 fi
52 54
 
53
-# More complicated aliases that need to be functions.
54
-dl () {dict "$@" | less}
55
-
56 55
 # Just to shorten typing
57
-alias tclock="tty-clock -c -C 4 -f '%b. %d, %Y'"
58
-alias scclock='env TZ=America/New_York tty-clock -C 0 -c -f "South Carolina"'
59
-alias iss_payload='chromium --app=http://www.ustream.tv/channel/iss-hdev-payload/pop-out'
60
-alias rtm='chromium --app=https://www.rememberthemilk.com'
61 56
 alias mrs='mr -d ~ status'
57
+alias gpg=gpg2
58
+alias virsh-vnc='vnc localhost $(expr 5900 + $(virsh vncdisplay $1|head -1|sed "s/^.*://"))'

+ 2
- 0
lib/bindings.zsh View File

@@ -1,3 +1,5 @@
1
+#!zsh
2
+
1 3
 # fix ^w
2 4
 export WORDCHARS="*?_-.[]~={}<>"
3 5
 autoload backward-kill-word-match select-word-style match-words-by-style

+ 2
- 0
lib/completion.zsh View File

@@ -1,3 +1,5 @@
1
+#!zsh
2
+
1 3
 zstyle ':completion:*' group-name ''
2 4
 zstyle ':completion:*' list-colors ''
3 5
 zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s

+ 2
- 0
lib/directories.zsh View File

@@ -1,3 +1,5 @@
1
+#!zsh
2
+
1 3
 # Directory stuff
2 4
 DIRSTACKSIZE=16
3 5
 setopt auto_pushd

+ 2
- 0
lib/editor.zsh View File

@@ -1,3 +1,5 @@
1
+#!zsh
2
+
1 3
 # Set our EDITOR
2 4
 if [ -x ~/bin/e ] && which emacsclient > /dev/null 2>&1; then
3 5
   export EDITOR="e --wait"

+ 2
- 0
lib/history.zsh View File

@@ -1,3 +1,5 @@
1
+#!zsh
2
+
1 3
 # History stuff
2 4
 HISTSIZE=100
3 5
 SAVEHIST=100

+ 2
- 0
lib/hosts.zsh View File

@@ -1,3 +1,5 @@
1
+#!zsh
2
+
1 3
 # Keep unique
2 4
 typeset -U ssh_hosts
3 5
 

+ 2
- 0
lib/prompt.zsh View File

@@ -1,3 +1,5 @@
1
+#!zsh
2
+
1 3
 # Prompt magic
2 4
 autoload -U colors; colors
3 5
 

+ 0
- 2
local/beefy.local View File

@@ -1,2 +0,0 @@
1
-#!/usr/bin/env zsh
2
-# My desktop (Mac Pro)

+ 0
- 2
local/skinny.local View File

@@ -1,2 +0,0 @@
1
-#!/usr/bin/env zsh
2
-# My laptop (MacBook Pro)

+ 1
- 1
os/darwin View File

@@ -1,4 +1,4 @@
1
-#!/usr/bin/env zsh
1
+#!zsh
2 2
 
3 3
 # Correct path for Mac OS X
4 4
 path=(~/bin /usr/texbin /usr/local/bin $path)

+ 1
- 1
os/linux View File

@@ -1,4 +1,4 @@
1
-#!/usr/bin/env zsh
1
+#!zsh
2 2
 
3 3
 ################################################################################
4 4
 # If it looks like I'm using a custom nixpkgs, then set up NIX_PATH:

+ 1
- 1
os/sunos View File

@@ -1,2 +1,2 @@
1
-#!/usr/bin/env zsh
1
+#!zsh
2 2
 path=(/sbin /usr/sbin /var/ruby/1.8/gem_home/bin $path)

+ 0
- 19
util/git-sb-info.zsh View File

@@ -1,19 +0,0 @@
1
-# This script is called by git_sb_info in rc/zsh/app/git.zsh
2
-
3
-source ~/.zsh/app/git.zsh
4
-top=$(cd ..; git rev-parse --show-toplevel)
5
-ref=$(git_current_branch)
6
-name=$(pwd | sed "s|$top/||")
7
-state=clean
8
-
9
-if [[ ${#ref} -eq 0 ]]; then
10
-  ref="(no branch)"
11
-fi
12
-
13
-if git_repo_has_changes; then
14
-  state=dirty
15
-elif git_repo_needs_push; then
16
-  state=push
17
-fi
18
-
19
-printf '%15s  %5s  %s\n' $ref $state $name

+ 1
- 1
wids/last-cmd-as-expansion View File

@@ -1,4 +1,4 @@
1
-#!/usr/bin/env zsh
1
+#!zsh
2 2
 
3 3
 last_command='$('`fc -l -1|sed 's/ *[0-9]* *//'`')'
4 4
 

Loading…
Cancel
Save