Bläddra i källkod

Massive spring cleaning

master
Peter J. Jones 2 år sedan
förälder
incheckning
21853d58da
Signerad av: Peter Jones <pjones@devalot.com> GPG-nyckel ID: 9DAFAA8D01941E49
43 ändrade filer med 119 tillägg och 728 borttagningar
  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 Visa fil

@@ -1,32 +1,24 @@
################################################################################
include ../mk/init.mk
include ../mk/files.mk
PREFIX ?= $(HOME)

################################################################################
DEST = $(HOME)/.zsh
HOST = $(shell hostname)
OS = $(shell uname -s | tr '[:upper:]' '[:lower:]')
LIBS = $(shell find func lib os wids -type f)
DOTS = $(shell find dot -type f)

################################################################################
FILES = $(wildcard lib/*.zsh)
FILES += $(wildcard app/*.zsh)
FILES += $(wildcard util/*.zsh)
FILES += $(wildcard func/*)
FILES += $(wildcard wids/*.zsh)
.PHONEY: install

################################################################################
$(foreach f,$(FILES),$(eval $(call PMADE_INSTALL_FILE,$(f),$(DEST)/$(f))))
$(eval $(call PMADE_INSTALL_DOT,dot/zshrc))
$(eval $(call PMADE_INSTALL_DOT,dot/zshenv))
# $1: Source file.
# $2: Destination name.
define INSTALL_FILE
install: $(PREFIX)/$(2)
$(PREFIX)/$(2): $(1)
@ echo "==> $$@"
@ mkdir -p `dirname $$@`
@ sed "s|@prefix@|$(PREFIX)|g" < $$< > $$@
endef

################################################################################
# Local (hostname based) Override
ifneq ($(wildcard local/$(HOSTNAME)),)
$(eval $(call PMADE_INSTALL_FILE,local/$(HOSTNAME),$(DEST)/local))
endif

################################################################################
# OS (os name based) Override
ifneq ($(wildcard os/$(OS)),)
$(eval $(call PMADE_INSTALL_FILE,os/$(OS),$(DEST)/os))
endif
$(foreach f,$(LIBS),$(eval $(call INSTALL_FILE,$(f),.zsh/$(f))))
$(foreach f,$(DOTS),$(eval $(call INSTALL_FILE,$(f),.$(notdir $(f)))))

+ 26
- 0
LICENSE Visa fil

@@ -0,0 +1,26 @@
Copyright (c) 2002-2017, Peter J. Jones <pjones@devalot.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the
distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 10
- 0
README.md Visa fil

@@ -0,0 +1,10 @@
# zshrc: Configuration for ZSH

Peter's `zsh` configuration files.

## Installing These Files

By default, running `make` will install everything under $HOME. To
change that, set the `PREFIX` variable:

$ make PREFIX=/some/path install

+ 0
- 40
app/cltc.zsh Visa fil

@@ -1,40 +0,0 @@
if [ `hostname` = "cltc" ]; then

##############################################################################
function _cltc-app {
name=$1
dir=$HOME/scors/$name

if [ -n "$shellHook" ]; then
echo "ERROR: you're already inside nix-shell"
exit 1
fi

if [ ! -d $dir ]; then
( cd `dirname $dir`
git clone --recursive git@github.ors.sc.gov:ors/${name}.git
)
fi

( export DEV_ENV=$name
cd $dir
nix-shell --command zsh ~/.nixpkgs/envs/scors/${name}.nix
)
}

##############################################################################
function cltc-phoenix {
_cltc-app cltc-phoenix
}

##############################################################################
function cltc-claims {
_cltc-app cltc-claims
}

##############################################################################
function cltc-flock {
_cltc-app cltc-flock
}

fi

+ 0
- 10
app/dict.zsh Visa fil

@@ -1,10 +0,0 @@
################################################################################
dict_it () {
dict --database ita-eng "$@"
}

################################################################################
dict_sounds_like () {
dict --match --strategy soundex "$@"
dict --match --strategy lev "$@"
}

+ 0
- 142
app/git.zsh Visa fil

@@ -1,142 +0,0 @@
################################################################################
# Git Log
glog ()
{
git log --pretty=format:'%Cgreen%h%Creset %Cred%ci%Creset %Cblue%ae%Creset %s' --graph $@
}

################################################################################
# Resolve conflicts by keeping the local changes and throwing away the
# remote changes
git_resolve_with_local ()
{
if [ $# -eq 0 ]; then
FILES=`git ls-files -u | awk '{if ($3==1) print $4;}'`
test -z "$FILES" && exit
else
FILES=$*
fi

PREFIX=`git rev-parse --show-prefix`

# need the echo below because the files are someone all glued
# together in a single string
for f in `echo $FILES`; do
echo "--> Tossing remote changes for $f"
git cat-file blob ":2:${PREFIX}${f}" >| "$f" 2> /dev/null
touch "$f"
git add -- "$f"
done

echo "now run git commit"
}

################################################################################
# Find out if a repo has uncommitted changes
git_repo_has_changes ()
{
if ! git status|grep -q -F 'working directory clean'; then
return 0
else
return 1
fi
}

################################################################################
# Find out if a repo has changes that haven't been pushed
git_repo_needs_push ()
{
if git status|head -2|grep -q 'ahead of'; then
return 0
else
return 1
fi
}

################################################################################
# Returns the name of the current git branch if we're in a git repo
git_current_branch ()
{
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo ${ref#refs/heads/}
}

################################################################################
# Create a new branch, and push it to the origin server
git_mk_branch ()
{
if [ $# -eq 0 ]; then
echo "Usage: $0 branch [remote]"
return 1
fi

branch=$1
remote=${2:-origin}

git checkout -b $branch || return 1
git config --add branch.${branch}.remote $remote || return 1
git push $remote $branch || return 1
}

################################################################################
# Delete a branch: FIXME: remove from all remotes
git_rm_branch ()
{
if [ $# -eq 0 ]; then
echo "Usage: $0 branch"
return 1
fi

branch=$1
git branch -d $branch || return 1

if git branch -a | grep -q origin/$branch; then
git push origin :heads/$branch
fi
}

################################################################################
# Pull master, and return to the current branch
git_master_pull ()
{
remote=origin
test $# -eq 1 && remote=$1

branch=`git_current_branch`
echo "==> Leaving branch ${branch}"
git checkout master || return 1
git pull $remote || return 1
git checkout $branch || return 1
}

################################################################################
# List info about each sub-module
function git-sb-info ()
{
git submodule --quiet foreach 'zsh ~/.zsh/util/git-sb-info.zsh'
}

################################################################################
# Create a new remote repo
git_new_repo ()
{
remote_path=$1
remote_name=origin
remote_host=dracula.pmade.com

test $# -gt 1 && remote_name=$2
test $# -gt 2 && remote_host=$3

ssh $remote_host "mkdir -p $remote_path && cd $remote_path && git init --bare"
git remote add $remote_name ${remote_host}:$remote_path
git config --add branch.master.remote $remote_name
git config --add branch.master.merge refs/heads/master
git push $remote_name master
}

################################################################################
# Find out about the current repo.
function git-what ()
{
git describe --long --tags --dirty --always
}

+ 0
- 17
app/gpg.zsh Visa fil

@@ -1,17 +0,0 @@
################################################################################
alias gpg=gpg2

################################################################################
# Outputs which key was used to encrypt a file.
gpg_which () {
file=$1
key=$(_gpg_which_key $file)
gpg2 --list-keys $key
}

################################################################################
# Helper function.
_gpg_which_key () {
gpg2 --batch --decrypt --list-only --status-fd 1 $1 2> /dev/null |\
awk '/ENC_TO/ {print $3}'
}

+ 0
- 12
app/mysql.zsh Visa fil

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

+ 0
- 50
app/nix.zsh Visa fil

@@ -1,50 +0,0 @@
################################################################################
# Functions for making Nix and NixOS a bit easier.
if [ -d /etc/nix ]; then

##############################################################################
function _nix-inside-shell () {
if [[ -n $NIX_BUILD_TOP ]]; then
return 0
else
return 1
fi
}

##############################################################################
# Run a Nix command with the correct options and environment for a
# local copy of nixpkgs.
function _nix-with-nixpkgs () {
command=$1
shift

typeset -a options
options=()

# Automatically add a binary cache when on my home network:
if iwgetid | cut -d: -f2 | grep -q "515"; then
options=($options --option extra-binary-caches http://10.0.1.10:8080)
fi

export NIX_PATH=nixpkgs=$HOME/develop/oss/nixpkgs:$NIX_PATH
$command $options "$@"
}

##############################################################################
# Nix shell with a local clone of nixpkgs.
function nixpkgs-shell () {
_nix-with-nixpkgs nix-shell --command $(which zsh) "$@"
}

##############################################################################
# Nix build with a local clone of nixpkgs.
function nixpkgs-build () {
_nix-with-nixpkgs nix-build "$@"
}

################################################################################
else

##############################################################################
function _nix-inside-shell () {return 1}
fi

+ 0
- 12
app/ruby.zsh Visa fil

@@ -1,12 +0,0 @@
################################################################################
# If the rbenv tool is installed, use it.
if [ -d ~/.rbenv/bin ]; then
path=(~/.rbenv/bin $path)
eval "$(rbenv init -)"
fi

################################################################################
alias irb='irb --readline -r irb/completion'

################################################################################
rtags () { command rtags --quiet $(find . -type f -name '*.rb')}

+ 0
- 7
app/script.zsh Visa fil

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

+ 0
- 1
app/ssh.zsh Visa fil

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

+ 0
- 83
app/tmux.zsh Visa fil

@@ -1,83 +0,0 @@
################################################################################
# Mount a virtual machine via SSHFS and then create a tmux session
# inside it.
tmux_mount () {
if [ $# -ne 1 ]; then
echo "Usage: tmux_mount name"
return 1
fi

name=$1
mount_point=$HOME/develop/hosts/$1
mount_options="-oauto_cache,reconnect,ControlMaster=no"
server=${name}.pmade.com

# If the host is a VM and it's not already running, start it.
virsh_is_registered $name && (virsh_running $name || virsh_start $name)

echo "==> Mounting $name on $mount_point"
mkdir -p $mount_point

if ssh $server test -d develop; then
server_dir=develop
elif ssh $server test -d Develop; then
server_dir=Develop
else
server_dir=""
fi

sshfs "${server}:${server_dir}" $mount_point $mount_options || return 1
cp ~/.emacs.d/server/server $mount_point/emacs.server

echo "==> Starting tmux session $name"
(cd $mount_point && tmux new-session -d -s $name)

return $?
}

################################################################################
# Mount and attach to a new session
tmux_mount_attach () {
tmux_mount $1 && tmux attach -t $1
}

################################################################################
# Kill a tmux session and un-mount the sshfs file system.
tmux_umount () {
if [ $# -ne 1 ]; then
echo "Usage: tmux_umount name"
return 1
fi

name=$1
mount_point=$HOME/develop/hosts/$1

if tmux list-sessions | awk '{print $1}' | grep -q ^${name}:\$; then
echo "==> Killing tmux session $name"
tmux kill-session -t $name || return 1
sleep 2 # Wait for all processes accessing the VM to die
fi

# Avoid my 'df' alias below by giving the full path
if /bin/df -P | awk 'NR > 1 {print $6}' | grep -q hosts/$name\$; then
echo "==> Un-mounting $mount_point"
fusermount -u $mount_point || return 1
fi
}

################################################################################
# Runs tmux_umount and then stops the VM
tmux_umount_stop () {
if [ $# -ne 1 ]; then
echo "Usage: tmux_umount_stop name"
return 1
fi

name=$1
tmux_umount $name || return 1

if virsh_running $name; then
echo "==> Stopping $name virtual machine"
virsh_stop $name || return 1
fi
}

+ 0
- 122
app/virsh.zsh Visa fil

@@ -1,122 +0,0 @@
################################################################################
# Returns 0 if a VM is running, otherwise 1.
virsh_running () {
if [ $# -ne 1 ]; then
echo "Usage: virsh_running name"
return 2
fi

name=$1
state=`virsh dominfo $name | grep ^State | awk '{print $2}'`

if [ "$state" = "running" ]; then
return 0
else
return 1
fi
}

################################################################################
# Returns 0 if the given VM is registered with libvirt, otherwise 1.
virsh_is_registered () {
if [ $# -ne 1 ]; then
echo "Usage: virsh_is_registered name"
return 2
fi

name=$1

if virsh dominfo $name > /dev/null 2>&1; then
return 0
else
return 1
fi
}

################################################################################
# Returns 0 if the VM has managed save info, otherwise 1.
virsh_has_managed_save () {
if [ $# -ne 1 ]; then
echo "Usage: virsh_has_managed_save name"
return 2
fi

name=$1
save=`virsh dominfo $name | grep '^Managed save' | awk '{print $3}'`

if [ "$save" = "yes" ]; then
return 0
else
return 1
fi
}

################################################################################
# Returns the current version of libvirt
virsh_version () {
virsh version | head -1 | awk -F: '{print $2}' | awk '{print $2}'
}

################################################################################
# Start a VM and wait for it to be running.
virsh_start () {
if [ $# -ne 1 ]; then
echo "Usage: virsh_start name"
return 1
fi

name=$1
hostname="${name}.pmade.com"

# First check to see if we're already running.
virsh_running $name && return 0

# Record if we have managed state
if virsh_has_managed_save $name; then
with_save=1
else
with_save=0
fi

# Start it and wait for it to be pingable
virsh start $name || return 1
echo "==> Waiting for $name to start..."
[ $with_save -eq 0 ] && sleep 60
ping -c 5 -q -w 120 $hostname
}

################################################################################
# Stop a running VM using managedsave.
virsh_stop () {
if [ $# -ne 1 ]; then
echo "Usage: virsh_stop name"
return 1
fi

name=$1
flags=""

if [ $(virsh_version) != '0.9.8' ]; then
flags="--verbose"
fi

# Can't stop a domain unless it's running
virsh_running $name || return 0

echo "==> Waiting for $name to stop"
virsh managedsave $name $flags
}

################################################################################
# Open a vnc connection to a virtual machine
virsh_vnc () {
if [ $# -ne 1 ]; then
echo "Usage: virsh_vnc name"
return 1
fi

name=$1
port=$(virsh vncdisplay $name|head -1|sed 's/^.*://')
port=$(expr 5900 + $port)
vnc localhost:$port
}

+ 0
- 33
app/vmware.zsh Visa fil

@@ -1,33 +0,0 @@
################################################################################
# Access the vmrun tool.
vmware_vmrun () {
"/Library/Application Support/VMware Fusion/vmrun" $@
}

################################################################################
# Returns the base directory where we mount things.
vmware_base_mount_point () {
echo ~/Develop/hosts
}

################################################################################
# Mount a VMWare virtual machine using sshfs
vmware_mount () {
name=$1

server="sshfs.${name}.pmade.com"
directory=`vmware_base_mount_point`"/$name"
mkdir -p $directory
sshfs "${server}:" $directory -oauto_cache,reconnect,volname=$name
}

################################################################################
# Mount a virtual machine and create a tmux session
vmware_session () {
name=$1
vmware_mount $name || return 1
directory=`vmware_base_mount_point`"/$name"
(cd $directory/develop && tmux new-session -d -s $name)
}

+ 0
- 14
app/wmctrl.zsh Visa fil

@@ -1,14 +0,0 @@
################################################################################
wmctrl_activate_emacs () {
win_id=$(wmctrl -l |awk '$4 ~ /emacs/ && $2 == 0 {print $1}'|head -1)
if [[ -n $win_id ]]; then
wmctrl -ia $win_id
fi
}

################################################################################
# Activates the biggest Conkeror window.
wmctrl_activate_conkeror () {
wmctrl -ia $(wmctrl -lG|grep Conkeror|sort -nk 5|tail -1|awk '{print $1}')
}

+ 0
- 1
app/xcode.zsh Visa fil

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

+ 5
- 7
dot/zshenv Visa fil

@@ -1,4 +1,4 @@
#!/usr/bin/env zsh
#!zsh

# Set default path
typeset -U path
@@ -7,14 +7,12 @@ typeset -U path
path=(~/bin $path)

# Load core environment variables.
source ~/.zsh/lib/editor.zsh
source @prefix@/.zsh/lib/editor.zsh

# Other environment variables:
export VIRSH_DEFAULT_CONNECT_URI="qemu:///system"
export GPG_TTY=`tty`
export GPG_TTY=$(tty)
export OS=$(uname -s | tr '[A-Z]' '[a-z]')

# Load in optional operating system override
[ -r ~/.zsh/os ] && source ~/.zsh/os

# Load in optional local override file
[ -r ~/.zsh/local ] && source ~/.zsh/local
[ -r "@prefix@/.zsh/$OS" ] && source "@prefix@/.zsh/$OS"

+ 10
- 20
dot/zshrc Visa fil

@@ -1,4 +1,4 @@
#!/usr/local/bin/zsh
#!zsh

# keep some arrays unique
typeset -U fpath
@@ -6,13 +6,12 @@ typeset -U cdpath
typeset -U manpath

# some variables to export
export OSNAME=`uname -s`
export LESS="-SRiJMW"
export PAGER=less

# add our function path
functions_directory=~/.zsh/func
widgets_directory=~/.zsh/wids
functions_directory=@prefix@/.zsh/func
widgets_directory=@prefix@/.zsh/wids
fpath=($functions_directory $widgets_directory $fpath)

# clober stuff
@@ -44,19 +43,10 @@ autoload -U ${fpath[1]}/*(:t)
zmodload zsh/datetime

# bring in other files
source ~/.zsh/lib/bindings.zsh
source ~/.zsh/lib/aliases.zsh
source ~/.zsh/lib/hosts.zsh
source ~/.zsh/lib/completion.zsh
source ~/.zsh/lib/directories.zsh
source ~/.zsh/lib/history.zsh
source ~/.zsh/lib/prompt.zsh

# Application files are autoloaded, if I can get it to freaking work:
# http://zsh.sourceforge.net/Doc/Release/Functions.html
# fpath=(~/.zsh/app $fpath)

for file in $(find ~/.zsh/app -type f -name '*.zsh'); do
source $file
#autoload -w $file
done
source @prefix@/.zsh/lib/bindings.zsh
source @prefix@/.zsh/lib/aliases.zsh
source @prefix@/.zsh/lib/hosts.zsh
source @prefix@/.zsh/lib/completion.zsh
source @prefix@/.zsh/lib/directories.zsh
source @prefix@/.zsh/lib/history.zsh
source @prefix@/.zsh/lib/prompt.zsh

+ 12
- 14
func/c Visa fil

@@ -1,22 +1,20 @@
#!/usr/local/bin/zsh
#!zsh

####
#
# Help print out columns
#
####
################################################################################
# Given input on STDIN, print only column number $1.

################################################################################
if [ "$#" -eq 1 ]; then
awk "{print \$$1}"
cut -f $1
else
read -A cols
read -t -k 1 && cat > /dev/null
read -A cols
read -t -k 1 && cat > /dev/null

echo 1 | \
echo 1 | \
(
PROMPT3=""
select i in $cols; do
break
done
PROMPT3=""
select i in $cols; do
break
done
)
fi

+ 2
- 3
func/d Visa fil

@@ -1,8 +1,7 @@
#!zsh

#
# change to a directory in the directory stack
#
################################################################################
# Change to a directory in the directory stack

typeset -a dlist
dlist=(`dirs`)

+ 2
- 2
func/get Visa fil

@@ -1,10 +1,10 @@
#!/usr/local/bin/zsh
#!zsh

if which wget > /dev/null; then
wget $1

elif which curl > /dev/null; then
curl -o `basename $1` $1
curl -Lo `basename $1` $1

elif which fetch > /dev/null; then
fetch $1

+ 6
- 0
func/gpg-which Visa fil

@@ -0,0 +1,6 @@
#!zsh

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

+ 0
- 17
func/loop Visa fil

@@ -1,17 +0,0 @@
#!/usr/bin/env zsh

sleep_for=30
[ $# -eq 1 ] && sleep_for=$1

hist_number=1
while :; do
[ $hist_number -eq 10 ] && return
the_command=`fc -l -$hist_number -$hist_number|sed 's/ *[0-9]* *//'`
[[ $the_command != loop* ]] && break
let "hist_number++"
done

while :; do
eval $the_command
sleep $sleep_for
done

+ 7
- 5
func/mkpatches Visa fil

@@ -1,9 +1,11 @@
#!/usr/local/bin/zsh
#!zsh

################################################################################
# Generate a patch set from files that end in .orig.
for orig in `find . -name '*.orig'`; do
name=`echo $orig | sed 's/\.orig$//g'`
patch="$name.patch"
name=`echo $orig | sed 's/\.orig$//g'`
patch="$name.patch"

echo "$orig $name ==> $patch"
diff -u $orig $name > $patch
echo "$orig $name ==> $patch"
diff -u $orig $name > $patch
done

+ 0
- 33
func/send-key Visa fil

@@ -1,33 +0,0 @@
#!zsh

#
# send your SSH public key to another host
#
if [ $# -lt 1 ]; then
echo "Usage: $0 <host> [ssh-options]"
return 1
fi

to_host=$1
shift

tmp=newkey
agent_key=$(ssh-add -L|awk '{print $3}'|head -1)

if [ -r "$agent_key".pub ]; then
src="$agent_key".pub
elif [ -r ~/.ssh/id_dsa.pub ]; then
src=~/.ssh/id_dsa.pub
elif [ -r ~/.ssh/id_rsa.pub ]; then
src=~/.ssh/id_rsa.pub
else
echo "ERROR: no public key found"
return 1
fi

cat $src | ssh $@ $to_host "
mkdir -p ~/.ssh;
chmod 700 ~/.ssh;
cat >> ~/.ssh/authorized_keys;
chmod 600 ~/.ssh/authorized_keys;
"

+ 0
- 24
func/st Visa fil

@@ -1,24 +0,0 @@
#!/usr/bin/env zsh

typeset -axU st

OLD_IFS=$IFS
IFS="
"

if [ -d .svn ]; then
# Subversion Status
st=(`svn status --ignore-externals | egrep -v '^X'`)
index=1

while [ $index -le $#st ]; do
printf "%2d %s\n" $index "$st[$index]"
st[$index]=`echo $st[$index] | sed 's/^[^[:space:]]*[[:space:]]*//'`
let "++index"
done
else
# Git Status
git status
fi

IFS=$OLD_IFS

+ 2
- 2
func/untar Visa fil

@@ -1,4 +1,4 @@
#!/usr/local/bin/zsh
#!zsh

if [[ $1 == *.gz || $1 == *.tgz ]]; then
gunzip -c $1 | tar xvf -
@@ -13,7 +13,7 @@ elif [[ $1 == *.zip ]]; then
unzip $1

elif [[ $1 == *.tar ]]; then
cat $1 | tar xvf -
tar xvf $1

else
echo "Unknow file type: $1"

+ 4
- 7
lib/aliases.zsh Visa fil

@@ -1,3 +1,5 @@
#!zsh

# stuff for every os
alias vared="IFS=\$'\n' vared"
alias bc='bc -q'
@@ -50,12 +52,7 @@ if [[ $OSNAME == "Darwin" ]]; then
alias ldd='otool -L'
fi

# More complicated aliases that need to be functions.
dl () {dict "$@" | less}

# Just to shorten typing
alias tclock="tty-clock -c -C 4 -f '%b. %d, %Y'"
alias scclock='env TZ=America/New_York tty-clock -C 0 -c -f "South Carolina"'
alias iss_payload='chromium --app=http://www.ustream.tv/channel/iss-hdev-payload/pop-out'
alias rtm='chromium --app=https://www.rememberthemilk.com'
alias mrs='mr -d ~ status'
alias gpg=gpg2
alias virsh-vnc='vnc localhost $(expr 5900 + $(virsh vncdisplay $1|head -1|sed "s/^.*://"))'

+ 2
- 0
lib/bindings.zsh Visa fil

@@ -1,3 +1,5 @@
#!zsh

# fix ^w
export WORDCHARS="*?_-.[]~={}<>"
autoload backward-kill-word-match select-word-style match-words-by-style

+ 2
- 0
lib/completion.zsh Visa fil

@@ -1,3 +1,5 @@
#!zsh

zstyle ':completion:*' group-name ''
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s

+ 2
- 0
lib/directories.zsh Visa fil

@@ -1,3 +1,5 @@
#!zsh

# Directory stuff
DIRSTACKSIZE=16
setopt auto_pushd

+ 2
- 0
lib/editor.zsh Visa fil

@@ -1,3 +1,5 @@
#!zsh

# Set our EDITOR
if [ -x ~/bin/e ] && which emacsclient > /dev/null 2>&1; then
export EDITOR="e --wait"

+ 2
- 0
lib/history.zsh Visa fil

@@ -1,3 +1,5 @@
#!zsh

# History stuff
HISTSIZE=100
SAVEHIST=100

+ 2
- 0
lib/hosts.zsh Visa fil

@@ -1,3 +1,5 @@
#!zsh

# Keep unique
typeset -U ssh_hosts


+ 2
- 0
lib/prompt.zsh Visa fil

@@ -1,3 +1,5 @@
#!zsh

# Prompt magic
autoload -U colors; colors


+ 0
- 2
local/beefy.local Visa fil

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

+ 0
- 2
local/skinny.local Visa fil

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

+ 1
- 1
os/darwin Visa fil

@@ -1,4 +1,4 @@
#!/usr/bin/env zsh
#!zsh

# Correct path for Mac OS X
path=(~/bin /usr/texbin /usr/local/bin $path)

+ 1
- 1
os/linux Visa fil

@@ -1,4 +1,4 @@
#!/usr/bin/env zsh
#!zsh

################################################################################
# If it looks like I'm using a custom nixpkgs, then set up NIX_PATH:

+ 1
- 1
os/sunos Visa fil

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

+ 0
- 19
util/git-sb-info.zsh Visa fil

@@ -1,19 +0,0 @@
# This script is called by git_sb_info in rc/zsh/app/git.zsh

source ~/.zsh/app/git.zsh
top=$(cd ..; git rev-parse --show-toplevel)
ref=$(git_current_branch)
name=$(pwd | sed "s|$top/||")
state=clean

if [[ ${#ref} -eq 0 ]]; then
ref="(no branch)"
fi

if git_repo_has_changes; then
state=dirty
elif git_repo_needs_push; then
state=push
fi

printf '%15s %5s %s\n' $ref $state $name

+ 1
- 1
wids/last-cmd-as-expansion Visa fil

@@ -1,4 +1,4 @@
#!/usr/bin/env zsh
#!zsh

last_command='$('`fc -l -1|sed 's/ *[0-9]* *//'`')'


Laddar…
Avbryt
Spara