diff --git a/.gitignore b/.gitignore index 018078aae3..718290212e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ vim/.netrwhist vim/bundle vim/doc/tags-ja +zsh/credentials +.bitbucket +oh-my-zsh diff --git a/Brewfile b/Brewfile new file mode 100644 index 0000000000..ab036c458e --- /dev/null +++ b/Brewfile @@ -0,0 +1,71 @@ +# Casks — GUI apps +cask "alfred" +cask "backblaze" +cask "charles" +cask "chatgpt" +cask "claude" +cask "codex" +cask "copilot-cli" +cask "cursor" +cask "docker-desktop" +cask "fantastical" +cask "figma" +cask "flux-app" +cask "google-chrome" +cask "intellij-idea-ce" +cask "iterm2" +cask "licecap" +cask "ngrok" +cask "obsidian" +cask "proxyman" +cask "rectangle" +cask "spotify" +cask "visual-studio-code" +cask "wispr-flow" + +# Brews — CLI tools +brew "awscli" +brew "ffmpeg" +brew "flyway" +brew "gh" +brew "gifsicle" +brew "git" +brew "git-extras" +brew "git-lfs" +brew "gradle" +brew "grep" +brew "httpie" +brew "jd" +brew "jq" +brew "just" +brew "k6" +brew "mas" +brew "nodenv" +brew "ollama" +brew "openjdk@11" +brew "openssh" +brew "pipx" +brew "postgresql@17" +brew "redis" +brew "ripgrep" +brew "terminal-notifier" +brew "the_silver_searcher" +brew "tmux" +brew "tmuxinator" +brew "uv" +brew "vim" +brew "websocat" +brew "wget" +brew "yarn" +brew "zsh" +brew "ngrok" + +# Mac App Store +mas "1Password", id: 1333542190 +mas "WhatsApp", id: 310633997 +mas "Things 3", id: 904280696 +mas "Bear", id: 1091189122 +mas "Harvest", id: 506189836 +mas "Slack", id: 803453959 +mas "Spark", id: 6445813049 +mas "Keynote", id: 409183694 diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000000..201e49f7fe --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,42 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Repository purpose + +Personal macOS dotfiles. Originally forked from Ben Orenstein's (r00k) dotfiles. Contains shell, editor, git, and tmux configuration plus a Brewfile and a tiny macOS setup script. + +## Layout & install model + +This repo lives at `~/code/dotfiles`. `~/.dotfiles` is a symlink to it, and individual dotfiles in `$HOME` (e.g. `~/.zshrc`, `~/.vimrc`, `~/.gitconfig`, `~/.tmux.conf`, `~/.bin`, `~/.oh-my-zsh`) are symlinks back into this repo. Both paths therefore show identical contents. + +`rake install` (see `Rakefile`) is the installer: it iterates every top-level entry and creates `~/.` → `$PWD/` symlinks, prompting before overwriting. There is no uninstall task — clean up by removing the symlinks manually. + +Consequence for edits: changing a file here changes the live config immediately. Re-run `source ~/.zshrc` (`so` alias) after editing zsh files. Run `` ` `` + `r` inside tmux to reload `tmux.conf`. + +## Key files + +- `zshrc` — entry point. Sources `zsh/aliases` and `zsh/functions`. Uses oh-my-zsh with theme `awesomepanda` and plugins `git docker aws`. +- `zsh/aliases`, `zsh/functions` — heavy use of short git aliases (`g`, `gs`, `gp`, `gpcb`, `grom`, …). Prefer extending these over adding new shell scripts. +- `zsh/func/` — autoloaded zsh functions (prompt themes, `awsso`, `zgitinit`). +- `vimrc` + `vim/` — Vim config; plugins managed by **Vundle** (not vim-plug). After editing the plugin list, run `:PluginInstall` in vim. Vundle itself is not vendored — bootstrap with `git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim`. +- oh-my-zsh — not tracked in this repo. Installed separately into `~/.oh-my-zsh` via upstream's installer (see README). Listed in `SKIP` in the Rakefile and in `.gitignore`. Put customizations in `zsh/` (which is tracked) rather than in `~/.oh-my-zsh/custom/` (which is not). +- `gitconfig` — signs commits via SSH key (`gpg.format = ssh`, `commit.gpgsign = true`); `pull.ff = only`; rich `git l`/`git r`/`git hp` aliases backed by `githelpers`. +- `Brewfile` — `brew bundle --file=Brewfile` to install. +- `bin/` — small one-off scripts, exposed on `$PATH` via the `~/.bin` symlink. +- `claude/` — Claude Code config. Handled specially by the Rakefile: NOT symlinked as `~/.claude` (that would clobber the live cache). Instead, individual entries listed in `CLAUDE_LINKS` in the Rakefile are symlinked into `~/.claude/` (e.g. `claude/settings.json` → `~/.claude/settings.json`, `claude/commands/build-cli.md` → `~/.claude/commands/build-cli.md`). Run `rake claude` to (re)apply just these links, or `rake install` to do everything. Add new tracked entries by appending to `CLAUDE_LINKS`. + +## Common commands + +- Install/refresh symlinks: `rake install` (from repo root). +- Install Homebrew packages: `brew bundle --file=Brewfile`. +- Reload shell: `so` (alias for `source ~/.zshrc`). +- Jump to repo: `dot` (alias for `cd ~/.dotfiles`). +- Edit aliases quickly: `aliases` (opens `zsh/aliases` in vim). + +There is no test suite, linter, or CI — this is config, not code. + +## Conventions when editing + +- Adding shell aliases or functions: put them in `zsh/aliases` or `zsh/functions`. Don't create new top-level files unless they need to land in `$HOME` as a dotfile (the Rakefile will symlink every top-level entry). +- The `master` branch is the only branch; commit directly. Commits are SSH-signed automatically via `gitconfig`. diff --git a/README.md b/README.md index 65207fa124..1c8b1ed48f 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,42 @@ -# Ben Orenstein's dot files +# Dotfiles -These are config files to set up a system the way I like it. +Personal macOS dotfiles (Apple Silicon). Shell, vim, git, tmux, and a `Brewfile`. -Vim-users will likely find useful stuff in my [vimrc](vimrc), and also my [Ruby snippets](vim/snippets/ruby.snippets). +## Install on a fresh Mac -I'm also a pretty aggressive aliaser. You might find a few you like in [zsh/aliases](zsh/aliases). +1. Install Xcode Command Line Tools (`xcode-select --install`) and restore SSH keys to `~/.ssh`. +2. Clone the repo and create the `~/.dotfiles` symlink the rest of the config expects: + ```sh + mkdir -p ~/code + git clone git@github.com:/dotfiles.git ~/code/dotfiles + ln -s ~/code/dotfiles ~/.dotfiles + ``` +3. Symlink every dotfile into `$HOME`: + ```sh + cd ~/.dotfiles && rake install + ``` +4. Install Homebrew, then the bundle: + ```sh + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + brew bundle --file=~/.dotfiles/Brewfile + ``` + Sign in to the App Store first if `mas` entries fail, then re-run `brew bundle`. +5. Install oh-my-zsh (the repo doesn't vendor it; `zshrc` expects it at `~/.oh-my-zsh`): + ```sh + sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended --keep-zshrc + ``` + `--keep-zshrc` is critical — without it the installer overwrites the `~/.zshrc` symlink created in step 3. +6. Vim plugins (Vundle): + ```sh + git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim + vim +PluginInstall +qall + ``` +7. Install Claude Code via Anthropic's official installer (not Homebrew): + ```sh + curl -fsSL https://claude.ai/install.sh | bash + ``` -## Installation +## Notes - git clone git://github.com/r00k/dotfiles ~/.dotfiles - cd ~/.dotfiles - rake install - - Vim plugins are managed through vundle. You'll need to install vundle to get them. - - git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim - Run :BundleInstall in vim. +- Single branch (`master`), commits are SSH-signed (see `gitconfig`). +- Editing files in this repo updates the live config immediately — they're symlinked into `$HOME`. Run `so` (alias for `source ~/.zshrc`) after editing zsh files. diff --git a/Rakefile b/Rakefile index c5488c0df4..77dc3bd04c 100644 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,23 @@ require 'rake' +# Files/dirs that should NOT be symlinked as ~/.. +# `claude/` is handled specially below — we symlink individual entries +# into ~/.claude/ instead of clobbering the whole live directory. +SKIP = %w[Rakefile README.md README.rdoc LICENSE CLAUDE.md id_dsa.pub claude oh-my-zsh .git .gitignore .DS_Store].freeze + +# Paths inside the repo's claude/ dir that get linked into ~/.claude/. +# Add new entries here as you decide to track more Claude config. +CLAUDE_LINKS = %w[ + settings.json + commands/build-cli.md +].freeze + desc "install the dot files into user's home directory" task :install do replace_all = false Dir['*'].each do |file| - next if %w[Rakefile README.rdoc LICENSE id_dsa.pub].include? file - + next if SKIP.include? file + if File.exist?(File.join(ENV['HOME'], ".#{file}")) if replace_all replace_file(file) @@ -28,16 +40,65 @@ task :install do end end - # Handle ssh pubkey on its own - puts "Linking public ssh key" - system %Q{rm "$HOME/.ssh/id_dsa.pub"} - system %Q{ln -s "$PWD/id_dsa.pub" "$HOME/.ssh/id_dsa.pub"} + install_claude + configure_iterm +end + +desc "symlink tracked claude/ entries into ~/.claude/" +task :claude do + install_claude +end + +desc "force iTerm2 to Dark theme (ignoring system appearance)" +task :iterm do + configure_iterm +end + +def install_claude + CLAUDE_LINKS.each do |rel| + src = File.join(Dir.pwd, 'claude', rel) + dest = File.join(ENV['HOME'], '.claude', rel) + + unless File.exist?(src) + puts "claude: missing source #{src}, skipping" + next + end + + FileUtils.mkdir_p(File.dirname(dest)) + + if File.symlink?(dest) && File.readlink(dest) == src + puts "claude: ~/.claude/#{rel} already linked" + next + end - # Need to do this to make vim use RVM's ruby version - puts "Moving zshenv to zshrc" - system %Q{sudo mv /etc/zshenv /etc/zshrc} + if File.exist?(dest) || File.symlink?(dest) + print "overwrite ~/.claude/#{rel}? [yn] " + case $stdin.gets.chomp + when 'y' + File.delete(dest) + else + puts "skipping ~/.claude/#{rel}" + next + end + end - system %Q{mkdir ~/.tmp} + puts "linking ~/.claude/#{rel}" + File.symlink(src, dest) + end +end + +# iTerm2 Preferences > Appearance > Theme. TabStyleWithAutomaticOption values: +# 0=Light 1=Dark 2=Light High Contrast 3=Dark High Contrast 4=Automatic 5=Minimal 6=Compact +ITERM_DARK = 1 + +def configure_iterm + current = `defaults read com.googlecode.iterm2 TabStyleWithAutomaticOption 2>/dev/null`.strip + if current == ITERM_DARK.to_s + puts "iterm: theme already Dark" + return + end + puts "iterm: setting theme to Dark (was #{current.empty? ? 'unset' : current})" + system "defaults write com.googlecode.iterm2 TabStyleWithAutomaticOption -int #{ITERM_DARK}" end def replace_file(file) diff --git a/ackrc b/ackrc deleted file mode 100644 index 8e3ea8e174..0000000000 --- a/ackrc +++ /dev/null @@ -1,7 +0,0 @@ ---type-add -ruby=.haml,.feature,.scss,.coffee ---ignore-dir=vendor ---ignore-dir=log ---ignore-dir=tmp ---ignore-dir=doc ---ignore-dir=coverage diff --git a/agignore b/agignore deleted file mode 100644 index aa4a93031b..0000000000 --- a/agignore +++ /dev/null @@ -1,7 +0,0 @@ -log -vendor -tmp -doc -coverage -public/assets -*.sql diff --git a/bin/create_docker_machine_swarm b/bin/create_docker_machine_swarm new file mode 100755 index 0000000000..c3dd4e931d --- /dev/null +++ b/bin/create_docker_machine_swarm @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + + +POSITIONAL=() +while [[ $# -gt 0 ]]; do + key="$1" + + case $key in + -s|--skip-create) + SKIP_CREATE="YES" + shift + shift + ;; + *) + POSITIONAL+=("$1") + shift + ;; + esac +done +set -- "${POSITIONAL[@]}" + +machine_name=$1 +last_ip_digit=$2 + +if [ "$#" -ne 2 ]; then + echo "You must pass a and in the command:" + echo "Example:" + echo " create_docker_machine_swarm my-swarm-cluster 60" + exit 1 +fi + +GREEN='\033[0;32m' +NC='\033[0m' + +function tell { + echo -e "${GREEN}${1}${NC}" +} + +docker_host_ip="192.168.99.$last_ip_digit" + +tell "Creating machine with the name '$machine_name' and the ip '$docker_host_ip'" + +if [ "$SKIP_CREATE" != "YES" ]; then + tell "=== Creating docker machine" + docker-machine create nf-cluster \ + --driver virtualbox \ + --engine-insecure-registry 192.168.99:5000 \ + --tls-san "$machine_name.dev, IP:$docker_host_ip, IP Address:$docker_host_ip" +fi + +# tell "=== Configuring docker machine with IP" +# echo "ifconfig eth1 $docker_host_ip netmask 255.255.255.0 broadcast 192.168.99.255 up" | \ +# docker-machine ssh $machine_name sudo tee /var/lib/boot2docker/bootsync.sh > /dev/null + +# tell "=== Restarting machine" +# docker-machine restart $machine_name +# +# tell "=== Regenerating certificates" +# docker-machine regenerate-certs $machine_name -f + +tell "=== Configuring docker machine as cluster" +eval $(docker-machine env $machine_name) +docker swarm init --advertise-addr $docker_host_ip + +tell "=== Creating docker registry" +docker service create --name registry --publish 5000:5000 registry diff --git a/bin/gem_from_path b/bin/gem_from_path new file mode 100644 index 0000000000..bcbb85435d --- /dev/null +++ b/bin/gem_from_path @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +function gfp { + gem_name="$1" + echo $gem_name + + # Replace gem 'gem_name' with gem 'gem_name', path: '../gem_name' + perl -p -i -e "s/gem ('|\")${gem_name}('|\")\$/gem '${gem_name}', path: '..\/${gem_name}'/gi" Gemfile + + # Clear asset cache (for rails apps) + rm -rf tmp/cache/assets + + # Bundle + bundle + + # Restart server + powder -r +} diff --git a/bin/tmuxinator.zsh b/bin/tmuxinator.zsh new file mode 100644 index 0000000000..4c76c94a8c --- /dev/null +++ b/bin/tmuxinator.zsh @@ -0,0 +1,30 @@ +#compdef tmuxinator mux + +_tmuxinator() { + local commands projects + commands=(${(f)"$(tmuxinator commands zsh)"}) + projects=(${(f)"$(tmuxinator completions start)"}) + + if (( CURRENT == 2 )); then + _describe -t commands "tmuxinator subcommands" commands + _describe -t projects "tmuxinator projects" projects + elif (( CURRENT == 3)); then + case $words[2] in + copy|debug|delete|open|start) + _arguments '*:projects:($projects)' + ;; + esac + fi + + return +} + +_tmuxinator + +# Local Variables: +# mode: Shell-Script +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: +# vim: ft=zsh sw=2 ts=2 et diff --git a/bin/validate_ie9_css b/bin/validate_ie9_css new file mode 100644 index 0000000000..f94cc23584 --- /dev/null +++ b/bin/validate_ie9_css @@ -0,0 +1,55 @@ +#!/usr/bin/env ruby + +begin + require 'active_support/core_ext' +rescue LoadError + puts 'Could not find rails. Installing rails...' + %x(gem install rails --no-rdoc --no-ri) + require 'active_support/core_ext' +end + +begin + require 'css_splitter/splitter' +rescue LoadError + puts "Could not find css_splitter. Installing css_splitter..." + %x(gem install css_splitter --no-rdoc --no-ri) + require 'css_splitter/splitter' +end + +print_stats = ENV["STATS"] + +precompiled_assets = Dir.glob("public/**/*.css") + +if precompiled_assets.empty? + abort "You have no precompiled assets. Please run 'bundle exec rake assets:precompile'" +end + +css_selector_counts = precompiled_assets.map do |css_file| + [File.basename(css_file), CssSplitter::Splitter.count_selectors(css_file)] +end + +invalid_css_sheets = css_selector_counts.select {|selector_count| + puts selector_count.first + selector_count.last > 4095 +} + +# Validate stylesheets +if invalid_css_sheets.empty? + puts "Your stylesheets are alright" +else + invalid_css_sheets.each do |selector_count| + puts "WARNING: #{selector_count.first} contains #{selector_count.last} - more selectors than IE9 can handle" + puts "Consider splitting the stylesheet into more stylesheets" + end +end + +# Print the selector counts +puts "Your stylesheet selector counts:" +puts 85.times.map { "-" }.join +printf "%-70s | %s\n", "Stylesheet", "Selectors" +puts 85.times.map { "-" }.join +css_selector_counts.each do |selector_count| + printf "%-70s | %d\n", selector_count.first, selector_count.last + puts 85.times.map { "-" }.join +end + diff --git a/bin/wifi-pass b/bin/wifi-pass new file mode 100755 index 0000000000..2e8d7cd2b3 --- /dev/null +++ b/bin/wifi-pass @@ -0,0 +1,12 @@ +#!/bin/bash +# Show SSID and password for the currently connected network. Requires sudo. +set -e + +ssid="$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | sed -n "/ SSID:/s/^.\\{2,\\}: //p")" +if [ -n "$ssid" ]; then + echo "$ssid" + security find-generic-password -ga "$ssid" 2>&1 >/dev/null | cut -d\" -f2 +else + echo "No current wifi network name detected" >&2 + exit 1 +fi diff --git a/claude/commands/build-cli.md b/claude/commands/build-cli.md new file mode 100644 index 0000000000..c4bc492445 --- /dev/null +++ b/claude/commands/build-cli.md @@ -0,0 +1,141 @@ +# Build CLI Command + +You are building a CLI that works well for both humans and agents. Follow these principles strictly when designing and implementing CLI commands. + +## Input + +The user will describe what their CLI should do. They may provide: +- A description of the domain and operations +- Existing API endpoints or data models +- Specific commands they want + +If $ARGUMENTS is provided, treat it as the task description. + +## CLI Design Principles + +### 1. Command Naming + +- Name commands around **user tasks**, not internal API operations +- Use `verb-noun` or `noun verb` patterns consistently (pick one, don't mix) +- Common workflows should require minimal flags +- Group related commands under a shared namespace + +### 2. Output Modes + +Every command that produces output MUST support: + +- **Table output** (default) — human-readable, aligned columns +- **JSON output** (`--output=json` or `-o json`) — machine-readable, stable schema +- **`--fields`** flag to select specific fields in both table and JSON modes +- **`--quiet` / `-q`** — minimal output (e.g., just IDs), useful for piping + +Output schema must be stable across versions. Adding fields is fine; renaming or removing fields is a breaking change. + +### 3. Schema Introspection + +Every command group MUST have a `schema` subcommand that returns: + +```json +{ + "command": "resource list", + "description": "List resources with optional filters", + "flags": { + "--status": { "type": "string", "enum": ["active", "archived"], "default": "active" }, + "--limit": { "type": "integer", "default": 50 } + }, + "output_fields": ["id", "name", "status", "created_at"], + "examples": [ + "cli resource list --status=active --output=json", + "cli resource list --fields=id,name" + ] +} +``` + +This lets agents inspect the CLI contract at runtime without parsing `--help` text. + +### 4. Dry Run + +Commands that **write, mutate, or have side effects** MUST support `--dry-run`: + +- Print the normalized request plan (what would be done) without executing +- Output should be valid JSON when combined with `--output=json` +- Dry run must NOT make network calls or state changes + +Read-only commands do not need `--dry-run`. + +### 5. Input Validation + +- Validate all inputs **before** execution, not during +- Use typed flags (enum, integer, boolean) — don't accept arbitrary strings where a finite set exists +- Provide clear, actionable error messages: say what was wrong AND what is expected +- Prefer explicit flags over positional argument overloading beyond the first argument + +### 6. Error Handling + +- Exit codes: `0` success, `1` general error, `2` usage error (bad input/flags) +- Errors in JSON mode must still be valid JSON: `{"error": "message", "code": "ERROR_CODE"}` +- Never print stack traces in production mode — log them to stderr or a debug file +- Include a `--verbose` / `-v` flag for diagnostic output on stderr + +### 7. Discoverability + +- `--help` on every command and subcommand with usage examples +- Top-level `help` command that lists all command groups +- Consider a `discover` command for CLIs that wrap APIs, to show available endpoints not yet promoted to typed commands + +### 8. Safety Rules for Write Commands + +Write commands (create, update, delete) should: + +- Require explicit confirmation for destructive operations (or `--yes` / `-y` to skip) +- Support `--dry-run` (see above) +- Log what was changed to stdout +- Return the affected resource in the output + +### 9. Standard Global Flags + +Every CLI should support these global flags: + +| Flag | Short | Purpose | +|------|-------|---------| +| `--output` | `-o` | Output format: `table`, `json` | +| `--fields` | | Comma-separated field list | +| `--quiet` | `-q` | Minimal output | +| `--verbose` | `-v` | Debug output on stderr | +| `--dry-run` | | Show plan without executing | +| `--yes` | `-y` | Skip confirmation prompts | +| `--help` | `-h` | Show help | + +### 10. Configuration + +- Support config via file (`~/.config/cli-name/config.toml` or similar), env vars, and flags +- Precedence: flags > env vars > config file > defaults +- Provide a `config show` command to display resolved configuration +- Provide a `config set` command for common settings + +## Implementation Approach + +When building the CLI: + +1. **Start with the command tree** — define all commands and their flags before writing implementation +2. **Implement the output layer first** — table/JSON formatting, error formatting, field selection +3. **Add schema generation** — derive from the command definitions, not hand-maintained +4. **Build commands** — using the shared output and validation infrastructure +5. **Add dry-run** — for all write commands +6. **Write integration tests** — test both human-readable and JSON output modes + +## Technology Preferences + +- Ask the user what language/framework they prefer if not obvious from context +- For TypeScript: consider `commander`, `yargs`, or `oclif` +- For Go: consider `cobra` + `pflag` +- For Python: consider `click` or `typer` +- For Rust: consider `clap` + +## What NOT to Do + +- Don't add hidden magic or implicit behavior that differs between runs +- Don't parse free-text where structured input is possible +- Don't change output format based on whether stdout is a TTY (unless the user explicitly opts into this) +- Don't require interactive input — every interactive prompt must have a flag equivalent +- Don't build features "just in case" — promote from real usage via `discover` patterns diff --git a/claude/settings.json b/claude/settings.json new file mode 100644 index 0000000000..4ff8aea4a6 --- /dev/null +++ b/claude/settings.json @@ -0,0 +1,42 @@ +{ + "permissions": { + "defaultMode": "auto" + }, + "model": "opus", + "hooks": { + "Stop": [ + { + "hooks": [ + { + "type": "command", + "command": "osascript -e 'display notification \"Claude needs your attention\" with title \"Claude Code\" sound name \"Ping\"'" + } + ] + } + ] + }, + "enabledPlugins": { + "game-sounds@citedy": true, + "aws-cdk@aws-skills": true, + "aws-cost-ops@aws-skills": true, + "posthog@claude-plugins-official": true, + "frontend-design@claude-plugins-official": true + }, + "extraKnownMarketplaces": { + "citedy": { + "source": { + "source": "github", + "repo": "citedy/claude-plugins" + } + }, + "aws-skills": { + "source": { + "source": "github", + "repo": "zxkane/aws-skills" + } + } + }, + "theme": "dark", + "agentPushNotifEnabled": true, + "skipAutoPermissionPrompt": true +} diff --git a/gitconfig b/gitconfig index 4fadc50f9c..9304efcbb2 100644 --- a/gitconfig +++ b/gitconfig @@ -1,35 +1,58 @@ [user] - name = Ben Orenstein - email = ben.orenstein@gmail.com -[alias] - co = checkout - cleanup = !git remote prune origin && git gc && git clean -df && git stash clear -[color] - diff = auto - status = auto - branch = auto + name = Anders Emil Pouplier + email = aemilnielsen@gmail.com + signingkey = /Users/andersemil/.ssh/id_rsa +# +# [includeIf "gitdir:~/code/kambi"] +# name = Anders Emil Pouplier +# email = anders@shapegames.com +# signingkey = /Users/andersemil/.ssh/id_kambi_github -[color "diff"] - meta = yellow +[alias] + ap = add -p + cm = commit -m + remove-merged = !sh -c 'git checkout master && git branch --merged | egrep -v \"production|master\" | xargs -L1 git delete-branch' + tmp = commit -a -m 'tmp' + wip = commit -a -m 'wip' + co = checkout + cob = checkout -b + dc = diff --cached + db = delete-branch + ri = rebase --interactive --autosquash + rim = rebase --interactive --autosquash master + # Fancy logging. + # h = head + # hp = head with patch + # r = recent commits, only current branch + # ra = recent commits, all reachable refs + # l = all commits, only current branch + # la = all commits, all reachable refs + head = !git r -1 + h = !git head + hp = "!. ~/.githelpers && show_git_head" + r = !GIT_NO_PAGER=1 git l -30 + ra = !git r --all + l = "!. ~/.githelpers && pretty_git_log" + la = !git l --all +[color] + status = auto + diff = auto + branch = auto [core] - excludesfile = ~/.gitignore - editor = vim --noplugin -[apply] - whitespace = nowarn - -[alias] - lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative -[help] - autocorrect = 1 -[branch] - autosetupmerge = true - autosetuprebase = always + editor = vim --noplugin + excludesfile = /Users/andersemil/.gitignore + ignorecase = false +[credential] + helper = osxkeychain [push] - default = current -[rerere] - enabled = 1 -[github] - user = r00k -[merge] - ff = only + default = current +[diff] + indentHeuristic = on + compactionHeuristic = on +[pull] + ff = only +[gpg] + format = ssh +[commit] + gpgsign = true diff --git a/githelpers b/githelpers new file mode 100644 index 0000000000..5fe8b6eba3 --- /dev/null +++ b/githelpers @@ -0,0 +1,66 @@ +#!/bin/bash + +# Log output: +# +# * 51c333e (12 days) add vim-eunuch +# +# The time massaging regexes start with ^[^<]* because that ensures that they +# only operate before the first "<". That "<" will be the beginning of the +# author name, ensuring that we don't destroy anything in the commit message +# that looks like time. +# +# The log format uses } characters between each field, and `column` is later +# used to split on them. A } in the commit subject or any other field will +# break this. + +HASH="%C(yellow)%h%Creset" +RELATIVE_TIME="%Cgreen(%ar)%Creset" +AUTHOR="%C(bold blue)<%an>%Creset" +REFS="%C(bold red)%d%Creset" +SUBJECT="%s" + +FORMAT="$HASH}$RELATIVE_TIME}$AUTHOR}$REFS $SUBJECT" + +ANSI_BLACK='\033[30m' +ANSI_BLACK_BOLD='\033[0;30;1m' +ANSI_RED='\033[31m' +ANSI_RED_BOLD='\033[0;31;1m' +ANSI_GREEN='\033[32m' +ANSI_GREEN_BOLD='\033[0;32;1m' +ANSI_YELLOW='\033[33m' +ANSI_YELLOW_BOLD='\033[0;33;1m' +ANSI_BLUE='\033[34m' +ANSI_BLUE_BOLD='\033[0;34;1m' +ANSI_MAGENTA='\033[35m' +ANSI_MAGENTA_BOLD='\033[0;35;1m' +ANSI_CYAN='\033[36m' +ANSI_CYAN_BOLD='\033[0;36;1m' +ANSI_WHITE='\033[37m' +ANSI_WHITE_BOLD='\033[0;37;1m' +ANSI_RESET='\033[0m' + + +show_git_head() { + pretty_git_log -1 + git show -p --pretty="tformat:" +} + +pretty_git_log() { + git log --graph --pretty="tformat:${FORMAT}" $* | + # Replace (2 years ago) with (2 years) + sed -Ee 's/(^[^<]*) ago\)/\1)/' | + # Replace (2 years, 5 months) with (2 years) + sed -Ee 's/(^[^<]*), [[:digit:]]+ .*months?\)/\1)/' | + # Line columns up based on } delimiter + column -s '}' -t | + # Color merge commits specially + sed -Ee "s/(Merge (branch|remote-tracking branch|pull request) .*$)/$(printf $ANSI_RED)\1$(printf $ANSI_RESET)/" | + # Page only if we're asked to. + if [ -n "$GIT_NO_PAGER" ]; then + cat + else + # Page only if needed. + less --quit-if-one-screen --no-init --RAW-CONTROL-CHARS --chop-long-lines + fi +} + diff --git a/gitignore b/gitignore index 3e7e6b11b8..bb57adffd9 100644 --- a/gitignore +++ b/gitignore @@ -6,3 +6,16 @@ log/ db/*.sqlite3 .netrwhist project-notes.txt +.ruby-gemset +.vimrc +Guardfile +.powenv +.idea +.iml +out +load-env +.vscode +__pycache__ +# cached-foggles +# import-cli/data +.github/instructions/* diff --git a/gvimrc b/gvimrc deleted file mode 100644 index 20f585b39a..0000000000 --- a/gvimrc +++ /dev/null @@ -1,4 +0,0 @@ -set lbr - -set lines=99999 -set columns=99999 diff --git a/id_dsa.pub b/id_dsa.pub deleted file mode 100644 index 44143214c8..0000000000 --- a/id_dsa.pub +++ /dev/null @@ -1 +0,0 @@ -ssh-dss AAAAB3NzaC1kc3MAAACBALkrW/9sxuCz3CiR2o09sw5SCNSpXkTWM7263s5JOLF+GhGnu0hOdNZfDEHAY4osq4UtRCULB8Ufkaf5ZkbL/c47ahydQoj0fDgX7yllrZotC1vLl0ooQB406dPIPX6ZYTCbEXcC20zoqnkHUrm6/bVSXtYOFIsB0d1z22iKuha/AAAAFQCEhRIL9a1/7uZPgotg5fG6CsM43wAAAIEArAA4XIIgPg8brhrEcf29MZtPqnLSRwZtPLGmPM72xGoKttzAawrGi5vGxW7kLviZ/V2Jd/522+MbsC52bsOLb7vJkIA63k4PW6De2mqlhD2gPDWxE9Jtyq+EAP7IXn5YUOAMOzOmBGEGukrLXqnXyKUofdHfYdOXqM4J4nJvHNgAAACBAKrOPk2Yx8vpZgImJWQceelUTxfIe+okW3ryVpSC2PuuCmbIVb4V4Rol2/C0nwvK1CmXLX+Z3zf8w6EnNMnXBTfgtG6c2Yx56RXuWR+s0Bf7nE/TBTd069Z2ElyVVs6Xn86reg9Zepa0OaKjG0HzugEsrhILQCwUvdw04tx68jgL bjo@dhcp-172-24-115-72.dfci.harvard.edu diff --git a/irbrc b/irbrc deleted file mode 100644 index 3111782c1a..0000000000 --- a/irbrc +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/ruby -require 'irb/completion' -require 'irb/ext/save-history' - -# IRB.conf[:SAVE_HISTORY] = 1000 -# IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history" -# -# IRB.conf[:PROMPT_MODE] = :SIMPLE -# -# IRB.conf[:AUTO_INDENT] = true - -class Object - # list methods which aren't in superclass - def local_methods(obj = self) - (obj.methods - obj.class.superclass.instance_methods).sort - end - - def find_ben - User.find_by_email 'ben@thoughtbot.com' - end -end diff --git a/railsrc b/railsrc deleted file mode 100644 index 25028bc713..0000000000 --- a/railsrc +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/ruby - -def change_log(stream) - ActiveRecord::Base.logger = Logger.new(stream) - ActiveRecord::Base.clear_active_connections! -end - -def show_log - change_log(STDOUT) -end - -def hide_log - change_log(nil) -end - -def show_session(session) - Marshal.load(Base64.decode64(session)) -end diff --git a/rdebugrc b/rdebugrc deleted file mode 100644 index 8940138873..0000000000 --- a/rdebugrc +++ /dev/null @@ -1,2 +0,0 @@ -set autoeval on - diff --git a/screenrc b/screenrc deleted file mode 100644 index cce945c094..0000000000 --- a/screenrc +++ /dev/null @@ -1,18 +0,0 @@ - -hardstatus alwayslastline "%{= KW}%-w%{= ck}%50>%n %t%{-}%+w%<%-22=%{w}%c [%l]" - -nonblock 5 - -# detach the screen if we get disconnected -autodetach on - -# Show messages at the bottom for only 0.5s -msgwait 0.5 - -shell -${SHELL} - -# Show the currently-running program -shelltitle '$ |bash' - -# allow for 10,000 lines of scroll back (default 100) -defscrollback 10000 diff --git a/tmux.conf b/tmux.conf index c373dc2a1c..29da1ddcc4 100644 --- a/tmux.conf +++ b/tmux.conf @@ -1,18 +1,20 @@ ########################### # Configuration ########################### +# +set-window-option -g xterm-keys on # use 256 term for pretty colors set -g default-terminal "screen-256color" # increase scroll-back history -set -g history-limit 5000 +set -g history-limit 15000 # use vim key bindings setw -g mode-keys vi -# disable mouse -setw -g mode-mouse off +# Enable mouse +set -g mouse on # decrease command delay (increases vim responsiveness) set -sg escape-time 1 @@ -23,19 +25,35 @@ set -g repeat-time 1000 # re-number windows when one is closed set -g renumber-windows on +# Start window numbering at 1 +set -g base-index 1 + +# Allow notifications to passthrough +set -g allow-passthrough on + + +# This is to make some commands (such as terminal-notifier) to work inside tmux +# https://github.com/julienXX/terminal-notifier/issues/115#issuecomment-104214742 +set -g default-command "which reattach-to-user-namespace > /dev/null && reattach-to-user-namespace -l $SHELL || $SHELL -l" + ########################### # Key Bindings ########################### # tmux prefix +# Use the backtix ` +# Type backtix twice to type the actual character unbind C-b -set -g prefix C-a +set -g prefix ` +bind ` send-prefix + +bind-key L last-window -# resize panes -bind -r H resize-pane -L 5 -bind -r J resize-pane -D 5 -bind -r K resize-pane -U 5 -bind -r L resize-pane -R 5 +# Move around panes in VIM style +bind h select-pane -L +bind j select-pane -D +bind k select-pane -U +bind l select-pane -R # force a reload of the config kile unbind r @@ -50,14 +68,22 @@ bind a send-prefix # Status Bar ########################### -# enable UTF-8 support in status bar -set -g status-utf8 on - # set refresh interval for status bar set -g status-interval 30 # center the status bar set -g status-justify left +set -g status-right 'B: #{battery_icon} #{battery_percentage} #{battery_remain} | I: #{online_status} | %a %d/%h %H:%M' + +########################### +# Copying +########################### +set-option -g status-key vi +set-window-option -g mode-keys vi + +bind-key -Tcopy-mode-vi 'v' send -X begin-selection +bind-key -Tcopy-mode-vi 'V' send -X begin-selection +bind-key -Tcopy-mode-vi 'y' send -X copy-pipe-and-cancel pbcopy ########################### # Colors @@ -68,11 +94,19 @@ set -g status-bg colour235 set -g status-fg white # highlight current window -set-window-option -g window-status-current-fg black -set-window-option -g window-status-current-bg green +# set-window-option -g window-status-current-fg black +# set-window-option -g window-status-current-bg green # set color of active pane -set -g pane-border-fg colour235 -set -g pane-border-bg black -set -g pane-active-border-fg green -set -g pane-active-border-bg black +# set -g pane-border-fg colour235 +# set -g pane-border-bg black +# set -g pane-active-border-fg green +# set -g pane-active-border-bg black + +# List of plugins +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-battery' +set -g @plugin 'tmux-plugins/tmux-online-status' + +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +run '~/.tmux/plugins/tpm/tpm' diff --git a/vim/plugin/snipMate.vim b/vim/plugin/snipMate.vim deleted file mode 100644 index ef03b12b58..0000000000 --- a/vim/plugin/snipMate.vim +++ /dev/null @@ -1,271 +0,0 @@ -" File: snipMate.vim -" Author: Michael Sanders -" Version: 0.84 -" Description: snipMate.vim implements some of TextMate's snippets features in -" Vim. A snippet is a piece of often-typed text that you can -" insert into your document using a trigger word followed by a "". -" -" For more help see snipMate.txt; you can do this by using: -" :helptags ~/.vim/doc -" :h snipMate.txt - -if exists('loaded_snips') || &cp || version < 700 - finish -endif -let loaded_snips = 1 -if !exists('snips_author') | let snips_author = 'Me' | endif - -au BufRead,BufNewFile *.snippets\= set ft=snippet -au FileType snippet setl noet fdm=indent - -let s:snippets = {} | let s:multi_snips = {} - -if !exists('snippets_dir') - let snippets_dir = substitute(globpath(&rtp, 'snippets/'), "\n", ',', 'g') -endif - -fun! MakeSnip(scope, trigger, content, ...) - let multisnip = a:0 && a:1 != '' - let var = multisnip ? 's:multi_snips' : 's:snippets' - if !has_key({var}, a:scope) | let {var}[a:scope] = {} | endif - if !has_key({var}[a:scope], a:trigger) - let {var}[a:scope][a:trigger] = multisnip ? [[a:1, a:content]] : a:content - elseif multisnip | let {var}[a:scope][a:trigger] += [[a:1, a:content]] - else - echom 'Warning in snipMate.vim: Snippet '.a:trigger.' is already defined.' - \ .' See :h multi_snip for help on snippets with multiple matches.' - endif -endf - -fun! ExtractSnips(dir, ft) - for path in split(globpath(a:dir, '*'), "\n") - if isdirectory(path) - let pathname = fnamemodify(path, ':t') - for snipFile in split(globpath(path, '*.snippet'), "\n") - call s:ProcessFile(snipFile, a:ft, pathname) - endfor - elseif fnamemodify(path, ':e') == 'snippet' - call s:ProcessFile(path, a:ft) - endif - endfor -endf - -" Processes a single-snippet file; optionally add the name of the parent -" directory for a snippet with multiple matches. -fun s:ProcessFile(file, ft, ...) - let keyword = fnamemodify(a:file, ':t:r') - if keyword == '' | return | endif - try - let text = join(readfile(a:file), "\n") - catch /E484/ - echom "Error in snipMate.vim: couldn't read file: ".a:file - endtry - return a:0 ? MakeSnip(a:ft, a:1, text, keyword) - \ : MakeSnip(a:ft, keyword, text) -endf - -fun! ExtractSnipsFile(file, ft) - if !filereadable(a:file) | return | endif - let text = readfile(a:file) - let inSnip = 0 - for line in text + ["\n"] - if inSnip && (line[0] == "\t" || line == '') - let content .= strpart(line, 1)."\n" - continue - elseif inSnip - call MakeSnip(a:ft, trigger, content[:-2], name) - let inSnip = 0 - endif - - if line[:6] == 'snippet' - let inSnip = 1 - let trigger = strpart(line, 8) - let name = '' - let space = stridx(trigger, ' ') + 1 - if space " Process multi snip - let name = strpart(trigger, space) - let trigger = strpart(trigger, 0, space - 1) - endif - let content = '' - endif - endfor -endf - -" Reset snippets for filetype. -fun! ResetSnippets(ft) - let ft = a:ft == '' ? '_' : a:ft - for dict in [s:snippets, s:multi_snips, g:did_ft] - if has_key(dict, ft) - unlet dict[ft] - endif - endfor -endf - -" Reset snippets for all filetypes. -fun! ResetAllSnippets() - let s:snippets = {} | let s:multi_snips = {} | let g:did_ft = {} -endf - -" Reload snippets for filetype. -fun! ReloadSnippets(ft) - let ft = a:ft == '' ? '_' : a:ft - call ResetSnippets(ft) - call GetSnippets(g:snippets_dir, ft) -endf - -" Reload snippets for all filetypes. -fun! ReloadAllSnippets() - for ft in keys(g:did_ft) - call ReloadSnippets(ft) - endfor -endf - -let g:did_ft = {} -fun! GetSnippets(dir, filetypes) - for ft in split(a:filetypes, '\.') - if has_key(g:did_ft, ft) | continue | endif - call s:DefineSnips(a:dir, ft, ft) - if ft == 'objc' || ft == 'cpp' || ft == 'cs' - call s:DefineSnips(a:dir, 'c', ft) - elseif ft == 'xhtml' - call s:DefineSnips(a:dir, 'html', 'xhtml') - endif - let g:did_ft[ft] = 1 - endfor -endf - -" Define "aliasft" snippets for the filetype "realft". -fun s:DefineSnips(dir, aliasft, realft) - for path in split(globpath(a:dir, a:aliasft.'/')."\n". - \ globpath(a:dir, a:aliasft.'-*/'), "\n") - call ExtractSnips(path, a:realft) - endfor - for path in split(globpath(a:dir, a:aliasft.'.snippets')."\n". - \ globpath(a:dir, a:aliasft.'-*.snippets'), "\n") - call ExtractSnipsFile(path, a:realft) - endfor -endf - -fun! TriggerSnippet() - if exists('g:SuperTabMappingForward') - if g:SuperTabMappingForward == "" - let SuperTabKey = "\" - elseif g:SuperTabMappingBackward == "" - let SuperTabKey = "\" - endif - endif - - if pumvisible() " Update snippet if completion is used, or deal with supertab - if exists('SuperTabKey') - call feedkeys(SuperTabKey) | return '' - endif - call feedkeys("\a", 'n') " Close completion menu - call feedkeys("\") | return '' - endif - - if exists('g:snipPos') | return snipMate#jumpTabStop(0) | endif - - let word = matchstr(getline('.'), '\S\+\%'.col('.').'c') - for scope in [bufnr('%')] + split(&ft, '\.') + ['_'] - let [trigger, snippet] = s:GetSnippet(word, scope) - " If word is a trigger for a snippet, delete the trigger & expand - " the snippet. - if snippet != '' - let col = col('.') - len(trigger) - sil exe 's/\V'.escape(trigger, '/\.').'\%#//' - return snipMate#expandSnip(snippet, col) - endif - endfor - - if exists('SuperTabKey') - call feedkeys(SuperTabKey) - return '' - endif - return "\" -endf - -fun! BackwardsSnippet() - if exists('g:snipPos') | return snipMate#jumpTabStop(1) | endif - - if exists('g:SuperTabMappingForward') - if g:SuperTabMappingBackward == "" - let SuperTabKey = "\" - elseif g:SuperTabMappingForward == "" - let SuperTabKey = "\" - endif - endif - if exists('SuperTabKey') - call feedkeys(SuperTabKey) - return '' - endif - return "\" -endf - -" Check if word under cursor is snippet trigger; if it isn't, try checking if -" the text after non-word characters is (e.g. check for "foo" in "bar.foo") -fun s:GetSnippet(word, scope) - let word = a:word | let snippet = '' - while snippet == '' - if exists('s:snippets["'.a:scope.'"]["'.escape(word, '\"').'"]') - let snippet = s:snippets[a:scope][word] - elseif exists('s:multi_snips["'.a:scope.'"]["'.escape(word, '\"').'"]') - let snippet = s:ChooseSnippet(a:scope, word) - if snippet == '' | break | endif - else - if match(word, '\W') == -1 | break | endif - let word = substitute(word, '.\{-}\W', '', '') - endif - endw - if word == '' && a:word != '.' && stridx(a:word, '.') != -1 - let [word, snippet] = s:GetSnippet('.', a:scope) - endif - return [word, snippet] -endf - -fun s:ChooseSnippet(scope, trigger) - let snippet = [] - let i = 1 - for snip in s:multi_snips[a:scope][a:trigger] - let snippet += [i.'. '.snip[0]] - let i += 1 - endfor - if i == 2 | return s:multi_snips[a:scope][a:trigger][0][1] | endif - let num = inputlist(snippet) - 1 - return num == -1 ? '' : s:multi_snips[a:scope][a:trigger][num][1] -endf - -fun! ShowAvailableSnips() - let line = getline('.') - let col = col('.') - let word = matchstr(getline('.'), '\S\+\%'.col.'c') - let words = [word] - if stridx(word, '.') - let words += split(word, '\.', 1) - endif - let matchlen = 0 - let matches = [] - for scope in [bufnr('%')] + split(&ft, '\.') + ['_'] - let triggers = has_key(s:snippets, scope) ? keys(s:snippets[scope]) : [] - if has_key(s:multi_snips, scope) - let triggers += keys(s:multi_snips[scope]) - endif - for trigger in triggers - for word in words - if word == '' - let matches += [trigger] " Show all matches if word is empty - elseif trigger =~ '^'.word - let matches += [trigger] - let len = len(word) - if len > matchlen | let matchlen = len | endif - endif - endfor - endfor - endfor - - " This is to avoid a bug with Vim when using complete(col - matchlen, matches) - " (Issue#46 on the Google Code snipMate issue tracker). - call setline(line('.'), substitute(line, repeat('.', matchlen).'\%'.col.'c', '', '')) - call complete(col, matches) - return '' -endf -" vim:noet:sw=4:ts=4:ft=vim diff --git a/vim/snippets/_.snippets b/vim/snippets/_.snippets deleted file mode 100644 index d3ee355272..0000000000 --- a/vim/snippets/_.snippets +++ /dev/null @@ -1,9 +0,0 @@ -# Global snippets - -# (c) holds no legal value ;) -snippet c) - Copyright `&enc[:2] == "utf" ? "©" : "(c)"` `strftime("%Y")` ${1:`g:snips_author`}. All Rights Reserved.${2} -snippet date - `strftime("%Y-%m-%d")` -snippet ddate - `strftime("%B %d, %Y")` diff --git a/vim/snippets/autoit.snippets b/vim/snippets/autoit.snippets deleted file mode 100644 index 690018ce9f..0000000000 --- a/vim/snippets/autoit.snippets +++ /dev/null @@ -1,66 +0,0 @@ -snippet if - If ${1:condition} Then - ${2:; True code} - EndIf -snippet el - Else - ${1} -snippet elif - ElseIf ${1:condition} Then - ${2:; True code} -# If/Else block -snippet ifel - If ${1:condition} Then - ${2:; True code} - Else - ${3:; Else code} - EndIf -# If/ElseIf/Else block -snippet ifelif - If ${1:condition 1} Then - ${2:; True code} - ElseIf ${3:condition 2} Then - ${4:; True code} - Else - ${5:; Else code} - EndIf -# Switch block -snippet switch - Switch (${1:condition}) - Case {$2:case1}: - {$3:; Case 1 code} - Case Else: - {$4:; Else code} - EndSwitch -# Select block -snippet select - Select (${1:condition}) - Case {$2:case1}: - {$3:; Case 1 code} - Case Else: - {$4:; Else code} - EndSelect -# While loop -snippet while - While (${1:condition}) - ${2:; code...} - WEnd -# For loop -snippet for - For ${1:n} = ${3:1} to ${2:count} - ${4:; code...} - Next -# New Function -snippet func - Func ${1:fname}(${2:`indent('.') ? 'self' : ''`}): - ${4:Return} - EndFunc -# Message box -snippet msg - MsgBox(${3:MsgType}, ${1:"Title"}, ${2:"Message Text"}) -# Debug Message -snippet debug - MsgBox(0, "Debug", ${1:"Debug Message"}) -# Show Variable Debug Message -snippet showvar - MsgBox(0, "${1:VarName}", $1) diff --git a/vim/snippets/c.snippets b/vim/snippets/c.snippets deleted file mode 100644 index e1c4f0500a..0000000000 --- a/vim/snippets/c.snippets +++ /dev/null @@ -1,113 +0,0 @@ -# main() -snippet main - int main(int argc, const char *argv[]) - { - ${1} - return 0; - } -snippet mainn - int main(void) - { - ${1} - return 0; - } -# #include <...> -snippet inc - #include <${1:stdio}.h>${2} -# #include "..." -snippet Inc - #include "${1:`Filename("$1.h")`}"${2} -# #ifndef ... #define ... #endif -snippet Def - #ifndef $1 - #define ${1:SYMBOL} ${2:value} - #endif${3} -snippet def - #define -snippet ifdef - #ifdef ${1:FOO} - ${2:#define } - #endif -snippet #if - #if ${1:FOO} - ${2} - #endif -# Header Include-Guard -snippet once - #ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`} - - #define $1 - - ${2} - - #endif /* end of include guard: $1 */ -# If Condition -snippet if - if (${1:/* condition */}) { - ${2:/* code */} - } -snippet el - else { - ${1} - } -# Ternary conditional -snippet t - ${1:/* condition */} ? ${2:a} : ${3:b} -# Do While Loop -snippet do - do { - ${2:/* code */} - } while (${1:/* condition */}); -# While Loop -snippet wh - while (${1:/* condition */}) { - ${2:/* code */} - } -# For Loop -snippet for - for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) { - ${4:/* code */} - } -# Custom For Loop -snippet forr - for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) { - ${5:/* code */} - } -# Function -snippet fun - ${1:void} ${2:function_name}(${3}) - { - ${4:/* code */} - } -# Function Declaration -snippet fund - ${1:void} ${2:function_name}(${3});${4} -# Typedef -snippet td - typedef ${1:int} ${2:MyCustomType};${3} -# Struct -snippet st - struct ${1:`Filename('$1_t', 'name')`} { - ${2:/* data */} - }${3: /* optional variable list */};${4} -# Typedef struct -snippet tds - typedef struct ${2:_$1 }{ - ${3:/* data */} - } ${1:`Filename('$1_t', 'name')`}; -# Typdef enum -snippet tde - typedef enum { - ${1:/* data */} - } ${2:foo}; -# printf -# unfortunately version this isn't as nice as TextMates's, given the lack of a -# dynamic `...` -snippet pr - printf("${1:%s}\n"${2});${3} -# fprintf (again, this isn't as nice as TextMate's version, but it works) -snippet fpr - fprintf(${1:stderr}, "${2:%s}\n"${3});${4} -# This is kind of convenient -snippet . - [${1}]${2} diff --git a/vim/snippets/cpp.snippets b/vim/snippets/cpp.snippets deleted file mode 100644 index fdabd634ba..0000000000 --- a/vim/snippets/cpp.snippets +++ /dev/null @@ -1,34 +0,0 @@ -# Read File Into Vector -snippet readfile - std::vector v; - if (FILE *${2:fp} = fopen(${1:"filename"}, "r")) { - char buf[1024]; - while (size_t len = fread(buf, 1, sizeof(buf), $2)) - v.insert(v.end(), buf, buf + len); - fclose($2); - }${3} -# std::map -snippet map - std::map<${1:key}, ${2:value}> map${3}; -# std::vector -snippet vector - std::vector<${1:char}> v${2}; -# Namespace -snippet ns - namespace ${1:`Filename('', 'my')`} { - ${2} - } /* $1 */ -# Class -snippet cl - class ${1:`Filename('$1_t', 'name')`} { - public: - $1 (${2:arguments}); - virtual ~$1 (); - - private: - ${3:/* data */} - }; -snippet fori - for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) { - ${4:/* code */} - } diff --git a/vim/snippets/erlang.snippets b/vim/snippets/erlang.snippets deleted file mode 100644 index 7238149130..0000000000 --- a/vim/snippets/erlang.snippets +++ /dev/null @@ -1,39 +0,0 @@ -# module and export all -snippet mod - -module(${1:`Filename('', 'my')`}). - - -compile([export_all]). - - start() -> - ${2} - - stop() -> - ok. -# define directive -snippet def - -define(${1:macro}, ${2:body}).${3} -# export directive -snippet exp - -export([${1:function}/${2:arity}]). -# include directive -snippet inc - -include("${1:file}").${2} -# behavior directive -snippet beh - -behaviour(${1:behaviour}).${2} -# if expression -snippet if - if - ${1:guard} -> - ${2:body} - end -# case expression -snippet case - case ${1:expression} of - ${2:pattern} -> - ${3:body}; - end -# record directive -snippet rec - -record(${1:record}, { - ${2:field}=${3:value}}).${4} diff --git a/vim/snippets/eruby.snippets b/vim/snippets/eruby.snippets deleted file mode 100644 index 01ebe65961..0000000000 --- a/vim/snippets/eruby.snippets +++ /dev/null @@ -1,12 +0,0 @@ -snippet p - <% ${1} %> -snippet pe - <%= ${1} %> -snippet end - <% end %> -snippet else - <% else %> -snippet prot - protocol${1} -snippet acti - activation_group${1} diff --git a/vim/snippets/html.snippets b/vim/snippets/html.snippets deleted file mode 100644 index 302cea2645..0000000000 --- a/vim/snippets/html.snippets +++ /dev/null @@ -1,190 +0,0 @@ -# Some useful Unicode entities -# Non-Breaking Space -snippet nbs -   -# ← -snippet left - ← -# → -snippet right - → -# ↑ -snippet up - ↑ -# ↓ -snippet down - ↓ -# ↩ -snippet return - ↩ -# ⇤ -snippet backtab - ⇤ -# ⇥ -snippet tab - ⇥ -# ⇧ -snippet shift - ⇧ -# ⌃ -snippet control - ⌃ -# ⌅ -snippet enter - ⌅ -# ⌘ -snippet command - ⌘ -# ⌥ -snippet option - ⌥ -# ⌦ -snippet delete - ⌦ -# ⌫ -snippet backspace - ⌫ -# ⎋ -snippet escape - ⎋ -# Generic Doctype -snippet doctype HTML 4.01 Strict - -snippet doctype HTML 4.01 Transitional - -snippet doctype HTML 5 - -snippet doctype XHTML 1.0 Frameset - -snippet doctype XHTML 1.0 Strict - -snippet doctype XHTML 1.0 Transitional - -snippet doctype XHTML 1.1 - -# HTML Doctype 4.01 Strict -snippet docts - -# HTML Doctype 4.01 Transitional -snippet doct - -# HTML Doctype 5 -snippet doct5 - -# XHTML Doctype 1.0 Frameset -snippet docxf - -# XHTML Doctype 1.0 Strict -snippet docxs - -# XHTML Doctype 1.0 Transitional -snippet docxt - -# XHTML Doctype 1.1 -snippet docx - -snippet html - - ${1} - -snippet xhtml - - ${1} - -snippet body - - ${1} - -snippet head - - - - Codestin Search App - ${2} - -snippet title - Codestin Search App${2} -snippet script - ${2} -snippet scriptsrc - ${2} -snippet style - ${3} -snippet base - -snippet r - -snippet div -
- ${2} -
-# Embed QT Movie -snippet movie - - - - - - ${6} -snippet fieldset -
- ${1:name} - - ${3} -
-snippet form -
- ${3} - - -

-
-snippet h1 -

${2:$1}

-snippet input - ${4} -snippet label - ${7} -snippet link - ${4} -snippet mailto - ${3:email me} -snippet meta - ${3} -snippet opt - ${3} -snippet optt - ${2} -snippet select - ${5} -snippet table - - - -
${2:Header}
${3:Data}
${4} -snippet textarea - ${5} diff --git a/vim/snippets/java.snippets b/vim/snippets/java.snippets deleted file mode 100644 index dd96b790a0..0000000000 --- a/vim/snippets/java.snippets +++ /dev/null @@ -1,95 +0,0 @@ -snippet main - public static void main (String [] args) - { - ${1:/* code */} - } -snippet pu - public -snippet po - protected -snippet pr - private -snippet st - static -snippet fi - final -snippet ab - abstract -snippet re - return -snippet br - break; -snippet de - default: - ${1} -snippet ca - catch(${1:Exception} ${2:e}) ${3} -snippet th - throw -snippet sy - synchronized -snippet im - import -snippet imp - implements -snippet ext - extends -snippet j.u - java.util -snippet j.i - java.io. -snippet j.b - java.beans. -snippet j.n - java.net. -snippet j.m - java.math. -snippet if - if (${1}) ${2} -snippet el - else -snippet elif - else if (${1}) ${2} -snippet wh - while (${1}) ${2} -snippet for - for (${1}; ${2}; ${3}) ${4} -snippet fore - for (${1} : ${2}) ${3} -snippet sw - switch (${1}) ${2} -snippet cs - case ${1}: - ${2} - ${3} -snippet tc - public class ${1:`Filename()`} extends ${2:TestCase} -snippet t - public void test${1:Name}() throws Exception ${2} -snippet cl - class ${1:`Filename("", "untitled")`} ${2} -snippet in - interface ${1:`Filename("", "untitled")`} ${2:extends Parent}${3} -snippet m - ${1:void} ${2:method}(${3}) ${4:throws }${5} -snippet v - ${1:String} ${2:var}${3: = null}${4};${5} -snippet co - static public final ${1:String} ${2:var} = ${3};${4} -snippet cos - static public final String ${1:var} = "${2}";${3} -snippet as - assert ${1:test} : "${2:Failure message}";${3} -snippet try - try { - ${3} - } catch(${1:Exception} ${2:e}) { - } -snippet tryf - try { - ${3} - } catch(${1:Exception} ${2:e}) { - } finally { - } -snippet rst - ResultSet ${1:rst}${2: = null}${3};${4} diff --git a/vim/snippets/javascript.snippets b/vim/snippets/javascript.snippets deleted file mode 100644 index f869e2f6b4..0000000000 --- a/vim/snippets/javascript.snippets +++ /dev/null @@ -1,74 +0,0 @@ -# Prototype -snippet proto - ${1:class_name}.prototype.${2:method_name} = - function(${3:first_argument}) { - ${4:// body...} - }; -# Function -snippet fun - function ${1:function_name} (${2:argument}) { - ${3:// body...} - } -# Anonymous Function -snippet f - function(${1}) {${2}}; -# if -snippet if - if (${1:true}) {${2}} -# if ... else -snippet ife - if (${1:true}) {${2}} - else{${3}} -# tertiary conditional -snippet t - ${1:/* condition */} ? ${2:a} : ${3:b} -# switch -snippet switch - switch(${1:expression}) { - case '${3:case}': - ${4:// code} - break; - ${5} - default: - ${2:// code} - } -# case -snippet case - case '${1:case}': - ${2:// code} - break; - ${3} -# for (...) {...} -snippet for - for (var ${2:i} = 0; $2 < ${1:Things}.length; $2${3:++}) { - ${4:$1[$2]} - }; -# for (...) {...} (Improved Native For-Loop) -snippet forr - for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2${3:--}) { - ${4:$1[$2]} - }; -# while (...) {...} -snippet wh - while (${1:/* condition */}) { - ${2:/* code */} - } -# do...while -snippet do - do { - ${2:/* code */} - } while (${1:/* condition */}); -# Object Method -snippet :f - ${1:method_name}: function(${2:attribute}) { - ${4} - }${3:,} -# setTimeout function -snippet timeout - setTimeout(function() {${3}}${2}, ${1:10}; -# Get Elements -snippet get - getElementsBy${1:TagName}('${2}')${3} -# Get Element -snippet gett - getElementBy${1:Id}('${2}')${3} diff --git a/vim/snippets/mako.snippets b/vim/snippets/mako.snippets deleted file mode 100644 index 2a0aef9ce5..0000000000 --- a/vim/snippets/mako.snippets +++ /dev/null @@ -1,54 +0,0 @@ -snippet def - <%def name="${1:name}"> - ${2:} - -snippet call - <%call expr="${1:name}"> - ${2:} - -snippet doc - <%doc> - ${1:} - -snippet text - <%text> - ${1:} - -snippet for - % for ${1:i} in ${2:iter}: - ${3:} - % endfor -snippet if if - % if ${1:condition}: - ${2:} - % endif -snippet if if/else - % if ${1:condition}: - ${2:} - % else: - ${3:} - % endif -snippet try - % try: - ${1:} - % except${2:}: - ${3:pass} - % endtry -snippet wh - % while ${1:}: - ${2:} - % endwhile -snippet $ - ${ ${1:} } -snippet <% - <% ${1:} %> -snippet -snippet inherit - <%inherit file="${1:filename}" /> -snippet include - <%include file="${1:filename}" /> -snippet namespace - <%namespace file="${1:name}" /> -snippet page - <%page args="${1:}" /> diff --git a/vim/snippets/objc.snippets b/vim/snippets/objc.snippets deleted file mode 100644 index 85b80d9e6c..0000000000 --- a/vim/snippets/objc.snippets +++ /dev/null @@ -1,247 +0,0 @@ -# #import <...> -snippet Imp - #import <${1:Cocoa/Cocoa.h}>${2} -# #import "..." -snippet imp - #import "${1:`Filename()`.h}"${2} -# @selector(...) -snippet sel - @selector(${1:method}:)${3} -# @"..." string -snippet s - @"${1}"${2} -# Object -snippet o - ${1:NSObject} *${2:foo} = [${3:$1 alloc}]${4};${5} -# NSLog(...) -snippet log - NSLog(@"${1:%@}"${2});${3} -# Class -snippet objc - @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject} - { - } - @end - - @implementation $1 - ${3} - @end -# Class Interface -snippet int - @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject} - {${3} - } - ${4} - @end -snippet @interface - @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject} - {${3} - } - ${4} - @end -# Class Implementation -snippet impl - @implementation ${1:`Filename('', 'someClass')`} - ${2} - @end -snippet @implementation - @implementation ${1:`Filename('', 'someClass')`} - ${2} - @end -# Protocol -snippet pro - @protocol ${1:`Filename('$1Delegate', 'MyProtocol')`} ${2:} - ${3} - @end -snippet @protocol - @protocol ${1:`Filename('$1Delegate', 'MyProtocol')`} ${2:} - ${3} - @end -# init Definition -snippet init - - (id)init - { - if (self = [super init]) { - ${1} - } - return self; - } -# dealloc Definition -snippet dealloc - - (void) dealloc - { - ${1:deallocations} - [super dealloc]; - } -snippet su - [super ${1:init}]${2} -snippet ibo - IBOutlet ${1:NSSomeClass} *${2:$1};${3} -# Category -snippet cat - @interface ${1:NSObject} (${2:MyCategory}) - @end - - @implementation $1 ($2) - ${3} - @end -# Category Interface -snippet cath - @interface ${1:`Filename('$1', 'NSObject')`} (${2:MyCategory}) - ${3} - @end -# Method -snippet m - - (${1:id})${2:method} - { - ${3} - } -# Method declaration -snippet md - - (${1:id})${2:method};${3} -# IBAction declaration -snippet ibad - - (IBAction)${1:method}:(${2:id})sender;${3} -# IBAction method -snippet iba - - (IBAction)${1:method}:(${2:id})sender - { - ${3} - } -# awakeFromNib method -snippet wake - - (void)awakeFromNib - { - ${1} - } -# Class Method -snippet M - + (${1:id})${2:method} - { - ${3:return nil;} - } -# Sub-method (Call super) -snippet sm - - (${1:id})${2:method} - { - [super $2];${3} - return self; - } -# Accessor Methods For: -# Object -snippet objacc - - (${1:id})${2:thing} - { - return $2; - } - - - (void)set$2:($1)${3:new$2} - { - [$3 retain]; - [$2 release]; - $2 = $3; - }${4} -# for (object in array) -snippet forin - for (${1:Class} *${2:some$1} in ${3:array}) { - ${4} - } -snippet fore - for (${1:object} in ${2:array}) { - ${3:statements} - } -snippet forarray - unsigned int ${1:object}Count = [${2:array} count]; - - for (unsigned int index = 0; index < $1Count; index++) { - ${3:id} $1 = [$2 $1AtIndex:index]; - ${4} - } -snippet fora - unsigned int ${1:object}Count = [${2:array} count]; - - for (unsigned int index = 0; index < $1Count; index++) { - ${3:id} $1 = [$2 $1AtIndex:index]; - ${4} - } -# Try / Catch Block -snippet @try - @try { - ${1:statements} - } - @catch (NSException * e) { - ${2:handler} - } - @finally { - ${3:statements} - } -snippet @catch - @catch (${1:exception}) { - ${2:handler} - } -snippet @finally - @finally { - ${1:statements} - } -# IBOutlet -# @property (Objective-C 2.0) -snippet prop - @property (${1:retain}) ${2:NSSomeClass} ${3:*$2};${4} -# @synthesize (Objective-C 2.0) -snippet syn - @synthesize ${1:property};${2} -# [[ alloc] init] -snippet alloc - [[${1:foo} alloc] init${2}];${3} -snippet a - [[${1:foo} alloc] init${2}];${3} -# retain -snippet ret - [${1:foo} retain];${2} -# release -snippet rel - [${1:foo} release]; -# autorelease -snippet arel - [${1:foo} autorelease]; -# autorelease pool -snippet pool - NSAutoreleasePool *${1:pool} = [[NSAutoreleasePool alloc] init]; - ${2:/* code */} - [$1 drain]; -# Throw an exception -snippet except - NSException *${1:badness}; - $1 = [NSException exceptionWithName:@"${2:$1Name}" - reason:@"${3}" - userInfo:nil]; - [$1 raise]; -snippet prag - #pragma mark ${1:-} -snippet cl - @class ${1:Foo};${2} -snippet color - [[NSColor ${1:blackColor}] set]; -# NSArray -snippet array - NSMutableArray *${1:array} = [NSMutable array];${2} -snippet nsa - NSArray ${1} -snippet nsma - NSMutableArray ${1} -snippet aa - NSArray * array;${1} -snippet ma - NSMutableArray * array;${1} -# NSDictionary -snippet dict - NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];${2} -snippet nsd - NSDictionary ${1} -snippet nsmd - NSMutableDictionary ${1} -# NSString -snippet nss - NSString ${1} -snippet nsms - NSMutableString ${1} diff --git a/vim/snippets/perl.snippets b/vim/snippets/perl.snippets deleted file mode 100644 index c85ff11359..0000000000 --- a/vim/snippets/perl.snippets +++ /dev/null @@ -1,97 +0,0 @@ -# #!/usr/bin/perl -snippet #! - #!/usr/bin/perl - -# Hash Pointer -snippet . - => -# Function -snippet sub - sub ${1:function_name} { - ${2:#body ...} - } -# Conditional -snippet if - if (${1}) { - ${2:# body...} - } -# Conditional if..else -snippet ife - if (${1}) { - ${2:# body...} - } - else { - ${3:# else...} - } -# Conditional if..elsif..else -snippet ifee - if (${1}) { - ${2:# body...} - } - elsif (${3}) { - ${4:# elsif...} - } - else { - ${5:# else...} - } -# Conditional One-line -snippet xif - ${1:expression} if ${2:condition};${3} -# Unless conditional -snippet unless - unless (${1}) { - ${2:# body...} - } -# Unless conditional One-line -snippet xunless - ${1:expression} unless ${2:condition};${3} -# Try/Except -snippet eval - eval { - ${1:# do something risky...} - }; - if ($@) { - ${2:# handle failure...} - } -# While Loop -snippet wh - while (${1}) { - ${2:# body...} - } -# While Loop One-line -snippet xwh - ${1:expression} while ${2:condition};${3} -# C-style For Loop -snippet cfor - for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) { - ${4:# body...} - } -# For loop one-line -snippet xfor - ${1:expression} for @${2:array};${3} -# Foreach Loop -snippet for - foreach my $${1:x} (@${2:array}) { - ${3:# body...} - } -# Foreach Loop One-line -snippet fore - ${1:expression} foreach @${2:array};${3} -# Package -snippet cl - package ${1:ClassName}; - - use base qw(${2:ParentClass}); - - sub new { - my $class = shift; - $class = ref $class if ref $class; - my $self = bless {}, $class; - $self; - } - - 1;${3} -# Read File -snippet slurp - my $${1:var}; - { local $/ = undef; local *FILE; open FILE, "<${2:file}"; $$1 = ; close FILE }${3} diff --git a/vim/snippets/php.snippets b/vim/snippets/php.snippets deleted file mode 100644 index 3ce9e26cc4..0000000000 --- a/vim/snippets/php.snippets +++ /dev/null @@ -1,216 +0,0 @@ -snippet php - -snippet ec - echo "${1:string}"${2}; -snippet inc - include '${1:file}';${2} -snippet inc1 - include_once '${1:file}';${2} -snippet req - require '${1:file}';${2} -snippet req1 - require_once '${1:file}';${2} -# $GLOBALS['...'] -snippet globals - $GLOBALS['${1:variable}']${2: = }${3:something}${4:;}${5} -snippet $_ COOKIE['...'] - $_COOKIE['${1:variable}']${2} -snippet $_ ENV['...'] - $_ENV['${1:variable}']${2} -snippet $_ FILES['...'] - $_FILES['${1:variable}']${2} -snippet $_ Get['...'] - $_GET['${1:variable}']${2} -snippet $_ POST['...'] - $_POST['${1:variable}']${2} -snippet $_ REQUEST['...'] - $_REQUEST['${1:variable}']${2} -snippet $_ SERVER['...'] - $_SERVER['${1:variable}']${2} -snippet $_ SESSION['...'] - $_SESSION['${1:variable}']${2} -# Start Docblock -snippet /* - /** - * ${1} - **/ -# Class - post doc -snippet doc_cp - /** - * ${1:undocumented class} - * - * @package ${2:default} - * @author ${3:`g:snips_author`} - **/${4} -# Class Variable - post doc -snippet doc_vp - /** - * ${1:undocumented class variable} - * - * @var ${2:string} - **/${3} -# Class Variable -snippet doc_v - /** - * ${3:undocumented class variable} - * - * @var ${4:string} - **/ - ${1:var} $${2};${5} -# Class -snippet doc_c - /** - * ${3:undocumented class} - * - * @packaged ${4:default} - * @author ${5:`g:snips_author`} - **/ - ${1:}class ${2:} - {${6} - } // END $1class $2 -# Constant Definition - post doc -snippet doc_dp - /** - * ${1:undocumented constant} - **/${2} -# Constant Definition -snippet doc_d - /** - * ${3:undocumented constant} - **/ - define(${1}, ${2});${4} -# Function - post doc -snippet doc_fp - /** - * ${1:undocumented function} - * - * @return ${2:void} - * @author ${3:`g:snips_author`} - **/${4} -# Function signature -snippet doc_s - /** - * ${4:undocumented function} - * - * @return ${5:void} - * @author ${6:`g:snips_author`} - **/ - ${1}function ${2}(${3});${7} -# Function -snippet doc_f - /** - * ${4:undocumented function} - * - * @return ${5:void} - * @author ${6:`g:snips_author`} - **/ - ${1}function ${2}(${3}) - {${7} - } -# Header -snippet doc_h - /** - * ${1} - * - * @author ${2:`g:snips_author`} - * @version ${3:$Id$} - * @copyright ${4:$2}, `strftime('%d %B, %Y')` - * @package ${5:default} - **/ - - /** - * Define DocBlock - *// -# Interface -snippet doc_i - /** - * ${2:undocumented class} - * - * @package ${3:default} - * @author ${4:`g:snips_author`} - **/ - interface ${1:} - {${5} - } // END interface $1 -# class ... -snippet class - /** - * ${1} - **/ - class ${2:ClassName} - { - ${3} - function ${4:__construct}(${5:argument}) - { - ${6:// code...} - } - } -# define(...) -snippet def - define('${1}'${2});${3} -# defined(...) -snippet def? - ${1}defined('${2}')${3} -snippet wh - while (${1:/* condition */}) { - ${2:// code...} - } -# do ... while -snippet do - do { - ${2:// code... } - } while (${1:/* condition */}); -snippet if - if (${1:/* condition */}) { - ${2:// code...} - } -snippet ife - if (${1:/* condition */}) { - ${2:// code...} - } else { - ${3:// code...} - } - ${4} -snippet else - else { - ${1:// code...} - } -snippet elseif - elseif (${1:/* condition */}) { - ${2:// code...} - } -# Tertiary conditional -snippet t - $${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5} -snippet switch - switch ($${1:variable}) { - case '${2:value}': - ${3:// code...} - break; - ${5} - default: - ${4:// code...} - break; - } -snippet case - case '${1:value}': - ${2:// code...} - break;${3} -snippet for - for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) { - ${4: // code...} - } -snippet foreach - foreach ($${1:variable} as $${2:key}) { - ${3:// code...} - } -snippet fun - ${1:public }function ${2:FunctionName}(${3}) - { - ${4:// code...} - } -# $... = array (...) -snippet array - $${1:arrayName} = array('${2}' => ${3});${4} diff --git a/vim/snippets/python.snippets b/vim/snippets/python.snippets deleted file mode 100644 index 28a2948a07..0000000000 --- a/vim/snippets/python.snippets +++ /dev/null @@ -1,86 +0,0 @@ -snippet #! - #!/usr/bin/env python - -snippet imp - import ${1:module} -# Module Docstring -snippet docs - ''' - File: ${1:`Filename('$1.py', 'foo.py')`} - Author: ${2:`g:snips_author`} - Description: ${3} - ''' -snippet wh - while ${1:condition}: - ${2:# code...} -snippet for - for ${1:needle} in ${2:haystack}: - ${3:# code...} -# New Class -snippet cl - class ${1:ClassName}(${2:object}): - """${3:docstring for $1}""" - def __init__(self, ${4:arg}): - ${5:super($1, self).__init__()} - self.$4 = $4 - ${6} -# New Function -snippet def - def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): - """${3:docstring for $1}""" - ${4:pass} -snippet deff - def ${1:fname}(${2:`indent('.') ? 'self' : ''`}): - ${3} -# New Method -snippet defs - def ${1:mname}(self, ${2:arg}): - ${3:pass} -# New Property -snippet property - def ${1:foo}(): - doc = "${2:The $1 property.}" - def fget(self): - ${3:return self._$1} - def fset(self, value): - ${4:self._$1 = value} -# Lambda -snippet ld - ${1:var} = lambda ${2:vars} : ${3:action} -snippet . - self. -snippet try Try/Except - try: - ${1:pass} - except ${2:Exception}, ${3:e}: - ${4:raise $3} -snippet try Try/Except/Else - try: - ${1:pass} - except ${2:Exception}, ${3:e}: - ${4:raise $3} - else: - ${5:pass} -snippet try Try/Except/Finally - try: - ${1:pass} - except ${2:Exception}, ${3:e}: - ${4:raise $3} - finally: - ${5:pass} -snippet try Try/Except/Else/Finally - try: - ${1:pass} - except ${2:Exception}, ${3:e}: - ${4:raise $3} - else: - ${5:pass} - finally: - ${6:pass} -# if __name__ == '__main__': -snippet ifmain - if __name__ == '__main__': - ${1:main()} -# __magic__ -snippet _ - __${1:init}__${2} diff --git a/vim/snippets/ruby.snippets b/vim/snippets/ruby.snippets deleted file mode 100644 index 764668f743..0000000000 --- a/vim/snippets/ruby.snippets +++ /dev/null @@ -1,490 +0,0 @@ -# #!/usr/bin/ruby -snippet #! - #!/usr/bin/ruby - -# New Block -snippet =b - =begin rdoc - ${1} - =end -snippet y - :yields: ${1:arguments} -snippet rb - #!/usr/bin/env ruby -wKU - -snippet req - require "${1}"${2} -snippet # - # => -snippet end - __END__ -snippet case - case ${1:object} - when ${2:condition} - ${3} - end -snippet when - when ${1:condition} - ${2} -snippet def - def ${1:method_name} - ${2} - end -snippet deft - def test_${1:case_name} - ${2} - end -snippet if - if ${1:condition} - ${2} - end -snippet ife - if ${1:condition} - ${2} - else - ${3} - end -snippet elsif - elsif ${1:condition} - ${2} -snippet unless - unless ${1:condition} - ${2} - end -snippet while - while ${1:condition} - ${2} - end -snippet until - until ${1:condition} - ${2} - end -snippet cla class .. end - class ${1:`substitute(Filename(), '^.', '\u&', '')`} - ${2} - end -snippet cla class .. initialize .. end - class ${1:`substitute(Filename(), '^.', '\u&', '')`} - def initialize(${2:args}) - ${3} - end - - - end -snippet cla class .. < ParentClass .. initialize .. end - class ${1:`substitute(Filename(), '^.', '\u&', '')`} < ${2:ParentClass} - def initialize(${3:args}) - ${4} - end - - - end -snippet cla ClassName = Struct .. do .. end - ${1:`substitute(Filename(), '^.', '\u&', '')`} = Struct.new(:${2:attr_names}) do - def ${3:method_name} - ${4} - end - - - end -snippet cla class BlankSlate .. initialize .. end - class ${1:BlankSlate} - instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ } -snippet cla class << self .. end - class << ${1:self} - ${2} - end -# class .. < DelegateClass .. initialize .. end -snippet cla- - class ${1:`substitute(Filename(), '^.', '\u&', '')`} < DelegateClass(${2:ParentClass}) - def initialize(${3:args}) - super(${4:del_obj}) - - ${5} - end - - - end -snippet mod module .. end - module ${1:`substitute(Filename(), '^.', '\u&', '')`} - ${2} - end -snippet mod module .. module_function .. end - module ${1:`substitute(Filename(), '^.', '\u&', '')`} - module_function - - ${2} - end -snippet mod module .. ClassMethods .. end - module ${1:`substitute(Filename(), '^.', '\u&', '')`} - module ClassMethods - ${2} - end - - module InstanceMethods - - end - - def self.included(receiver) - receiver.extend ClassMethods - receiver.send :include, InstanceMethods - end - end -# attr_reader -snippet r - attr_reader :${1:attr_names} -# attr_writer -snippet w - attr_writer :${1:attr_names} -# attr_accessor -snippet rw - attr_accessor :${1:attr_names} -# include Enumerable -snippet Enum - include Enumerable - - def each(&block) - ${1} - end -# include Comparable -snippet Comp - include Comparable - - def <=>(other) - ${1} - end -# extend Forwardable -snippet Forw- - extend Forwardable -# def self -snippet defs - def self.${1:class_method_name} - ${2} - end -# def method_missing -snippet defmm - def method_missing(meth, *args, &blk) - ${1} - end -snippet defd - def_delegator :${1:@del_obj}, :${2:del_meth}, :${3:new_name} -snippet defds - def_delegators :${1:@del_obj}, :${2:del_methods} -snippet am - alias_method :${1:new_name}, :${2:old_name} -snippet app - if __FILE__ == $PROGRAM_NAME - ${1} - end -# usage_if() -snippet usai - if ARGV.${1} - abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3} - end -# usage_unless() -snippet usau - unless ARGV.${1} - abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3} - end -snippet array - Array.new(${1:10}) { |${2:i}| ${3} } -snippet hash - Hash.new { |${1:hash}, ${2:key}| $1[$2] = ${3} } -snippet file File.foreach() { |line| .. } - File.foreach(${1:"path/to/file"}) { |${2:line}| ${3} } -snippet file File.read() - File.read(${1:"path/to/file"})${2} -snippet Dir Dir.global() { |file| .. } - Dir.glob(${1:"dir/glob/*"}) { |${2:file}| ${3} } -snippet Dir Dir[".."] - Dir[${1:"glob/**/*.rb"}]${2} -snippet dir - Filename.dirname(__FILE__) -snippet deli - delete_if { |${1:e}| ${2} } -snippet fil - fill(${1:range}) { |${2:i}| ${3} } -# flatten_once() -snippet flao - inject(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2)}${3} -snippet zip - zip(${1:enums}) { |${2:row}| ${3} } -# downto(0) { |n| .. } -snippet dow - downto(${1:0}) { |${2:n}| ${3} } -snippet ste - step(${1:2}) { |${2:n}| ${3} } -snippet tim - times { |${1:n}| ${2} } -snippet upt - upto(${1:1.0/0.0}) { |${2:n}| ${3} } -snippet loo - loop { ${1} } -snippet ea - each { |${1:e}| ${2} } -snippet eab - each_byte { |${1:byte}| ${2} } -snippet eac- each_char { |chr| .. } - each_char { |${1:chr}| ${2} } -snippet eac- each_cons(..) { |group| .. } - each_cons(${1:2}) { |${2:group}| ${3} } -snippet eai - each_index { |${1:i}| ${2} } -snippet eak - each_key { |${1:key}| ${2} } -snippet eal - each_line { |${1:line}| ${2} } -snippet eap - each_pair { |${1:name}, ${2:val}| ${3} } -snippet eas- - each_slice(${1:2}) { |${2:group}| ${3} } -snippet eav - each_value { |${1:val}| ${2} } -snippet eawi - each_with_index { |${1:e}, ${2:i}| ${3} } -snippet reve - reverse_each { |${1:e}| ${2} } -snippet inj - inject(${1:init}) { |${2:mem}, ${3:var}| ${4} } -snippet map - map { |${1:e}| ${2} } -snippet mapwi- - enum_with_index.map { |${1:e}, ${2:i}| ${3} } -snippet sor - sort { |a, b| ${1} } -snippet sorb - sort_by { |${1:e}| ${2} } -snippet ran - sort_by { rand } -snippet all - all? { |${1:e}| ${2} } -snippet any - any? { |${1:e}| ${2} } -snippet cl - classify { |${1:e}| ${2} } -snippet col - collect { |${1:e}| ${2} } -snippet det - detect { |${1:e}| ${2} } -snippet fet - fetch(${1:name}) { |${2:key}| ${3} } -snippet fin - find { |${1:e}| ${2} } -snippet fina - find_all { |${1:e}| ${2} } -snippet gre - grep(${1:/pattern/}) { |${2:match}| ${3} } -snippet sub - ${1:g}sub(${2:/pattern/}) { |${3:match}| ${4} } -snippet sca - scan(${1:/pattern/}) { |${2:match}| ${3} } -snippet max - max { |a, b| ${1} } -snippet min - min { |a, b| ${1} } -snippet par - partition { |${1:e}| ${2} } -snippet rej - reject { |${1:e}| ${2} } -snippet sel - select { |${1:e}| ${2} } -snippet lam - lambda { |${1:args}| ${2} } -snippet do - do |${1:variable}| - ${2} - end -snippet : - :${1:key} => ${2:"value"}${3} -snippet ope - open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${4} } -# path_from_here() -snippet patfh - File.join(File.dirname(__FILE__), *%2[${1:rel path here}])${2} -# unix_filter {} -snippet unif - ARGF.each_line${1} do |${2:line}| - ${3} - end -# option_parse {} -snippet optp - require "optparse" - - options = {${1:default => "args"}} - - ARGV.options do |opts| - opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} -snippet opt - opts.on( "-${1:o}", "--${2:long-option-name}", ${3:String}, - "${4:Option description.}") do |${5:opt}| - ${6} - end -snippet ts - require "test/unit" - - require "tc_${1:test_case_file}" - require "tc_${2:test_case_file}"${3} -snippet as - assert(${1:test}, "${2:Failure message.}")${3} -snippet ase - assert_equal(${1:expected}, ${2:actual})${3} -snippet asne - assert_not_equal(${1:unexpected}, ${2:actual})${3} -snippet asid - assert_in_delta(${1:expected_float}, ${2:actual_float}, ${3:2 ** -20})${4} -snippet asio - assert_instance_of(${1:ExpectedClass}, ${2:actual_instance})${3} -snippet asko - assert_kind_of(${1:ExpectedKind}, ${2:actual_instance})${3} -snippet asn - assert_nil(${1:instance})${2} -snippet asnn - assert_not_nil(${1:instance})${2} -snippet asm - assert_match(/${1:expected_pattern}/, ${2:actual_string})${3} -snippet asnm - assert_no_match(/${1:unexpected_pattern}/, ${2:actual_string})${3} -snippet aso - assert_operator(${1:left}, :${2:operator}, ${3:right})${4} -snippet asr - assert_raise(${1:Exception}) { ${2} } -snippet asnr - assert_nothing_raised(${1:Exception}) { ${2} } -snippet asrt - assert_respond_to(${1:object}, :${2:method})${3} -snippet ass assert_same(..) - assert_same(${1:expected}, ${2:actual})${3} -snippet ass assert_send(..) - assert_send([${1:object}, :${2:message}, ${3:args}])${4} -snippet asns - assert_not_same(${1:unexpected}, ${2:actual})${3} -snippet ast - assert_throws(:${1:expected}) { ${2} } -snippet asnt - assert_nothing_thrown { ${1} } -snippet fl - flunk("${1:Failure message.}")${2} -# Benchmark.bmbm do .. end -snippet bm- - TESTS = ${1:10_000} - Benchmark.bmbm do |results| - ${2} - end -snippet rep - results.report("${1:name}:") { TESTS.times { ${2} }} -# Marshal.dump(.., file) -snippet Md - File.open(${1:"path/to/file.dump"}, "wb") { |${2:file}| Marshal.dump(${3:obj}, $2) }${4} -# Mashal.load(obj) -snippet Ml - File.open(${1:"path/to/file.dump"}, "rb") { |${2:file}| Marshal.load($2) }${3} -# deep_copy(..) -snippet deec - Marshal.load(Marshal.dump(${1:obj_to_copy}))${2} -snippet Pn- - PStore.new(${1:"file_name.pstore"})${2} -snippet tra - transaction(${1:true}) { ${2} } -# xmlread(..) -snippet xml- - REXML::Document.new(File.read(${1:"path/to/file"}))${2} -# xpath(..) { .. } -snippet xpa - elements.each(${1:"//Xpath"}) do |${2:node}| - ${3} - end -# class_from_name() -snippet clafn - split("::").inject(Object) { |par, const| par.const_get(const) } -# singleton_class() -snippet sinc - class << self; self end -snippet nam - namespace :${1:`Filename()`} do - ${2} - end -snippet tas - desc "${1:Task description\}" - task :${2:task_name => [:dependent, :tasks]} do - ${3} - end - -# My additions -snippet ed - each do |${1:e}| - ${2} - end -snippet defp - def ${1:method_name}(${2:params}) - ${3} - end -snippet inst - institution${1} -snippet acti - activation_group${1} -snippet prot - protocol${1} -# -# For rspec -snippet desc - describe "${1}" do - ${2} - end -snippet it - it "${1}" do - ${2} - end -snippet con - context "${1}" do - ${2} - end -snippet bed - before do - ${1} - end -snippet cont - context "${1}" do - ${2} - end -snippet spec - require "rails_helper" - - describe ${1} do - ${2} - end -snippet hc - expect(page).to have_content(${1}) -snippet F - Factory(:${1}) -snippet cuke - "([^"]*)" ${1} -snippet let - let(:${1}) { ${2} } -snippet letb - let!(:${1}) { ${2} } -snippet puts - puts "\n\n************ #{${1}} **************\n\n" -snippet mm - def method_missing(method, *args, &block) - @target.send(method, *args, &block) - end -snippet defi - def initialize(${1}) - ${2} - end -snippet ex - expect(${1}).to ${2} -snippet scen - scenario "${1}" do - ${2} - end -snippet save - save_and_open_page -snippet rrh - require "rails_helper" -snippet feat - feature "${1}" do - scenario "${2}" do - ${3} - end - end diff --git a/vim/snippets/sh.snippets b/vim/snippets/sh.snippets deleted file mode 100644 index f035126eec..0000000000 --- a/vim/snippets/sh.snippets +++ /dev/null @@ -1,28 +0,0 @@ -# #!/bin/bash -snippet #! - #!/bin/bash - -snippet if - if [[ ${1:condition} ]]; then - ${2:#statements} - fi -snippet elif - elif [[ ${1:condition} ]]; then - ${2:#statements} -snippet for - for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do - ${3:#statements} - done -snippet wh - while [[ ${1:condition} ]]; do - ${2:#statements} - done -snippet until - until [[ ${1:condition} ]]; do - ${2:#statements} - done -snippet case - case ${1:word} in - ${2:pattern}) - ${3};; - esac diff --git a/vim/snippets/snippet.snippets b/vim/snippets/snippet.snippets deleted file mode 100644 index 854c058202..0000000000 --- a/vim/snippets/snippet.snippets +++ /dev/null @@ -1,7 +0,0 @@ -# snippets for making snippets :) -snippet snip - snippet ${1:trigger} - ${2} -snippet msnip - snippet ${1:trigger} ${2:description} - ${3} diff --git a/vim/snippets/tcl.snippets b/vim/snippets/tcl.snippets deleted file mode 100644 index 1fe1cb960e..0000000000 --- a/vim/snippets/tcl.snippets +++ /dev/null @@ -1,92 +0,0 @@ -# #!/usr/bin/env tclsh -snippet #! - #!/usr/bin/env tclsh - -# Process -snippet pro - proc ${1:function_name} {${2:args}} { - ${3:#body ...} - } -#xif -snippet xif - ${1:expr}? ${2:true} : ${3:false} -# Conditional -snippet if - if {${1}} { - ${2:# body...} - } -# Conditional if..else -snippet ife - if {${1}} { - ${2:# body...} - } else { - ${3:# else...} - } -# Conditional if..elsif..else -snippet ifee - if {${1}} { - ${2:# body...} - } elseif {${3}} { - ${4:# elsif...} - } else { - ${5:# else...} - } -# If catch then -snippet ifc - if { [catch {${1:#do something...}} ${2:err}] } { - ${3:# handle failure...} - } -# Catch -snippet catch - catch {${1}} ${2:err} ${3:options} -# While Loop -snippet wh - while {${1}} { - ${2:# body...} - } -# For Loop -snippet for - for {set ${2:var} 0} {$$2 < ${1:count}} {${3:incr} $2} { - ${4:# body...} - } -# Foreach Loop -snippet fore - foreach ${1:x} {${2:#list}} { - ${3:# body...} - } -# after ms script... -snippet af - after ${1:ms} ${2:#do something} -# after cancel id -snippet afc - after cancel ${1:id or script} -# after idle -snippet afi - after idle ${1:script} -# after info id -snippet afin - after info ${1:id} -# Expr -snippet exp - expr {${1:#expression here}} -# Switch -snippet sw - switch ${1:var} { - ${3:pattern 1} { - ${4:#do something} - } - default { - ${2:#do something} - } - } -# Case -snippet ca - ${1:pattern} { - ${2:#do something} - }${3} -# Namespace eval -snippet ns - namespace eval ${1:path} {${2:#script...}} -# Namespace current -snippet nsc - namespace current diff --git a/vim/snippets/tex.snippets b/vim/snippets/tex.snippets deleted file mode 100644 index 22f7316532..0000000000 --- a/vim/snippets/tex.snippets +++ /dev/null @@ -1,115 +0,0 @@ -# \begin{}...\end{} -snippet begin - \begin{${1:env}} - ${2} - \end{$1} -# Tabular -snippet tab - \begin{${1:tabular}}{${2:c}} - ${3} - \end{$1} -# Align(ed) -snippet ali - \begin{align${1:ed}} - ${2} - \end{align$1} -# Gather(ed) -snippet gat - \begin{gather${1:ed}} - ${2} - \end{gather$1} -# Equation -snippet eq - \begin{equation} - ${1} - \end{equation} -# Unnumbered Equation -snippet \ - \\[ - ${1} - \\] -# Enumerate -snippet enum - \begin{enumerate} - \item ${1} - \end{enumerate} -# Itemize -snippet item - \begin{itemize} - \item ${1} - \end{itemize} -# Description -snippet desc - \begin{description} - \item[${1}] ${2} - \end{description} -# Matrix -snippet mat - \begin{${1:p/b/v/V/B/small}matrix} - ${2} - \end{$1matrix} -# Cases -snippet cas - \begin{cases} - ${1:equation}, &\text{ if }${2:case}\\ - ${3} - \end{cases} -# Split -snippet spl - \begin{split} - ${1} - \end{split} -# Part -snippet part - \part{${1:part name}} % (fold) - \label{prt:${2:$1}} - ${3} - % part $2 (end) -# Chapter -snippet cha - \chapter{${1:chapter name}} % (fold) - \label{cha:${2:$1}} - ${3} - % chapter $2 (end) -# Section -snippet sec - \section{${1:section name}} % (fold) - \label{sec:${2:$1}} - ${3} - % section $2 (end) -# Sub Section -snippet sub - \subsection{${1:subsection name}} % (fold) - \label{sub:${2:$1}} - ${3} - % subsection $2 (end) -# Sub Sub Section -snippet subs - \subsubsection{${1:subsubsection name}} % (fold) - \label{ssub:${2:$1}} - ${3} - % subsubsection $2 (end) -# Paragraph -snippet par - \paragraph{${1:paragraph name}} % (fold) - \label{par:${2:$1}} - ${3} - % paragraph $2 (end) -# Sub Paragraph -snippet subp - \subparagraph{${1:subparagraph name}} % (fold) - \label{subp:${2:$1}} - ${3} - % subparagraph $2 (end) -snippet itd - \item[${1:description}] ${2:item} -snippet figure - ${1:Figure}~\ref{${2:fig:}}${3} -snippet table - ${1:Table}~\ref{${2:tab:}}${3} -snippet listing - ${1:Listing}~\ref{${2:list}}${3} -snippet section - ${1:Section}~\ref{${2:sec:}}${3} -snippet page - ${1:page}~\pageref{${2}}${3} diff --git a/vim/snippets/vim.snippets b/vim/snippets/vim.snippets deleted file mode 100644 index 64e7807eb4..0000000000 --- a/vim/snippets/vim.snippets +++ /dev/null @@ -1,32 +0,0 @@ -snippet header - " File: ${1:`expand('%:t')`} - " Author: ${2:`g:snips_author`} - " Description: ${3} - ${4:" Last Modified: `strftime("%B %d, %Y")`} -snippet guard - if exists('${1:did_`Filename()`}') || &cp${2: || version < 700} - finish - endif - let $1 = 1${3} -snippet f - fun ${1:function_name}(${2}) - ${3:" code} - endf -snippet for - for ${1:needle} in ${2:haystack} - ${3:" code} - endfor -snippet wh - while ${1:condition} - ${2:" code} - endw -snippet if - if ${1:condition} - ${2:" code} - endif -snippet ife - if ${1:condition} - ${2} - else - ${3} - endif diff --git a/vim/snippets/zsh.snippets b/vim/snippets/zsh.snippets deleted file mode 100644 index 7aee05bd24..0000000000 --- a/vim/snippets/zsh.snippets +++ /dev/null @@ -1,58 +0,0 @@ -# #!/bin/zsh -snippet #! - #!/bin/zsh - -snippet if - if ${1:condition}; then - ${2:# statements} - fi -snippet ife - if ${1:condition}; then - ${2:# statements} - else - ${3:# statements} - fi -snippet elif - elif ${1:condition} ; then - ${2:# statements} -snippet for - for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do - ${3:# statements} - done -snippet fore - for ${1:item} in ${2:list}; do - ${3:# statements} - done -snippet wh - while ${1:condition}; do - ${2:# statements} - done -snippet until - until ${1:condition}; do - ${2:# statements} - done -snippet repeat - repeat ${1:integer}; do - ${2:# statements} - done -snippet case - case ${1:word} in - ${2:pattern}) - ${3};; - esac -snippet select - select ${1:answer} in ${2:choices}; do - ${3:# statements} - done -snippet ( - ( ${1:#statements} ) -snippet { - { ${1:#statements} } -snippet [ - [[ ${1:test} ]] -snippet always - { ${1:try} } always { ${2:always} } -snippet fun - function ${1:name} (${2:args}) { - ${3:# body} - } diff --git a/vim/spell/en.utf-8.add b/vim/spell/en.utf-8.add index fe1c23d866..0c4f9d636a 100644 --- a/vim/spell/en.utf-8.add +++ b/vim/spell/en.utf-8.add @@ -2,3 +2,8 @@ Upcase www screenshot UX +scalability +scalable +precompute +precomputation +lifecycle diff --git a/vim/spell/en.utf-8.add.spl b/vim/spell/en.utf-8.add.spl index 626be424c4..08cb9658d1 100644 Binary files a/vim/spell/en.utf-8.add.spl and b/vim/spell/en.utf-8.add.spl differ diff --git a/vimrc b/vimrc index 643fb41e1e..d51b428958 100644 --- a/vimrc +++ b/vimrc @@ -9,36 +9,72 @@ set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " let Vundle manage Vundle, required +Plugin 'Quramy/tsuquyomi' +Plugin 'leafgarland/typescript-vim' Plugin 'gmarik/Vundle.vim' - -" My bundles Plugin 'elixir-lang/vim-elixir' Plugin 'ervandew/supertab' -Plugin 'kchmck/vim-coffee-script' Plugin 'koron/nyancat-vim' -Plugin 'skwp/greplace.vim' Plugin 'tomtom/tcomment_vim' -Plugin 'tpope/vim-bundler' -Plugin 'tpope/vim-cucumber' -Plugin 'tpope/vim-dispatch' -Plugin 'tpope/vim-endwise' -Plugin 'tpope/vim-fugitive' +Plugin 'vim-ruby/vim-ruby' +Plugin 'pangloss/vim-javascript' +Plugin 'udalov/kotlin-vim' +" Plugin 'wincent/Command-T' +Plugin 'scrooloose/nerdtree' +Plugin 'LaTeX-Box-Team/LaTeX-Box' +Plugin 'kien/ctrlp.vim' +Plugin 'kongo2002/fsharp-vim' +Plugin 'kchmck/vim-coffee-script' +Plugin 'mustache/vim-mustache-handlebars' +Plugin 'ngmy/vim-rubocop' +Plugin 'godlygeek/tabular' +Plugin 'ecomba/vim-ruby-refactoring' Plugin 'tpope/vim-rails' -Plugin 'tpope/vim-repeat' Plugin 'tpope/vim-surround' -Plugin 'tpope/vim-unimpaired' -Plugin 'vim-ruby/vim-ruby' -Plugin 'wincent/Command-T' +Plugin 'tpope/vim-fugitive' +Plugin 'slim-template/vim-slim' +Plugin 'geoffharcourt/vim-matchit' +Plugin 'Townk/vim-autoclose' +Plugin 'rizzatti/dash.vim' +Plugin 'keith/swift.vim' +Plugin 'vim-scripts/groovy.vim' +Plugin 'tpope/tpope-vim-abolish' + +Plugin 'honza/vim-snippets' " nelstrom's plugin depends on kana's Plugin 'kana/vim-textobj-user' Plugin 'nelstrom/vim-textobj-rubyblock' +Plugin 'andreshazard/vim-freemarker' + +" UI Plugins +Plugin 'bling/vim-airline' " UI statusbar niceties +Plugin 'vim-airline/vim-airline-themes' +set laststatus=2 " enable airline even if no splits +let g:airline_theme='luna' +let g:airline_powerline_fonts = 1 +let g:airline_left_sep = '' +let g:airline_right_sep = '' +let g:airline#extensions#tabline#enabled = 1 +" let g:airline#extensions#syntastic#enabled = 1 +let g:airline#branch#enabled = 1 + +" Ctrl-p configurations +let g:ctrlp_custom_ignore = { + \ 'dir': '\v(node_modules|bower_components|dist|deps|_build|build)', + \ 'file': '\v\.(pyc)$', + \ } + +" Cache in Ctrl-p +" let g:ctrlp_cache_dir = $HOME . '/.cache/ctrlp' +" if executable('ag') +" let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' +" endif + +" NERDTree configuration +let NERDTreeIgnore = ['\.pyc$', '*.egg-info', '__pycache__/*'] +let NERDTreeRespectWildIgnore=1 -" Clojure -Plugin 'guns/vim-clojure-static' -Plugin 'tpope/vim-classpath' -Plugin 'tpope/vim-fireplace' -Plugin 'tpope/vim-leiningen' " Colors Plugin 'nanotech/jellybeans.vim' @@ -46,333 +82,167 @@ Plugin 'nanotech/jellybeans.vim' " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required +filetype plugin on " Use the colorscheme from above colorscheme jellybeans " ======================================================================== -" Ruby stuff +" Settings (things with set) " ======================================================================== -syntax on " Enable syntax highlighting -filetype plugin indent on " Enable filetype-specific indenting and plugins - -augroup myfiletypes - " Clear old autocmds in group - autocmd! - " autoindent with two spaces, always expand tabs - autocmd FileType ruby,eruby,yaml setlocal ai sw=2 sts=2 et - autocmd FileType ruby,eruby,yaml setlocal path+=lib - autocmd FileType ruby,eruby,yaml setlocal colorcolumn=80 - " Make ?s part of words - autocmd FileType ruby,eruby,yaml setlocal iskeyword+=? - - " Clojure - autocmd FileType clojure setlocal colorcolumn=80 - autocmd FileType clojure map t :!lein test % -augroup END - -" Enable built-in matchit plugin -runtime macros/matchit.vim -" ================ -let mapleader = "," +set autoindent " autoindent on linebreak +set ts=2 sts=2 sw=2 expandtab " Tab settings +set shiftround " When at 3 spaces and I hit >>, go to 4, not 5. +set history=500 " keep 500 lines of command line history +set showcmd " display incomplete commands +set ruler " show the cursor position all the time +set incsearch " do incremental searching +set nohlsearch " Stop highlihgt search after something -... +set backupdir=~/.tmp +set directory=~/.tmp +set timeoutlen=500 " Less leader timeout +set cc=80 " Display line at 80 chars -map ac :sp app/controllers/application_controller.rb -vmap b :!git blame =expand("%:p") \| sed -n =line("'<") ,=line("'>") p -map bb :!bundle install -nmap bi :source ~/.vimrc:PluginInstall -vmap bed "td?describeobed"tpkdd/endo:nohl -map cc :!cucumber --drb % -map cu :Tabularize /\| -map co ggVG"*y -map cc :Rjcollection client/ -map cj :Rjspec client/ -map cm :Rjmodel client/ -map cs :call SearchForCallSitesCursor() -map ct :Rtemplate client/ -map cv :Rjview client/ -map cn :e ~/Dropbox/notes/coding-notes.txt -map d orequire 'pry'binding.pry:w -map dr :e ~/Dropbox -map dj :e ~/Dropbox/notes/debugging_journal.txt -map ec :e ~/code/ -map g :Start gitsh -map gw :!git add . && git commit -m 'WIP' && git push -map f :call OpenFactoryFile() -map fix :cnoremap % % -map fa :sp test/factories.rb -map h :CommandT -map i mmgg=G`m -map l oconsole.log 'debugging':w -map m :Rmodel -map nn :sp ~/Dropbox/notes/programming_notes.txt -map nt :e! ~/Dropbox/docs/trailmix/todo.md -map o :w:call RunCurrentLineInTest() -map p :set pasteo"*]p:set nopaste -map pn :sp ~/Dropbox/work/thoughtbot/notes/project-notes.txt -map ra :%s/ -map rd :!bundle exec rspec % --format documentation -map rf :CommandTFlush:CommandT -map rs :vsp #w -map rt q:?!ruby -map rw :%s/\s\+$//:w -map sc :sp db/schema.rb -map sg :sp:grep -map sj :call OpenJasmineSpecInBrowser() -map sm :RSmodel -map sp yss

-map sn :e ~/.vim/snippets/ruby.snippets -map so :so % -map sq j}klllcs:wq -map ss ds)i :w -map st :!ruby -Itest % -n "//" -map su :RSunittest -map sv :RSview -map t :w:call RunCurrentTest() -map y :!rspec --drb % -map u :Runittest -map vc :RVcontroller -map vf :RVfunctional -map vg :vsp:grep -map vi :tabe ~/.vimrc -map vu :RVunittest -map vm :RVmodel -map vv :RVview -map w w -map x :exec getline(".") +" Don't add the comment prefix when I hit enter or o/O on a comment line. +set formatoptions-=or +set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.egg-info,*.git,/node_modules/*,/bower_components/* -" Edit another file in the same directory as the current file -" uses expression to extract path from current file's path -map e :e =escape(expand("%:p:h"),' ') . '/' -map s :split =escape(expand("%:p:h"), ' ') . '/' -map v :vnew =escape(expand("%:p:h"), ' ') . '/' +" LaTeX ignores +set wildignore+=*.aux,*.blg,*.out,*.toc,*.bbl -map :nohl -imap : -" Note that remapping C-s requires flow control to be disabled -" (e.g. in .bashrc or .zshrc) -map :w -imap :w -map :tabnew -map c -map :cn -map :cp - -" Emacs-like beginning and end of line. -imap $ -imap ^ +" Readable highlight text +highlight PmenuSel ctermfg=black -set backspace=indent,eol,start " allow backspacing over everything in insert mode -set history=500 " keep 500 lines of command line history -set ruler " show the cursor position all the time -set showcmd " display incomplete commands -set autoindent -set showmatch +" Set gutter background to black +highlight SignColumn ctermbg=black + +" Use Silver Searcher for 'grepping' +set grepprg=ag +let g:ackprg = 'ag --vimgrep' + +" set list listchars=tab:»·,trail:· +syntax on " syntax highlighting + +" Make it more obvious which paren I'm on +hi MatchParen cterm=none ctermbg=black ctermfg=yellow + +" By default, vim thinks .md is Modula-2. +autocmd BufNewFile,BufReadPost *.md set filetype=markdown +autocmd BufNewFile,BufReadPost Jenkinsfile set filetype=groovy +autocmd BufNewFile,BufReadPost *.es6 set filetype=javascript +autocmd BufNewFile,BufReadPost *.j2 set filetype=yaml + +" Spell checker on these files +autocmd BufRead,BufNewFile *.md setlocal spell +autocmd BufRead,BufNewFile *.tex setlocal spell +set complete+=kspell + +" Set Gradle syntax +au BufNewFile,BufRead *.gradle setf groovy + +" Read upon: +" Better? completion on command line +set wildmenu +" What to do when I press 'wildchar'. Worth tweaking to see what feels right. +set wildmode=list:full set nowrap -set backupdir=~/.tmp -set directory=~/.tmp " Don't clutter my dirs up with swp and tmp files +set backspace=indent,eol,start " allow backspacing over everything in insert mode set autoread set wmh=0 set viminfo+=! set guioptions-=T set guifont=Triskweline_10:h10 set et -set sw=2 set smarttab set noincsearch set ignorecase smartcase set laststatus=2 " Always show status line. -set relativenumber +set number set gdefault " assume the /g flag on :s substitutions to replace all matches in a line set autoindent " always set autoindenting on -set bg=light - -" Set the tag file search order set tags=./tags; - -" Use _ as a word-separator -" set iskeyword-=_ - -" Use Silver Searcher instead of grep -set grepprg=ag - -" Make the omnicomplete text readable -:highlight PmenuSel ctermfg=black - -" Fuzzy finder: ignore stuff that can't be opened, and generated files -let g:fuzzy_ignore = "*.png;*.PNG;*.JPG;*.jpg;*.GIF;*.gif;vendor/**;coverage/**;tmp/**;rdoc/**" - -" Highlight the status line highlight StatusLine ctermfg=blue ctermbg=yellow - -" Format xml files -au FileType xml exe ":silent 1,$!xmllint --format --recover - 2>/dev/null" - -set shiftround " When at 3 spaces and I hit >>, go to 4, not 5. - set nofoldenable " Say no to code folding... -command! Q q " Bind :Q to :q -command! Qall qall - - -" Disable Ex mode -map Q - -" Disable K looking stuff up -map K - -au BufNewFile,BufRead *.txt setlocal nolist " Don't display whitespace - -" Better? completion on command line -set wildmenu -" What to do when I press 'wildchar'. Worth tweaking to see what feels right. -set wildmode=list:full - -" (Hopefully) removes the delay when hitting esc in insert mode -set noesckeys -set ttimeout -set ttimeoutlen=1 - -" Turn on spell-checking in markdown and text. -" au BufRead,BufNewFile *.md,*.txt setlocal spell - -" Merge a tab into a split in the previous window -function! MergeTabs() - if tabpagenr() == 1 - return - endif - let bufferName = bufname("%") - if tabpagenr("$") == tabpagenr() - close! - else - close! - tabprev - endif - split - execute "buffer " . bufferName -endfunction - -nmap u :call MergeTabs() - +" ======================================================================== +" Mappings +" ======================================================================== +let mapleader = "," -" Squash all commits into the first during rebase -function! SquashAll() - normal ggj}klllcf:w -endfunction +vmap b :!git blame =expand("%:p") \| sed -n =line("'<") ,=line("'>") p +map bb :!bundle install +map eb :!mix deps.get +nmap bi :source ~/.vimrc:PluginInstall +nmap d DashSearch +map st :source % +map sv :source ~/.vimrc +" map d orequire 'pry'binding.pry:w +map ra :%s/ +map rd :!bundle exec rspec % --format documentation +map rt :!ruby -Ilib:test % +map pt :!py.test +map ptf :!py.test -c pytest-fast.ini +map mt :!mix test % +map np :set nopaste :retab +map p :set paste +map rf :CommandTFlush:CommandT +map rw :%s/\s\+$//:w +map :%s/\s\+$//:w +map :NERDTreeToggle +" Edit another file in the same directory as the current file +" uses expression to extract path from current file's path +map e :e =escape(expand("%:p:h"),' ') . '/' +map s :split =escape(expand("%:p:h"), ' ') . '/' +map v :vnew =escape(expand("%:p:h"), ' ') . '/' +map stt :%retab! +map j :%!python -m json.tool +" Beginning and end of files as in terminal +imap $ +imap ^ -function! SearchForCallSitesCursor() - let searchTerm = expand("") - call SearchForCallSites(searchTerm) -endfunction +" Ruby refactoring +nnoremap rap :RAddParameter +nnoremap rcpc :RConvertPostConditional +nnoremap rel :RExtractLet +vnoremap rec :RExtractConstant +vnoremap relv :RExtractLocalVariable +nnoremap rit :RInlineTemp +vnoremap rrlv :RRenameLocalVariable +vnoremap rriv :RRenameInstanceVariable +vnoremap rem :RExtractMethod +vnoremap // y/"" + +" Rubocop +let g:vimrubocop_keymap = 0 +map rc :RuboCop + +" Tabularize +nmap a= :Tabularize /= +vmap a= :Tabularize /= +" nmap a: :Tabularize /:\zs +" vmap a: :Tabularize /:\zs -" Search for call sites for term (excluding its definition) and -" load into the quickfix list. -function! SearchForCallSites(term) - cexpr system('ag ' . shellescape(a:term) . '\| grep -v def') -endfunction """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Test-running stuff +" Strip Trailing Whitespaces (from VimCast.org) """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -function! RunCurrentTest() - let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\|_test.rb\)$') != -1 - if in_test_file - call SetTestFile() - - if match(expand('%'), '\.feature$') != -1 - call SetTestRunner("!bin/cucumber") - exec g:bjo_test_runner g:bjo_test_file - elseif match(expand('%'), '_spec\.rb$') != -1 - call SetTestRunner("!bin/rspec") - exec g:bjo_test_runner g:bjo_test_file - else - call SetTestRunner("!ruby -Itest") - exec g:bjo_test_runner g:bjo_test_file - endif - else - exec g:bjo_test_runner g:bjo_test_file - endif -endfunction - -function! SetTestRunner(runner) - let g:bjo_test_runner=a:runner -endfunction - -function! RunCurrentLineInTest() - let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\|_test.rb\)$') != -1 - if in_test_file - call SetTestFileWithLine() - end - - exec "!bin/rspec" g:bjo_test_file . ":" . g:bjo_test_file_line -endfunction - -function! SetTestFile() - let g:bjo_test_file=@% -endfunction - -function! SetTestFileWithLine() - let g:bjo_test_file=@% - let g:bjo_test_file_line=line(".") -endfunction - -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -inoremap - -" Let's be reasonable, shall we? -nmap k gk -nmap j gj - - -" Set up some useful Rails.vim bindings for working with Backbone.js -autocmd User Rails Rnavcommand template app/assets/templates -glob=**/* -suffix=.jst.ejs -autocmd User Rails Rnavcommand jmodel app/assets/javascripts/models -glob=**/* -suffix=.coffee -autocmd User Rails Rnavcommand jview app/assets/javascripts/views -glob=**/* -suffix=.coffee -autocmd User Rails Rnavcommand jcollection app/assets/javascripts/collections -glob=**/* -suffix=.coffee -autocmd User Rails Rnavcommand jrouter app/assets/javascripts/routers -glob=**/* -suffix=.coffee -autocmd User Rails Rnavcommand jspec spec/javascripts -glob=**/* -suffix=.coffee - -" Don't add the comment prefix when I hit enter or o/O on a comment line. -set formatoptions-=or - - -function! OpenJasmineSpecInBrowser() - let filename = expand('%') - " substitute(exprsson, pattern, substitution, flags) - let url_fragment = substitute(filename, "spec/javascripts", "evergreen/run", "") - let host_fragment = "http://localhost:3001/" - let url = host_fragment . url_fragment - silent exec "!open ~/bin/chrome" url -endfunction - -" set statusline+=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P - -let g:CommandTMaxHeight=50 -let g:CommandTMatchWindowAtTop=1 - -" Don't wait so long for the next keypress (particularly in ambigious Leader -" situations. -set timeoutlen=500 - -" Don't go past 100 chars on levelup: -autocmd BufNewFile,BufRead /Users/ben/code/levelup/*.rb set colorcolumn=100 - -" Remove trailing whitespace on save for ruby files. -au BufWritePre *.rb :%s/\s\+$//e - -function! OpenFactoryFile() - if filereadable("test/factories.rb") - execute ":sp test/factories.rb" - else - execute ":sp spec/factories.rb" - end +function! StripTrailingWhitespaces() + " Preparation: save last search, and cursor position. + let _s=@/ + let l = line(".") + let c = col(".") + " Do the business: + %s/\s\+$//e + " Clean up: restore previous search history, and cursor position + let @/=_s + call cursor(l, c) endfunction -" Set gutter background to black -highlight SignColumn ctermbg=black +if has("autocmd") + autocmd BufWritePre * :call StripTrailingWhitespaces() +end """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " RENAME CURRENT FILE (thanks Gary Bernhardt) @@ -388,8 +258,17 @@ function! RenameFile() endfunction map n :call RenameFile() -" Display extra whitespace -set list listchars=tab:»·,trail:· +" ======================================================================== +" End of things set by me. +" ======================================================================== + +" ======================================================================== +" Stuff from the vim example file +" ======================================================================== + +if has('mouse') + set mouse=a +endif " Switch syntax highlighting on, when the terminal has colors " Also switch on highlighting the last used search pattern. @@ -398,16 +277,6 @@ if &t_Co > 2 || has("gui_running") set hlsearch endif -" Make it more obvious which paren I'm on -hi MatchParen cterm=none ctermbg=black ctermfg=yellow - -" By default, vim thinks .md is Modula-2. -autocmd BufNewFile,BufReadPost *.md set filetype=markdown - -" ======================================================================== -" End of things set by me. -" ======================================================================== - " Only do this part when compiled with support for autocommands. if has("autocmd") @@ -421,12 +290,17 @@ if has("autocmd") augroup vimrcEx au! + " For all text files set 'textwidth' to 78 characters. + autocmd FileType text setlocal textwidth=78 + " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). + " Also don't do it when the mark is in the first line, that is the default + " position when opening a file. autocmd BufReadPost * - \ if line("'\"") > 0 && line("'\"") <= line("$") | - \ exe "normal g`\"" | + \ if line("'\"") > 1 && line("'\"") <= line("$") | + \ exe "normal! g`\"" | \ endif augroup END diff --git a/zlogin b/zlogin deleted file mode 100644 index e027d90fdb..0000000000 --- a/zlogin +++ /dev/null @@ -1,7 +0,0 @@ -# go to saved path if there is one -if [[ -f ~/.current_path~ ]]; then - cd `cat ~/.current_path~` - rm ~/.current_path~ -fi - -[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* diff --git a/zsh/aliases b/zsh/aliases index 1d3da69cfb..33ced58ce4 100644 --- a/zsh/aliases +++ b/zsh/aliases @@ -1,143 +1,69 @@ -# Handle the fact that this file will be used with multiple OSs -platform=`uname` -if [[ $platform == 'Linux' ]]; then - alias a='ls -lrth --color' -elif [[ $platform == 'Darwin' ]]; then - alias a='ls -lrthG' -fi - -alias ack='ag' -alias amend="git commit --amend" -alias asu="cd ~/code/rails/activesupport" +# UNIX alias aliases='vim ~/.dotfiles/zsh/aliases' -alias b='bin/rspec' -alias bake='bundle exec rake' -alias be='bundle exec' -alias ben='ssh ben@benorenstein.com' -alias bi='bundle install -j 8' -alias be='bundle exec' -alias bo='cd ~/code/boardwalk' -alias br='bin/rspec' -alias bu='bundle update' -alias bunbang='bundle install && !!' -alias c='cd' -alias cc='cd ~/Dropbox/freelancing/code-climate' -alias chad='vim ~/Dropbox/work/thoughtbot/notes/1-1s/chad.txt' -alias code='cd ~/code' -alias codereview='vim ~/Dropbox/notes/code-review-checklist.txt' -alias d='cd ~/.dotfiles' -alias dbprep='rdm && rdtp' -alias di='cd ~/code/discourse' -alias dr='cd ~/Dropbox' +alias dot='cd ~/.dotfiles' alias drop='cd ~/Dropbox' -alias edwin='vim ~/Dropbox/work/thoughtbot/notes/1-1s/edwin.txt' -alias fs='foreman start' -alias -g G='| grep' +alias so='source ~/.zshrc' +alias uuid="uuidgen | tr '[:upper:]' '[:lower:]'" +alias cuuid="uuid | pbcopy" +alias prettyjson='python3 -m json.tool' +alias jsonvim='prettyjson | vim -c "set syntax=json" -' +alias jsonless='prettyjson | less' +alias cleardns="sudo killall -HUP mDNSResponder" +alias jobdone="terminal-notifier -message \"Job's done\"" +alias csvtojson="python3 -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))'" + +# Vim +alias v='vim' +alias vi='vim' + +# Tmux +alias ts="tmux list-sessions" +alias ta="tmux attach -t" +alias tkill="tmux kill-session -t" +alias mux="tmuxinator" +alias tmk="tmux kill-session -t" +alias tma="tmux attach -t" +alias ms="mux start" + +# Docker +alias dc='docker-compose' +alias docklog="docker logs --follow" + +# Git +alias gs="git status" +alias gp="git add . -p" +alias gn="git add . -N" +alias gf="git commit --fixup" alias gad='git add --all .' -alias gbc='gdc' -alias gca='git commit -a' -alias gcaa='git commit -a --amend -C HEAD' -alias gcl='git clone' +alias tmp="git add . -A && git commit -m 'TMP'" +alias wip="git add . -A && git commit -m 'WIP'" +alias gcall="git add . -A && git commit -m" +alias gpo="git push origin master" +alias glo="git pull origin master" +alias gpu="git push upstream" +alias glu="git pull upstream master" alias gcm="git commit -m" alias gco='git checkout' +alias gcom='git co master' +alias gca="git commit --amend" +alias gcon='git checkout -b' +alias grm="git ri master" +alias gitres="git add . -A && git rebase --continue" +alias gclean="remove_untracked_files" +alias amend="git commit --amend" alias gd='git diff' alias gdc='git diff --cached' alias gdm='git diff master' -alias get='sudo apt-get install' alias gg='git lg' -alias gig='vim ~/Dropbox/notes/gigmasters-prefill.txt' -alias gpush='echo "Use gp!" && git push' -alias gp='git push' -alias gpf='git push -f' -alias gpr='git pull --rebase' -alias gratitude='vim ~/Dropbox/docs/journal/gratitude.txt' -alias grc='git rebase --continue' -alias grake='rspec --drb spec/ && cucumber --drb features/' -alias gurad='guard' -alias h='sync' -alias he='cd ~/code/hacker-engine' -alias herkou='heroku' -alias hpr='hub pull-request' -alias hpush='git push heroku' -alias i='ssh -t ben@downtowncrossingquartet.com screen -rd irc' -alias irb='irb --readline -r irb/completion' -alias jokes='vim ~/Dropbox/notes/jokes.txt' -alias journal='vim ~/Dropbox/docs/journal/2011.txt' -alias killruby='killall -9 ruby' -alias killrudy='killall -9 ruby' -alias -g M='| more' -alias mastre='master' -alias mentor='vim ~/Dropbox/work/thoughtbot/notes/mentees.txt' -alias newscreen="tmux" -alias l='cd ~/code/upcase' -alias lt='lein test' -alias lrs='lein ring server' -alias -g L='| less' -alias pc='production-console' -alias parallel='rdtp && rake parallel:prepare test:parallel_with_specs' -alias patch='git format-patch HEAD^ --stdout > patch.diff' -alias phil='vim ~/Dropbox/work/thoughtbot/notes/1-1s/phil.txt' -alias phonecall='vim ~/Dropbox/work/thoughtbot/notes/prime/phonecalls.txt' -alias podcast='vim ~/Dropbox/work/thoughtbot/notes/podcast.txt' -alias prepdb='dbprep' -alias r='cd ~/code/refactoring-good-to-great' -alias remore='!! | more' -alias reguard='killall -9 ruby ; guard' -alias rerake='!! && rake' -alias restart_apache="sudo /etc/init.d/apache2 restart" -alias restart_postgres="stoppostgres && startpostgres" -alias retag='ctags -R --exclude=.svn --exclude=.git --exclude=log --exclude=tmp *' -alias retagwithcoffee='ctags -R --exclude=.svn --exclude=.git --exclude=log --exclude=tmp * && coffeetags -R -f >> tags' -alias repush="gpr && git push" -alias review="git diff master" -alias rc='bin/rails console' -alias remigrate='rake db:migrate && rake db:migrate:redo && rake db:schema:dump && rake db:test:prepare' -alias rdm="bin/rake db:migrate" -alias rdtp="bin/rake db:test:prepare" -alias rs='bundle install && rails server -p 3000' -alias safepush='git pull --rebase && bundle install && rdm && rake && git push' -alias sfh='cd ~/code/speaking-for-hackers-book' -alias shpush='rake && hpush' -alias sc='staging-console' -alias so='source ~/.dotfiles/zsh/aliases' -alias sp='safepush' -alias speaking='cd ~/Dropbox/speaking' -alias squash='git rebase -i master' -alias ss='spring stop' -alias stage='git push staging head:master && staging open' -alias startpostgres='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start' -alias startredis='redis-server /usr/local/etc/redis.conf &' -alias stoppostgres='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log stop' -alias status='vim ~/Dropbox/work/thoughtbot/notes/prime -c "Ex"' -alias sync='git add -u . && git commit -m "Minor changes. Commit message skipped." && repush' -alias tail-logs='heroku logs -t' -alias thom='vim ~/Dropbox/work/thoughtbot/notes/1-1s/thom.txt' -alias track='git checkout -t' -alias t='cd ~/code/trailmix' -alias tute='vim ~/Dropbox/work/thoughtbot/notes/1-1s/tute.txt' -alias w='cd ~/code/upcase-exercises' -alias worknotes='vim ~/Dropbox/work/thoughtbot/notes -c "Ex"' -alias u='cd ..' alias undeployed='git fetch --multiple production origin && git log production/master..origin/master' -alias v='vim' -alias vi='vim' - -# Heroku staging -alias staging-console='heroku run console --remote staging' -alias staging-tail='heroku logs --tail --remote staging' - -# Heroku production -alias production-console='heroku run console --remote production' -alias production-tail='heroku logs --tail --remote production' - -# # Heroku databases - -alias db-pull-staging='development restore staging' -alias db-pull-production='development restore production' +alias gpcb='git push origin HEAD' +alias grom='git co master && git pull origin master && git checkout @{-1} && git rebase master' -alias db-copy-production-to-staging='heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote production` --remote staging --confirm `basename $PWD`-staging' -alias db-backup-production='heroku pgbackups:capture --remote production' -alias db-backups='heroku pgbackups --remote production' +# AWS +alias asso='aws-sso-util' -alias levelup-get-production='curl -o ~/Downloads/latest.dump `heroku pgbackups:url --app levelup-production`' -alias levelup-db-fix='killruby ; rake db:drop:all db:create:all ; pg_restore --verbose --clean --no-acl --no-owner -d levelup_development ~/Downloads/latest.dump -j 8 ; prepdb && rake levelup:dev:create_admin && rails runner CreditCard.delete_all' +# Gradle +alias jt="./gradlew test --parallel" +alias jc="./gradlew clean" +alias tpush='./gradlew test --parallel && gpcb' +alias kotlinlib="gradle init --type kotlin-library && rm -rf .gradle gradle && rm gradlew* && rm settings.gradle.kts .gitignore" diff --git a/zsh/anderslime.zsh-theme b/zsh/anderslime.zsh-theme new file mode 100644 index 0000000000..cc28ef4f50 --- /dev/null +++ b/zsh/anderslime.zsh-theme @@ -0,0 +1,27 @@ +PROMPT=$'%F{114}%m%{$reset_color%}:%c$(git_prompt_info) %F{222}$ %{$reset_color%}' +local return_status="%{$fg[red]%}%(?..⏎)%{$reset_color%}" +RPROMPT='${return_status}%{$reset_color%}' + +DIRTY_YELLOW_COLOR="%F{220}" +LONG_SINCE_COMMIT_RED="%F{9}" + +ZSH_THEME_GIT_PROMPT_PREFIX="(%F{110}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})" +ZSH_THEME_GIT_PROMPT_DIRTY="$LONG_SINCE_COMMIT_RED!" +ZSH_THEME_GIT_PROMPT_CLEAN="" + +ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} ✚" +ZSH_THEME_GIT_PROMPT_MODIFIED="$DIRTY_YELLOW_COLOR ✹" +ZSH_THEME_GIT_PROMPT_DELETED="$LONG_SINCE_COMMIT_RED ✖" +ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜" +ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭" + +GIT_RPROMPT_DIRTY="$DIRTY_YELLOW_COLOR ✗%{$reset_color%}" +GIT_RPROMPT_CLEAN="" + +ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT=$fg[green] +ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM=$DIRTY_YELLOW_COLOR +ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG=$LONG_SINCE_COMMIT_RED +ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL=$reset_color + diff --git a/zsh/func/awsso b/zsh/func/awsso new file mode 100644 index 0000000000..dda93c2345 --- /dev/null +++ b/zsh/func/awsso @@ -0,0 +1,10 @@ +_AWS_SSO_UTIL_COMPLETE_SCRIPT_DIR=~/.local/share/aws-sso-util +_AWS_SSO_UTIL_COMPLETE_SCRIPT=$_AWS_SSO_UTIL_COMPLETE_SCRIPT_DIR/complete.sh +if which aws-sso-util > /dev/null; then + mkdir -p $_AWS_SSO_UTIL_COMPLETE_SCRIPT_DIR + ({ _AWS_SSO_UTIL_COMPLETE=source_bash aws-sso-util > $_AWS_SSO_UTIL_COMPLETE_SCRIPT.tmp ; + mv $_AWS_SSO_UTIL_COMPLETE_SCRIPT.tmp $_AWS_SSO_UTIL_COMPLETE_SCRIPT; } &) + if [ -f $_AWS_SSO_UTIL_COMPLETE_SCRIPT ]; then + source $_AWS_SSO_UTIL_COMPLETE_SCRIPT + fi +fi diff --git a/zsh/func/prompt_grb_setup b/zsh/func/prompt_grb_setup new file mode 100644 index 0000000000..57f4a11226 --- /dev/null +++ b/zsh/func/prompt_grb_setup @@ -0,0 +1,342 @@ +# grb prompt theme +# copied from wunjo prompt theme and modified + +autoload -U zgitinit +zgitinit + +prompt_grb_help () { + cat <<'EOF' + + prompt grb + +EOF +} + +revstring() { + git describe --always $1 2>/dev/null || + git rev-parse --short $1 2>/dev/null +} + +coloratom() { + local off=$1 atom=$2 + if [[ $atom[1] == [[:upper:]] ]]; then + off=$(( $off + 60 )) + fi + echo $(( $off + $colorcode[${(L)atom}] )) +} +colorword() { + local fg=$1 bg=$2 att=$3 + local -a s + + if [ -n "$fg" ]; then + s+=$(coloratom 30 $fg) + fi + if [ -n "$bg" ]; then + s+=$(coloratom 40 $bg) + fi + if [ -n "$att" ]; then + s+=$attcode[$att] + fi + + echo "%{"$'\e['${(j:;:)s}m"%}" +} + +function minutes_since_last_commit { + now=`date +%s` + last_commit=`git log --pretty=format:'%at' -1 2>/dev/null` + if $lastcommit ; then + seconds_since_last_commit=$((now-last_commit)) + minutes_since_last_commit=$((seconds_since_last_commit/60)) + echo $minutes_since_last_commit + else + echo "-1" + fi +} + +function prompt_grb_scm_time_since_commit() { + local -A pc + pc=(${(kv)wunjo_prompt_colors}) + + if zgit_inworktree; then + local MINUTES_SINCE_LAST_COMMIT=`minutes_since_last_commit` + if [ "$MINUTES_SINCE_LAST_COMMIT" -eq -1 ]; then + COLOR="$pc[scm_time_uncommitted]" + local SINCE_LAST_COMMIT="${COLOR}uncommitted$pc[reset]" + else + if [ "$MINUTES_SINCE_LAST_COMMIT" -gt 30 ]; then + COLOR="$pc[scm_time_long]" + elif [ "$MINUTES_SINCE_LAST_COMMIT" -gt 10 ]; then + COLOR="$pc[scm_time_medium]" + else + COLOR="$pc[scm_time_short]" + fi + local SINCE_LAST_COMMIT="${COLOR}$(minutes_since_last_commit)m$pc[reset]" + fi + echo $SINCE_LAST_COMMIT + fi +} + +function prompt_grb_scm_info() { + if zgit_inworktree; then + echo "($(prompt_wunjo_scm_branch))" + fi +} + +prompt_grb_setup() { + local verbose + if [[ $TERM == screen* ]] && [ -n "$STY" ]; then + verbose= + else + verbose=1 + fi + + typeset -A colorcode + colorcode[black]=0 + colorcode[red]=1 + colorcode[green]=2 + colorcode[yellow]=3 + colorcode[blue]=4 + colorcode[magenta]=5 + colorcode[cyan]=6 + colorcode[white]=7 + colorcode[default]=9 + colorcode[k]=$colorcode[black] + colorcode[r]=$colorcode[red] + colorcode[g]=$colorcode[green] + colorcode[y]=$colorcode[yellow] + colorcode[b]=$colorcode[blue] + colorcode[m]=$colorcode[magenta] + colorcode[c]=$colorcode[cyan] + colorcode[w]=$colorcode[white] + colorcode[.]=$colorcode[default] + + typeset -A attcode + attcode[none]=00 + attcode[bold]=01 + attcode[faint]=02 + attcode[standout]=03 + attcode[underline]=04 + attcode[blink]=05 + attcode[reverse]=07 + attcode[conceal]=08 + attcode[normal]=22 + attcode[no-standout]=23 + attcode[no-underline]=24 + attcode[no-blink]=25 + attcode[no-reverse]=27 + attcode[no-conceal]=28 + + local -A pc + pc[divider]='black' + pc[default]='default' + pc[date]='cyan' + pc[time]='Blue' + pc[host]='Green' + pc[user]='cyan' + pc[punc]='yellow' + pc[line]='magenta' + pc[hist]='green' + pc[path]='Cyan' + pc[shortpath]='default' + pc[rc]='red' + pc[scm_branch]='green' + pc[scm_commitid]='Yellow' + pc[scm_status_dirty]='Red' + pc[scm_status_staged]='Green' + pc[scm_time_short]='green' + pc[scm_time_medium]='yellow' + pc[scm_time_long]='red' + pc[scm_time_uncommitted]='Magenta' + pc[#]='Yellow' + for cn in ${(k)pc}; do + pc[${cn}]=$(colorword $pc[$cn]) + done + pc[reset]=$(colorword . . 00) + + typeset -Ag wunjo_prompt_colors + wunjo_prompt_colors=(${(kv)pc}) + + local p_date p_line p_rc + + p_date="$pc[date]%D{%Y-%m-%d} $pc[time]%D{%T}$pc[reset]" + + p_line="$pc[line]%y$pc[reset]" + + PROMPT="$pc[divider]\$(repeat \$COLUMNS printf '-')$pc[reset]" + PROMPT+= + if [ $verbose ]; then + PROMPT+="$pc[host]%m$pc[reset]" + fi + #PROMPT+="$pc[path]%(2~.%~.%/)$pc[reset]" + #PROMPT+="\$(prompt_wunjo_scm_status)" + #PROMPT+="%(?.. $pc[rc]exited %1v$pc[reset])" +# PROMPT+=" +#" + #PROMPT+="($pc[hist]%h$pc[reset])" + PROMPT+=":$pc[shortpath]%1~$pc[reset]" + PROMPT+="($pc[scm_branch]\$(prompt_wunjo_scm_branch)$pc[reset])" + PROMPT+=" $pc[#]\$$pc[reset] " + + #RPROMPT= + #if [ $verbose ]; then + # RPROMPT+="$p_date " + #fi + #RPROMPT+="$pc[user]%n$pc[reset]" + #RPROMPT+=" $p_line" + + export PROMPT RPROMPT + precmd_functions+='prompt_wunjo_precmd' +} + +prompt_wunjo_precmd() { + local ex=$? + psvar=() + + if [[ $ex -ge 128 ]]; then + sig=$signals[$ex-127] + psvar[1]="sig${(L)sig}" + else + psvar[1]="$ex" + fi +} + +prompt_wunjo_scm_status() { + zgit_isgit || return + local -A pc + pc=(${(kv)wunjo_prompt_colors}) + + head=$(zgit_head) + gitcommit=$(revstring $head) + + local -a commits + + if zgit_rebaseinfo; then + orig_commit=$(revstring $zgit_info[rb_head]) + orig_name=$(git name-rev --name-only $zgit_info[rb_head]) + orig="$pc[scm_branch]$orig_name$pc[punc]($pc[scm_commitid]$orig_commit$pc[punc])" + onto_commit=$(revstring $zgit_info[rb_onto]) + onto_name=$(git name-rev --name-only $zgit_info[rb_onto]) + onto="$pc[scm_branch]$onto_name$pc[punc]($pc[scm_commitid]$onto_commit$pc[punc])" + + if [ -n "$zgit_info[rb_upstream]" ] && [ $zgit_info[rb_upstream] != $zgit_info[rb_onto] ]; then + upstream_commit=$(revstring $zgit_info[rb_upstream]) + upstream_name=$(git name-rev --name-only $zgit_info[rb_upstream]) + upstream="$pc[scm_branch]$upstream_name$pc[punc]($pc[scm_commitid]$upstream_commit$pc[punc])" + commits+="rebasing $upstream$pc[reset]..$orig$pc[reset] onto $onto$pc[reset]" + else + commits+="rebasing $onto$pc[reset]..$orig$pc[reset]" + fi + + local -a revs + revs=($(git rev-list $zgit_info[rb_onto]..HEAD)) + if [ $#revs -gt 0 ]; then + commits+="\n$#revs commits in" + fi + + if [ -f $zgit_info[dotest]/message ]; then + mess=$(head -n1 $zgit_info[dotest]/message) + commits+="on $mess" + fi + elif [ -n "$gitcommit" ]; then + commits+="on $pc[scm_branch]$head$pc[punc]($pc[scm_commitid]$gitcommit$pc[punc])$pc[reset]" + local track_merge=$(zgit_tracking_merge) + if [ -n "$track_merge" ]; then + if git rev-parse --verify -q $track_merge >/dev/null; then + local track_remote=$(zgit_tracking_remote) + local tracked=$(revstring $track_merge 2>/dev/null) + + local -a revs + revs=($(git rev-list --reverse $track_merge..HEAD)) + if [ $#revs -gt 0 ]; then + local base=$(revstring $revs[1]~1) + local base_name=$(git name-rev --name-only $base) + local base_short=$(revstring $base) + local word_commits + if [ $#revs -gt 1 ]; then + word_commits='commits' + else + word_commits='commit' + fi + + local conj="since" + if [[ "$base" == "$tracked" ]]; then + conj+=" tracked" + tracked= + fi + commits+="$#revs $word_commits $conj $pc[scm_branch]$base_name$pc[punc]($pc[scm_commitid]$base_short$pc[punc])$pc[reset]" + fi + + if [ -n "$tracked" ]; then + local track_name=$track_merge + if [[ $track_remote == "." ]]; then + track_name=${track_name##*/} + fi + tracked=$(revstring $tracked) + commits+="tracking $pc[scm_branch]$track_name$pc[punc]" + if [[ "$tracked" != "$gitcommit" ]]; then + commits[$#commits]+="($pc[scm_commitid]$tracked$pc[punc])" + fi + commits[$#commits]+="$pc[reset]" + fi + fi + fi + fi + + gitsvn=$(git rev-parse --verify -q --short git-svn) + if [ $? -eq 0 ]; then + gitsvnrev=$(zgit_svnhead $gitsvn) + gitsvn=$(revstring $gitsvn) + if [ -n "$gitsvnrev" ]; then + local svninfo='' + local -a revs + svninfo+="$pc[default]svn$pc[punc]:$pc[scm_branch]r$gitsvnrev" + revs=($(git rev-list git-svn..HEAD)) + if [ $#revs -gt 0 ]; then + svninfo+="$pc[punc]@$pc[default]HEAD~$#revs" + svninfo+="$pc[punc]($pc[scm_commitid]$gitsvn$pc[punc])" + fi + commits+=$svninfo + fi + fi + + if [ $#commits -gt 0 ]; then + echo -n " ${(j: :)commits}" + fi +} + +prompt_wunjo_scm_branch() { + zgit_isgit || return + local -A pc + pc=(${(kv)wunjo_prompt_colors}) + + echo -n "$pc[punc]$pc[scm_branch]$(zgit_head)" + + #if zgit_inworktree; then + # if ! zgit_isindexclean; then + # echo -n "$pc[scm_status_staged]+" + # fi + + # local -a dirty + # if ! zgit_isworktreeclean; then + # dirty+='!' + # fi + + # if zgit_hasunmerged; then + # dirty+='*' + # fi + + # if zgit_hasuntracked; then + # dirty+='?' + # fi + + # if [ $#dirty -gt 0 ]; then + # echo -n "$pc[scm_status_dirty]${(j::)dirty}" + # fi + #fi + + echo $pc[reset] +} + +prompt_grb_setup "$@" + +# vim:set ft=zsh: diff --git a/zsh/func/prompt_wunjo_setup b/zsh/func/prompt_wunjo_setup new file mode 100644 index 0000000000..908b6e217a --- /dev/null +++ b/zsh/func/prompt_wunjo_setup @@ -0,0 +1,294 @@ +# wunjo prompt theme + +autoload -U zgitinit +zgitinit + +prompt_wunjo_help () { + cat <<'EOF' + + prompt wunjo + +EOF +} + +revstring() { + git describe --always $1 2>/dev/null || + git rev-parse --short $1 2>/dev/null +} + +coloratom() { + local off=$1 atom=$2 + if [[ $atom[1] == [[:upper:]] ]]; then + off=$(( $off + 60 )) + fi + echo $(( $off + $colorcode[${(L)atom}] )) +} +colorword() { + local fg=$1 bg=$2 att=$3 + local -a s + + if [ -n "$fg" ]; then + s+=$(coloratom 30 $fg) + fi + if [ -n "$bg" ]; then + s+=$(coloratom 40 $bg) + fi + if [ -n "$att" ]; then + s+=$attcode[$att] + fi + + echo "%{"$'\e['${(j:;:)s}m"%}" +} + +prompt_wunjo_setup() { + local verbose + if [[ $TERM == screen* ]] && [ -n "$STY" ]; then + verbose= + else + verbose=1 + fi + + typeset -A colorcode + colorcode[black]=0 + colorcode[red]=1 + colorcode[green]=2 + colorcode[yellow]=3 + colorcode[blue]=4 + colorcode[magenta]=5 + colorcode[cyan]=6 + colorcode[white]=7 + colorcode[default]=9 + colorcode[k]=$colorcode[black] + colorcode[r]=$colorcode[red] + colorcode[g]=$colorcode[green] + colorcode[y]=$colorcode[yellow] + colorcode[b]=$colorcode[blue] + colorcode[m]=$colorcode[magenta] + colorcode[c]=$colorcode[cyan] + colorcode[w]=$colorcode[white] + colorcode[.]=$colorcode[default] + + typeset -A attcode + attcode[none]=00 + attcode[bold]=01 + attcode[faint]=02 + attcode[standout]=03 + attcode[underline]=04 + attcode[blink]=05 + attcode[reverse]=07 + attcode[conceal]=08 + attcode[normal]=22 + attcode[no-standout]=23 + attcode[no-underline]=24 + attcode[no-blink]=25 + attcode[no-reverse]=27 + attcode[no-conceal]=28 + + local -A pc + pc[default]='default' + pc[date]='cyan' + pc[time]='Blue' + pc[host]='Green' + pc[user]='cyan' + pc[punc]='yellow' + pc[line]='magenta' + pc[hist]='green' + pc[path]='Cyan' + pc[shortpath]='default' + pc[rc]='red' + pc[scm_branch]='Cyan' + pc[scm_commitid]='Yellow' + pc[scm_status_dirty]='Red' + pc[scm_status_staged]='Green' + pc[#]='Yellow' + for cn in ${(k)pc}; do + pc[${cn}]=$(colorword $pc[$cn]) + done + pc[reset]=$(colorword . . 00) + + typeset -Ag wunjo_prompt_colors + wunjo_prompt_colors=(${(kv)pc}) + + local p_date p_line p_rc + + p_date="$pc[date]%D{%Y-%m-%d} $pc[time]%D{%T}$pc[reset]" + + p_line="$pc[line]%y$pc[reset]" + + PROMPT= + if [ $verbose ]; then + PROMPT+="$pc[host]%m$pc[reset] " + fi + PROMPT+="$pc[path]%(2~.%~.%/)$pc[reset]" + PROMPT+="\$(prompt_wunjo_scm_status)" + PROMPT+="%(?.. $pc[rc]exited %1v$pc[reset])" + PROMPT+=" +" + PROMPT+="$pc[hist]%h$pc[reset] " + PROMPT+="$pc[shortpath]%1~$pc[reset]" + PROMPT+="\$(prompt_wunjo_scm_branch)" + PROMPT+=" $pc[#]%#$pc[reset] " + + RPROMPT= + if [ $verbose ]; then + RPROMPT+="$p_date " + fi + RPROMPT+="$pc[user]%n$pc[reset]" + RPROMPT+=" $p_line" + + export PROMPT RPROMPT + precmd_functions+='prompt_wunjo_precmd' +} + +prompt_wunjo_precmd() { + local ex=$? + psvar=() + + if [[ $ex -ge 128 ]]; then + sig=$signals[$ex-127] + psvar[1]="sig${(L)sig}" + else + psvar[1]="$ex" + fi +} + +prompt_wunjo_scm_status() { + zgit_isgit || return + local -A pc + pc=(${(kv)wunjo_prompt_colors}) + + head=$(zgit_head) + gitcommit=$(revstring $head) + + local -a commits + + if zgit_rebaseinfo; then + orig_commit=$(revstring $zgit_info[rb_head]) + orig_name=$(git name-rev --name-only $zgit_info[rb_head]) + orig="$pc[scm_branch]$orig_name$pc[punc]($pc[scm_commitid]$orig_commit$pc[punc])" + onto_commit=$(revstring $zgit_info[rb_onto]) + onto_name=$(git name-rev --name-only $zgit_info[rb_onto]) + onto="$pc[scm_branch]$onto_name$pc[punc]($pc[scm_commitid]$onto_commit$pc[punc])" + + if [ -n "$zgit_info[rb_upstream]" ] && [ $zgit_info[rb_upstream] != $zgit_info[rb_onto] ]; then + upstream_commit=$(revstring $zgit_info[rb_upstream]) + upstream_name=$(git name-rev --name-only $zgit_info[rb_upstream]) + upstream="$pc[scm_branch]$upstream_name$pc[punc]($pc[scm_commitid]$upstream_commit$pc[punc])" + commits+="rebasing $upstream$pc[reset]..$orig$pc[reset] onto $onto$pc[reset]" + else + commits+="rebasing $onto$pc[reset]..$orig$pc[reset]" + fi + + local -a revs + revs=($(git rev-list $zgit_info[rb_onto]..HEAD)) + if [ $#revs -gt 0 ]; then + commits+="\n$#revs commits in" + fi + + if [ -f $zgit_info[dotest]/message ]; then + mess=$(head -n1 $zgit_info[dotest]/message) + commits+="on $mess" + fi + elif [ -n "$gitcommit" ]; then + commits+="on $pc[scm_branch]$head$pc[punc]($pc[scm_commitid]$gitcommit$pc[punc])$pc[reset]" + local track_merge=$(zgit_tracking_merge) + if [ -n "$track_merge" ]; then + if git rev-parse --verify -q $track_merge >/dev/null; then + local track_remote=$(zgit_tracking_remote) + local tracked=$(revstring $track_merge 2>/dev/null) + + local -a revs + revs=($(git rev-list --reverse $track_merge..HEAD)) + if [ $#revs -gt 0 ]; then + local base=$(revstring $revs[1]~1) + local base_name=$(git name-rev --name-only $base) + local base_short=$(revstring $base) + local word_commits + if [ $#revs -gt 1 ]; then + word_commits='commits' + else + word_commits='commit' + fi + + local conj="since" + if [[ "$base" == "$tracked" ]]; then + conj+=" tracked" + tracked= + fi + commits+="$#revs $word_commits $conj $pc[scm_branch]$base_name$pc[punc]($pc[scm_commitid]$base_short$pc[punc])$pc[reset]" + fi + + if [ -n "$tracked" ]; then + local track_name=$track_merge + if [[ $track_remote == "." ]]; then + track_name=${track_name##*/} + fi + tracked=$(revstring $tracked) + commits+="tracking $pc[scm_branch]$track_name$pc[punc]" + if [[ "$tracked" != "$gitcommit" ]]; then + commits[$#commits]+="($pc[scm_commitid]$tracked$pc[punc])" + fi + commits[$#commits]+="$pc[reset]" + fi + fi + fi + fi + + gitsvn=$(git rev-parse --verify -q --short git-svn) + if [ $? -eq 0 ]; then + gitsvnrev=$(zgit_svnhead $gitsvn) + gitsvn=$(revstring $gitsvn) + if [ -n "$gitsvnrev" ]; then + local svninfo='' + local -a revs + svninfo+="$pc[default]svn$pc[punc]:$pc[scm_branch]r$gitsvnrev" + revs=($(git rev-list git-svn..HEAD)) + if [ $#revs -gt 0 ]; then + svninfo+="$pc[punc]@$pc[default]HEAD~$#revs" + svninfo+="$pc[punc]($pc[scm_commitid]$gitsvn$pc[punc])" + fi + commits+=$svninfo + fi + fi + + if [ $#commits -gt 0 ]; then + echo -n " ${(j: :)commits}" + fi +} + +prompt_wunjo_scm_branch() { + zgit_isgit || return + local -A pc + pc=(${(kv)wunjo_prompt_colors}) + + echo -n "$pc[punc]:$pc[scm_branch]$(zgit_head)" + + if zgit_inworktree; then + if ! zgit_isindexclean; then + echo -n "$pc[scm_status_staged]+" + fi + + local -a dirty + if ! zgit_isworktreeclean; then + dirty+='!' + fi + + if zgit_hasunmerged; then + dirty+='*' + fi + + if zgit_hasuntracked; then + dirty+='?' + fi + + if [ $#dirty -gt 0 ]; then + echo -n "$pc[scm_status_dirty]${(j::)dirty}" + fi + fi + + echo $pc[reset] +} + +prompt_wunjo_setup "$@" + +# vim:set ft=zsh: diff --git a/zsh/func/zgitinit b/zsh/func/zgitinit new file mode 100644 index 0000000000..c85e962fbc --- /dev/null +++ b/zsh/func/zgitinit @@ -0,0 +1,243 @@ +## +## Load with `autoload -U zgitinit; zgitinit' +## + +typeset -gA zgit_info +zgit_info=() +autoload -U add-zsh-hook + +zgit_chpwd_hook() { + zgit_info_update +} + +zgit_preexec_hook() { + if [[ $2 == git\ * ]] || [[ $2 == *\ git\ * ]]; then + zgit_precmd_do_update=1 + fi +} + +zgit_precmd_hook() { + if [ $zgit_precmd_do_update ]; then + unset zgit_precmd_do_update + zgit_info_update + fi +} + +zgit_info_update() { + zgit_info=() + + local gitdir="$(git rev-parse --show-toplevel 2>/dev/null)" + if [ $? -ne 0 ] || [ -z "$gitdir" ]; then + return + fi + + zgit_info[dir]=$gitdir + zgit_info[bare]=$(git rev-parse --is-bare-repository) + zgit_info[inwork]=$(git rev-parse --is-inside-work-tree) +} + +zgit_isgit() { + if [ -z "$zgit_info[dir]" ]; then + return 1 + else + return 0 + fi +} + +zgit_inworktree() { + zgit_isgit || return + if [ "$zgit_info[inwork]" = "true" ]; then + return 0 + else + return 1 + fi +} + +zgit_isbare() { + zgit_isgit || return + if [ "$zgit_info[bare]" = "true" ]; then + return 0 + else + return 1 + fi +} + +zgit_head() { + zgit_isgit || return 1 + + if [ -z "$zgit_info[head]" ]; then + local name='' + name=$(git symbolic-ref -q HEAD) + if [ $? -eq 0 ]; then + if [[ $name == refs/(heads|tags)/* ]]; then + name=${name#refs/(heads|tags)/} + fi + else + name=$(git name-rev --name-only --no-undefined --always HEAD) + if [ $? -ne 0 ]; then + return 1 + elif [[ $name == remotes/* ]]; then + name=${name#remotes/} + fi + fi + zgit_info[head]=$name + fi + + echo $zgit_info[head] +} + +zgit_branch() { + zgit_isgit || return 1 + zgit_isbare && return 1 + + if [ -z "$zgit_info[branch]" ]; then + local branch=$(git symbolic-ref --short HEAD 2>/dev/null) + if [ $? -ne 0 ]; then + branch=$(git name-rev --name-only --always HEAD) + fi + zgit_info[branch]=$branch + fi + + echo $zgit_info[branch] + return 0 +} + +zgit_tracking_remote() { + zgit_isgit || return 1 + zgit_isbare && return 1 + + local branch + if [ -n "$1" ]; then + branch=$1 + elif [ -z "$zgit_info[branch]" ]; then + branch=$(zgit_branch) + [ $? -ne 0 ] && return 1 + else + branch=$zgit_info[branch] + fi + + local k="tracking_$branch" + local remote + if [ -z "$zgit_info[$k]" ]; then + remote=$(git config branch.$branch.remote) + zgit_info[$k]=$remote + fi + + echo $zgit_info[$k] + return 0 +} + +zgit_tracking_merge() { + zgit_isgit || return 1 + zgit_isbare && return 1 + + local branch + if [ -z "$zgit_info[branch]" ]; then + branch=$(zgit_branch) + [ $? -ne 0 ] && return 1 + else + branch=$zgit_info[branch] + fi + + local remote=$(zgit_tracking_remote $branch) + [ $? -ne 0 ] && return 1 + if [ -n "$remote" ]; then # tracking branch + local merge=$(git config branch.$branch.merge) + if [ $remote != "." ]; then + merge=$remote/$(basename $merge) + fi + echo $merge + return 0 + else + return 1 + fi +} + +zgit_isindexclean() { + zgit_isgit || return 1 + if git diff --quiet --cached 2>/dev/null; then + return 0 + else + return 1 + fi +} + +zgit_isworktreeclean() { + zgit_isgit || return 1 + if [ -z "$(git ls-files $zgit_info[dir] --modified)" ]; then + return 0 + else + return 1 + fi +} + +zgit_hasuntracked() { + zgit_isgit || return 1 + local -a flist + flist=($(git ls-files --others --exclude-standard)) + if [ $#flist -gt 0 ]; then + return 0 + else + return 1 + fi +} + +zgit_hasunmerged() { + zgit_isgit || return 1 + local -a flist + flist=($(git ls-files -u)) + if [ $#flist -gt 0 ]; then + return 0 + else + return 1 + fi +} + +zgit_svnhead() { + zgit_isgit || return 1 + + local commit=$1 + if [ -z "$commit" ]; then + commit='HEAD' + fi + + git svn find-rev $commit +} + +zgit_rebaseinfo() { + zgit_isgit || return 1 + if [ -d $zgit_info[dir]/rebase-merge ]; then + dotest=$zgit_info[dir]/rebase-merge + elif [ -d $zgit_info[dir]/.dotest-merge ]; then + dotest=$zgit_info[dir]/.dotest-merge + elif [ -d .dotest ]; then + dotest=.dotest + else + return 1 + fi + + zgit_info[dotest]=$dotest + + zgit_info[rb_onto]=$(cat "$dotest/onto") + if [ -f "$dotest/upstream" ]; then + zgit_info[rb_upstream]=$(cat "$dotest/upstream") + else + zgit_info[rb_upstream]= + fi + if [ -f "$dotest/orig-head" ]; then + zgit_info[rb_head]=$(cat "$dotest/orig-head") + elif [ -f "$dotest/head" ]; then + zgit_info[rb_head]=$(cat "$dotest/head") + fi + zgit_info[rb_head_name]=$(cat "$dotest/head-name") + + return 0 +} + +add-zsh-hook chpwd zgit_chpwd_hook +add-zsh-hook preexec zgit_preexec_hook +add-zsh-hook precmd zgit_precmd_hook + +zgit_info_update + +# vim:set ft=zsh: diff --git a/zsh/functions b/zsh/functions index ac27248bd5..e9aaf77b6b 100644 --- a/zsh/functions +++ b/zsh/functions @@ -7,11 +7,6 @@ function git_branch_name { echo "$val" } -function git-done { - branch=`git_branch_name` - killruby ; spring stop ; git checkout master && git merge $branch --ff-only && bundle install && prepdb && bin/rspec && git push && git branch -D $branch && git push origin :$branch -} - function git-nuke { git branch -D $1 && git push origin :$1 } @@ -19,10 +14,10 @@ compdef _git git-nuke=git-checkout function git-on-master { branch=`git_branch_name` - git checkout master && git pull --rebase + git checkout master && git pull --rebase git checkout $branch git rebase master - } +} function g { if [[ $# > 0 ]]; then @@ -32,10 +27,6 @@ function g { fi } -function rrg { - bin/rake routes | grep $1 -} - function take { mkdir $1 cd $1 @@ -45,3 +36,27 @@ function take { function gc { git commit -m "$*" } + +function note { + vim ~/notes/$1.txt +} +alias en=note + +function remove_untracked_files { + git clean -f -n + read -q "REPLY?Above files will be removed. Are you sure?" -r 1 -n + echo + if [[ $REPLY =~ ^[Yy]$ ]] + then + git clean -f + fi +} + +function rebase_all { + for branch in $(git branch --no-merged | xargs); do + git co $branch + git rebase master || git rebase --abort + done +} + +function killport { lsof -ti:$1 | xargs kill; } diff --git a/zshrc b/zshrc index 66d4c305f4..e4ba807d82 100644 --- a/zshrc +++ b/zshrc @@ -1,31 +1,64 @@ -# Allow completing of the remainder of a command -bindkey "^N" insert-last-word +# Homebrew (Apple Silicon) +eval "$(/opt/homebrew/bin/brew shellenv)" + +# Path to your oh-my-zsh installation. +export ZSH=$HOME/.oh-my-zsh + +# ZSH Theme +ZSH_THEME="awesomepanda" + +# oh-my-zsh plugins +plugins=( + git + docker + aws +) + +# User configuration +HISTSIZE=20000 +HISTFILE=~/.zsh_history +SAVEHIST=20000 # Show contents of directory after cd-ing into it chpwd() { ls -lrthG } -# Save a ton of history -HISTSIZE=20000 -HISTFILE=~/.zsh_history -SAVEHIST=20000 +# Load oh my zsh +source $ZSH/oh-my-zsh.sh -# Enable completion -autoload -U compinit -compinit +# Ngrok (must come after oh-my-zsh so compdef is defined) +if command -v ngrok &>/dev/null; then + eval "$(ngrok completion)" +fi -# Disable flow control commands (keeps C-s from freezing everything) -stty start undef -stty stop undef +# Python +export PYTHONIOENCODING=utf-8 -# RVM -[[ -s "/Users/ben/.rvm/scripts/rvm" ]] && source "/Users/ben/.rvm/scripts/rvm" +# Locale +export LC_ALL=en_US.UTF-8 +export LANG=da_DK.UTF-8 +export EDITOR='vim' +export LC_CTYPE="en_US.UTF-8" -# Sourcing of other files source $HOME/.dotfiles/zsh/aliases source $HOME/.dotfiles/zsh/functions -source $HOME/.dotfiles/zsh/prompt -source $HOME/.dotfiles/zsh/z -export PATH=$PATH:bin:~/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/git/bin:/usr/bin:/bin:/usr/sbin:/sbin:$HOME/.rvm/bin +# Java +# export JAVA_21_HOME=$(/usr/libexec/java_home -v21) +# alias java21='export JAVA_HOME=$JAVA_21_HOME' + +bindkey "^[[1;3D" backward-word +bindkey "^[[1;3C" forward-word + +eval "$(nodenv init -)" + +# User-local binaries (Claude Code lives here) +export PATH="$HOME/.local/bin:$PATH" + +export PATH="/opt/homebrew/opt/postgresql@17/bin:$PATH" + +# bun +export BUN_INSTALL="$HOME/.bun" +export PATH="$BUN_INSTALL/bin:$PATH" +[ -s "$HOME/.bun/_bun" ] && source "$HOME/.bun/_bun"