diff --git a/.gitignore b/.gitignore index 69c84937..1d635aef 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,8 @@ Transmission Remote GUI vim/bundle/* Fritzing +hub +camlistore +git/ +inkscape/ +transmission-daemon/ diff --git a/.gitmodules b/.gitmodules index bb6c5f27..6fea3454 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ -[submodule "editors/vim/bundle/vundle"] - path = editors/vim/bundle/vundle - url = git://github.com/gmarik/vundle.git +[submodule "shells/zsh/lib/syntax-highlighting"] + path = shells/zsh/lib/syntax-highlighting + url = git://github.com/zsh-users/zsh-syntax-highlighting.git +[submodule "shells/zsh/lib/history-substring-search"] + path = shells/zsh/lib/history-substring-search + url = git://github.com/zsh-users/zsh-history-substring-search.git diff --git a/README.md b/README.md index 8795fa51..9564c3da 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,16 @@ -# TODO +# My dot files. -* Make ZSH/Bash PATH dynamically figured out (via globbing) like fish -* Make `rake install` install a .git pre-commit hook to remind about or automatically remove all API keys from dot files (gitconfig, etc) -* Make `rake install` set up a loop that will always try to `git pull` the dot-files (if working directory is clean) so they are always up to date -* Remove 'export' from variables that don't need them -* Make current directory red in prompt if non-writeable (ala fish) -* Fix shell $PATH. Intelligently build up from only existent directories and ensure no-duplicates -* Steal some awesome stuff from https://github.com/skwp/dotfiles/blob/master/osx +Please explore and/or suggest! -Copyright (c) 2008-2011 Bodaniel Jeanes +## Initial setup + +```sh +$ FRESH_LOCAL_SOURCE=bjeanes/dot-files bash -c "`curl -sL https://get.freshshell.com`" +``` + +# LICENSE + +Copyright (c) 2008-2013 Bodaniel Jeanes Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/Rakefile b/Rakefile deleted file mode 100644 index e2c96a72..00000000 --- a/Rakefile +++ /dev/null @@ -1,79 +0,0 @@ -require 'rake' -require 'fileutils' - -desc "install the dot files into user's home directory" -task :install do - replace_all = false - dot_files = File.dirname(__FILE__) - files = %w( - editors/vim - editors/vim/gvimrc - editors/vim/vimrc - languages/ruby/autotest/autotest - languages/ruby/gemrc - languages/ruby/irbrc - languages/ruby/rdebugrc - misc/ackrc - misc/ctags - misc/inputrc - misc/nanorc - misc/tmux/tmux.conf - shells/bash/bash_profile - shells/bash/bashrc - shells/zsh/zshenv - shells/zsh/zshrc - vcs/git/gitattributes - vcs/git/gitconfig - vcs/git/gitconfig.merge - vcs/git/gitconfig.pushurls - vcs/git/gitignore - vcs/git/gitk - vcs/git/git_template - vcs/hg/hgrc - ) - - files = Hash[files.zip(Array.new(files.size, "~/."))] - files["languages/clojure/lein/profiles.clj"] = "~/.lein/" - files["editors/emacs/init.el"] = "~/.emacs.d/" - files["editors/emacs/bjeanes"] = "~/.emacs.d/" - - system "cp -n vcs/git/gitconfig.local ~/.gitconfig.local" - - files.each do |file, destination| - file_name = file.split(/\//).last - source_file = File.join(dot_files, file) - destination_file = File.expand_path("#{destination}#{file_name}") - - if File.exist?(destination_file) || File.symlink?(destination_file) - if replace_all - replace_file(destination_file, source_file) - else - print "overwrite #{destination_file}? [ynaq] " - case $stdin.gets.chomp.downcase - when 'a' - replace_all = true - replace_file(destination_file, source_file) - when 'y' - replace_file(destination_file, source_file) - when 'q' - exit - else - puts "skipping #{destination_file}" - end - end - else - link_file(destination_file, source_file) - end - end -end - -def replace_file(old_file, new_file) - system %Q{rm "#{old_file}"} - link_file(old_file, new_file) -end - -def link_file(old_file, new_file) - puts "#{old_file} => #{new_file}" - FileUtils.mkdir_p(File.dirname(new_file)) - system %Q{ln -fs "#{new_file}" "#{old_file}"} -end diff --git a/editors/emacs/bjeanes/01_colors.el b/editors/emacs/bjeanes/01_colors.el index 9b92c7be..29c19c81 100644 --- a/editors/emacs/bjeanes/01_colors.el +++ b/editors/emacs/bjeanes/01_colors.el @@ -1,7 +1,3 @@ -(defun plist-to-alist (&optional arg) nil) ; stop a weird error coming - ; from color-theme-molokai -(require 'color-theme) -(require 'color-theme-molokai) -(color-theme-molokai) +(require 'color-theme-sanityinc-tomorrow) -(set-face-background 'hl-line "#000") +(color-theme-sanityinc-tomorrow-night) diff --git a/editors/emacs/bjeanes/99_vim.el b/editors/emacs/bjeanes/99_vim.el index 8c449892..d3da8088 100644 --- a/editors/emacs/bjeanes/99_vim.el +++ b/editors/emacs/bjeanes/99_vim.el @@ -1,11 +1,51 @@ -(require 'evil) -(add-hook 'prog-mode-hook 'evil-mode) -(require 'surround) -(add-hook 'prog-mode-hook 'global-surround-mode) - -(define-key evil-motion-state-map (kbd "C-u") 'evil-scroll-up) - ;; TODO ;; * Map D to C-k (i.e. preserve paredit's version) ;; * Make word motions obey subword-mode setting ;; * Put current Evil state into powerline + +(require 'evil) + +;; This is actually mapped but it doesn't seem to work reliably +;; without this +(define-key evil-motion-state-map (kbd "C-u") 'evil-scroll-up) + +;; Escape quits +;; https://github.com/mbriggs/.emacs.d/blob/d9e254ae/my-keymaps.el#L81-L89 +(define-key evil-normal-state-map [escape] 'keyboard-quit) +(define-key evil-visual-state-map [escape] 'keyboard-quit) +(define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit) +(define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit) +(define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit) +(define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit) +(define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit) + + +(require 'cl) ; for `flet` +(flet ((move-key (keymap-from keymap-to key) + (define-key keymap-to key (lookup-key keymap-from key)) + (define-key keymap-from key nil))) + ;; Keep space/return available for other modes + ;; http://emacswiki.org/emacs/Evil#toc11 + (move-key evil-motion-state-map evil-normal-state-map (kbd "RET")) + (move-key evil-motion-state-map evil-normal-state-map " ")) + +;; a la vim-surround +(require 'surround) +(add-hook 'prog-mode-hook + (lambda () + (turn-on-evil-mode) + (turn-on-surround-mode))) + +;; "tabs" (http://emacswiki.org/emacs/Evil#toc16) +(load "elscreen" "ElScreen" t) +(define-key evil-normal-state-map (kbd "C-w t") 'elscreen-create) ;create tab +(define-key evil-normal-state-map (kbd "C-w x") 'elscreen-kill) ;kill tab +(define-key evil-normal-state-map "gT" 'elscreen-previous) ;previous tab +(define-key evil-normal-state-map "gt" 'elscreen-next) ;next tab + +(require 'evil-paredit) +(add-hook 'emacs-lisp-mode-hook 'evil-paredit-mode) +(add-hook 'clojure-mode-hook 'evil-paredit-mode) +(add-hook 'common-lisp-mode-hook 'evil-paredit-mode) +(add-hook 'scheme-mode-hook 'evil-paredit-mode) +(add-hook 'lisp-mode-hook 'evil-paredit-mode) diff --git a/editors/emacs/bjeanes/bindings.el b/editors/emacs/bjeanes/bindings.el index ea957a56..56926bc5 100644 --- a/editors/emacs/bjeanes/bindings.el +++ b/editors/emacs/bjeanes/bindings.el @@ -1,3 +1,7 @@ (global-set-key (kbd "C-x M-f") 'ido-find-file-other-window) (global-set-key (kbd "C-x m") 'eshell) + +(define-key global-map (kbd "C-+") 'text-scale-increase) +(define-key global-map (kbd "C--") 'text-scale-decrease) + (define-key 'help-command "a" 'apropos) diff --git a/editors/emacs/bjeanes/clojure.el b/editors/emacs/bjeanes/clojure.el index f2a87db9..46739630 100644 --- a/editors/emacs/bjeanes/clojure.el +++ b/editors/emacs/bjeanes/clojure.el @@ -1,6 +1,7 @@ (require 'clojure-mode) (define-clojure-indent (defroutes 'defun) + (do-seq 1) (GET 2) (POST 2) (PUT 2) diff --git a/editors/emacs/bjeanes/go.el b/editors/emacs/bjeanes/go.el new file mode 100644 index 00000000..2e4e7dde --- /dev/null +++ b/editors/emacs/bjeanes/go.el @@ -0,0 +1,2 @@ +(require 'go-mode) +(gofmt-before-save) diff --git a/editors/emacs/bjeanes/misc.el b/editors/emacs/bjeanes/misc.el index a36c1bdf..cf380c2a 100644 --- a/editors/emacs/bjeanes/misc.el +++ b/editors/emacs/bjeanes/misc.el @@ -1,5 +1,5 @@ (require 'powerline) -(command-execute 'powerline-default) +(command-execute 'powerline-default-theme) (global-auto-revert-mode t) diff --git a/editors/emacs/bjeanes/programming.el b/editors/emacs/bjeanes/programming.el index 934a1fad..c101bebe 100644 --- a/editors/emacs/bjeanes/programming.el +++ b/editors/emacs/bjeanes/programming.el @@ -6,6 +6,20 @@ (require 'autopair) (autopair-mode 1) - ;; TODO: Look into whitespace-cleanup instead? + (define-key global-map (kbd "RET") 'newline-and-indent) + (add-hook 'before-save-hook - 'delete-trailing-whitespace))) + (lambda () + (gofmt-before-save) + (delete-trailing-whitespace))) + + (require 'auto-complete-config) + (ac-config-default))) + + +;;;;;;;; misc + +;; Auto-compile is really annoying if you have an existing +;; compilation process that puts the output elsewhere or names it +;; differently (e.g. Rails asset pipeline, Middleman, etc) +(setq scss-compile-at-save nil) diff --git a/editors/emacs/bjeanes/ruby.el b/editors/emacs/bjeanes/ruby.el index e40bf116..4f1fbba6 100644 --- a/editors/emacs/bjeanes/ruby.el +++ b/editors/emacs/bjeanes/ruby.el @@ -2,7 +2,8 @@ (require 'ruby-end) (require 'ruby-tools) -(custom-set-variables '(ruby-end-insert-newline nil)) +(custom-set-variables '(ruby-end-insert-newline nil) + '(ruby-deep-indent-paren nil)) (eval-after-load 'ruby-mode '(progn (add-hook 'ruby-mode-hook diff --git a/editors/emacs/bjeanes/snippets.el b/editors/emacs/bjeanes/snippets.el new file mode 100644 index 00000000..d15468bb --- /dev/null +++ b/editors/emacs/bjeanes/snippets.el @@ -0,0 +1,8 @@ +(require 'yasnippet) + +(add-to-list 'yas-snippet-dirs + (concat esk-user-dir "/snippets")) + +(yas-reload-all) + +(add-hook 'prog-mode-hook 'yas-minor-mode) diff --git a/editors/emacs/init.el b/editors/emacs/init.el index 07e68658..b337ae93 100644 --- a/editors/emacs/init.el +++ b/editors/emacs/init.el @@ -9,31 +9,54 @@ (package-refresh-contents)) ;; Add in your own as you wish: -(defvar my-packages '(starter-kit - starter-kit-ruby - starter-kit-lisp - starter-kit-eshell - starter-kit-js +(defvar my-packages '(ac-nrepl + auto-complete + autopair clojure-mode clojure-test-mode clojurescript-mode - autopair - ruby-tools - ruby-end - ruby-electric - markdown-mode color-theme - color-theme-molokai - rainbow-delimiters + color-theme-sanityinc-tomorrow ctags + evil + evil-paredit + exec-path-from-shell + find-file-in-repository + go-mode + markdown-mode paredit - undo-tree - org powerline - evil - surround) + rainbow-delimiters + ruby-electric + ruby-end + ruby-tools + starter-kit + starter-kit-eshell + starter-kit-js + starter-kit-lisp + starter-kit-ruby + surround + undo-tree + yasnippet) "A list of packages to ensure are installed at launch.") (dolist (p my-packages) (when (not (package-installed-p p)) (package-install p))) + +;; This takes a really long time because ZSH init scripts are TOO slow! +;; Thoughts: +;; * Extract a lot of non-interactive ZSH stuff to spawn from +;; .zshenv and adjust exec-path-from-shell to not start interactive +;; shell +(when (memq window-system '(mac ns)) + (exec-path-from-shell-initialize)) + +;; TODO: +;; * Go snippets +;; * Custom ruby/rspec snippetts +;; * proper auto-complete / intellisense +;; * auto pop-up (~100ms) +;; * intuitive TAB/ENTER support +;; * can be backed by REPL, ctags, buffer words, etc +;; * Plug snippets into auto-complete diff --git a/editors/emacs/spacemacs b/editors/emacs/spacemacs new file mode 100644 index 00000000..63dc39bc --- /dev/null +++ b/editors/emacs/spacemacs @@ -0,0 +1,238 @@ +;; -*- mode: dotspacemacs -*- +;; This file is loaded by Spacemacs at startup. +;; It must be stored in your home directory. + +(defun dotspacemacs/layers () + "Configuration Layers declaration." + (setq-default + ;; List of additional paths where to look for configuration layers. + ;; Paths must have a trailing slash (i.e. `~/.mycontribs/') + dotspacemacs-configuration-layer-path '() + ;; List of configuration layers to load. If it is the symbol `all' instead + ;; of a list then all discovered layers will be installed. + dotspacemacs-configuration-layers + '( + ;; ---------------------------------------------------------------- + ;; Example of useful layers you may want to use right away. + ;; Uncomment some layer names and press (Vim style) or + ;; (Emacs style) to install them. + ;; ---------------------------------------------------------------- + auto-completion + better-defaults + clojure + javascript + colors + dash + emacs-lisp + evil-commentary + git + github + go + markdown + osx + ruby + shell-scripts + rust + smex + sql + html + org + (shell :variables + shell-default-height 30 + shell-default-position 'bottom + shell-default-term-shell "/usr/local/bin/zsh") + syntax-checking + version-control) + ;; List of additional packages that will be installed without being + ;; wrapped in a layer. If you need some configuration for these + ;; packages then consider to create a layer, you can also put the + ;; configuration in `dotspacemacs/config'. + dotspacemacs-additional-packages + '(yaml-mode + haml-mode + gitconfig + ansi-color + aggressive-indent) + ;; A list of packages and/or extensions that will not be install and loaded. + dotspacemacs-excluded-packages '() + ;; If non-nil spacemacs will delete any orphan packages, i.e. packages that + ;; are declared in a layer which is not a member of + ;; the list `dotspacemacs-configuration-layers' + dotspacemacs-delete-orphan-packages t)) + +(defun dotspacemacs/init () + "Initialization function. +This function is called at the very startup of Spacemacs initialization +before layers configuration." + ;; This setq-default sexp is an exhaustive list of all the supported + ;; spacemacs settings. + (setq-default + ;; Either `vim' or `emacs'. Evil is always enabled but if the variable + ;; is `emacs' then the `holy-mode' is enabled at startup. + dotspacemacs-editing-style 'nil + ;; If non nil output loading progress in `*Messages*' buffer. + dotspacemacs-verbose-loading nil + ;; Specify the startup banner. Default value is `official', it displays + ;; the official spacemacs logo. An integer value is the index of text + ;; banner, `random' chooses a random text banner in `core/banners' + ;; directory. A string value must be a path to an image format supported + ;; by your Emacs build. + ;; If the value is nil then no banner is displayed. + dotspacemacs-startup-banner 'official + ;; List of items to show in the startup buffer. If nil it is disabled. + ;; Possible values are: `recents' `bookmarks' `projects'." + dotspacemacs-startup-lists '(recents projects) + ;; List of themes, the first of the list is loaded when spacemacs starts. + ;; Press T n to cycle to the next theme in the list (works great + ;; with 2 themes variants, one dark and one light) + dotspacemacs-themes '(monokai) + + ;; If non nil the cursor color matches the state color. + dotspacemacs-colorize-cursor-according-to-state t + ;; Default font. `powerline-scale' allows to quickly tweak the mode-line + ;; size to make separators look not too crappy. + dotspacemacs-default-font '(;"Source Code Pro" + "Inconsolata" + :size 13 + :weight normal + :width normal + :powerline-scale 1.1) + ;; The leader key + dotspacemacs-leader-key "SPC" + ;; The leader key accessible in `emacs state' and `insert state' + dotspacemacs-emacs-leader-key "M-m" + ;; Major mode leader key is a shortcut key which is the equivalent of + ;; pressing ` m`. Set it to `nil` to disable it. + dotspacemacs-major-mode-leader-key "," + ;; Major mode leader key accessible in `emacs state' and `insert state' + dotspacemacs-major-mode-emacs-leader-key "C-M-m" + ;; The command key used for Evil commands (ex-commands) and + ;; Emacs commands (M-x). + ;; By default the command key is `:' so ex-commands are executed like in Vim + ;; with `:' and Emacs commands are executed with ` :'. + dotspacemacs-command-key ":" + ;; Location where to auto-save files. Possible values are `original' to + ;; auto-save the file in-place, `cache' to auto-save the file to another + ;; file stored in the cache directory and `nil' to disable auto-saving. + ;; Default value is `cache'. + dotspacemacs-auto-save-file-location 'cache + ;; If non nil then `ido' replaces `helm' for some commands. For now only + ;; `find-files' (SPC f f) is replaced. + dotspacemacs-use-ido nil + ;; If non nil the paste micro-state is enabled. When enabled pressing `p` + ;; several times cycle between the kill ring content. + dotspacemacs-enable-paste-micro-state nil + ;; Guide-key delay in seconds. The Guide-key is the popup buffer listing + ;; the commands bound to the current keystrokes. + dotspacemacs-guide-key-delay 0.4 + ;; If non nil a progress bar is displayed when spacemacs is loading. This + ;; may increase the boot time on some systems and emacs builds, set it to + ;; nil ;; to boost the loading time. + dotspacemacs-loading-progress-bar t + ;; If non nil the frame is fullscreen when Emacs starts up. + ;; (Emacs 24.4+ only) + dotspacemacs-fullscreen-at-startup nil + ;; If non nil `spacemacs/toggle-fullscreen' will not use native fullscreen. + ;; Use to disable fullscreen animations in OSX." + dotspacemacs-fullscreen-use-non-native t + ;; If non nil the frame is maximized when Emacs starts up. + ;; Takes effect only if `dotspacemacs-fullscreen-at-startup' is nil. + ;; (Emacs 24.4+ only) + dotspacemacs-maximized-at-startup nil + ;; A value from the range (0..100), in increasing opacity, which describes + ;; the transparency level of a frame when it's active or selected. + ;; Transparency can be toggled through `toggle-transparency'. + dotspacemacs-active-transparency 90 + ;; A value from the range (0..100), in increasing opacity, which describes + ;; the transparency level of a frame when it's inactive or deselected. + ;; Transparency can be toggled through `toggle-transparency'. + dotspacemacs-inactive-transparency 90 + ;; If non nil unicode symbols are displayed in the mode line. + dotspacemacs-mode-line-unicode-symbols nil + ;; If non nil smooth scrolling (native-scrolling) is enabled. Smooth + ;; scrolling overrides the default behavior of Emacs which recenters the + ;; point when it reaches the top or bottom of the screen. + dotspacemacs-smooth-scrolling t + ;; If non-nil smartparens-strict-mode will be enabled in programming modes. + dotspacemacs-smartparens-strict-mode t + ;; Select a scope to highlight delimiters. Possible value is `all', + ;; `current' or `nil'. Default is `all' + dotspacemacs-highlight-delimiters 'all + ;; If non nil advises quit functions to keep server open when quitting. + dotspacemacs-persistent-server nil + ;; List of search tool executable names. Spacemacs uses the first installed + ;; tool of the list. Supported tools are `ag', `pt', `ack' and `grep'. + dotspacemacs-search-tools '("ag" "pt" "ack" "grep") + ;; The default package repository used if no explicit repository has been + ;; specified with an installed package. + ;; Not used for now. + dotspacemacs-default-package-repository nil + + ruby-version-manager 'chruby + ) + ;; User initialization goes here + + (add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/")) + + (add-to-list 'package-pinned-packages '(cider . "melpa-stable") t) + (add-to-list 'package-pinned-packages '(clj-refactor . "melpa-stable") t) + (add-to-list 'package-pinned-packages '(cljr-helm . "melpa-stable") t) + (add-to-list 'package-pinned-packages '(ac-cider . "melpa-stable") t) + (add-to-list 'package-pinned-packages '(projectile . "melpa-stable") t) + ) + +(defun dotspacemacs/config () + "Configuration function. + This function is called at the very end of Spacemacs initialization after +layers configuration." + (setq magit-repository-directories '("~/Code/")) + (setq clojure-enable-fancify-symbols t) + + (add-hook 'prog-mode-hook 'linum-mode) + (add-hook 'prog-mode-hook 'aggressive-indent-mode) + + ;; Load shell for commands (e.g. *compilation* buffers) so that correct + ;; environment (chruby, etc) is sourced + (setq shell-file-name "bash") + (setq shell-command-switch "-ic") + + ;; colourize compilation buffer + (ignore-errors + (require 'ansi-color) + (defun my-colorize-compilation-buffer () + (when (eq major-mode 'compilation-mode) + (ansi-color-apply-on-region compilation-filter-start (point-max)))) + (add-hook 'compilation-filter-hook 'my-colorize-compilation-buffer))) + +;; Do not write anything past this comment. This is where Emacs will +;; auto-generate custom variable definitions. +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(ahs-case-fold-search nil) + '(ahs-default-range (quote ahs-range-whole-buffer)) + '(ahs-idle-interval 0.25) + '(ahs-idle-timer 0 t) + '(ahs-inhibit-face-list nil) + '(org-babel-process-comment-text (quote org-babel-trim)) + '(org-export-babel-evaluate (quote inline-only)) + '(paradox-github-token t) + '(projectile-use-git-grep t) + '(ring-bell-function (quote ignore) t) + '(safe-local-variable-values + (quote + ((org-babel-clojure-backend + (quote cider)) + (org-export-htmlize-output-type + (quote css)) + (org-export-html-style-include-default) + (org-export-html-style-include-scripts))))) +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(company-tooltip-common ((t (:inherit company-tooltip :weight bold :underline nil)))) + '(company-tooltip-common-selection ((t (:inherit company-tooltip-selection :weight bold :underline nil))))) diff --git a/editors/vim/.gitignore b/editors/vim/.gitignore index 8178c623..a31c1ec3 100644 --- a/editors/vim/.gitignore +++ b/editors/vim/.gitignore @@ -1,2 +1,2 @@ -bundle/vim-peepopen +plugged/* dirs/* diff --git a/editors/vim/after/ftplugin/sh.vim b/editors/vim/after/ftplugin/sh.vim new file mode 100644 index 00000000..df7eb071 --- /dev/null +++ b/editors/vim/after/ftplugin/sh.vim @@ -0,0 +1,3 @@ +setlocal shiftwidth=2 +setlocal tabstop=2 +setlocal noexpandtab diff --git a/editors/vim/after/syntax/ruby.vim b/editors/vim/after/syntax/ruby.vim index 84953204..72bb4cda 100644 --- a/editors/vim/after/syntax/ruby.vim +++ b/editors/vim/after/syntax/ruby.vim @@ -1,11 +1,15 @@ -" RSpec +if expand('%') =~# '_spec\.rb$' + syn keyword rubyRspec describe context it specify it_should_behave_like before after setup subject let shared_context shared_examples_for shared_examples +endif - " Syntax highlighting - if expand('%') =~# '_spec\.rb$' - syn keyword rubyRspec describe context it specify it_should_behave_like before after setup subject let shared_context shared_examples_for - endif +hi def link rubyRspec Function - hi def link rubyRspec Function +nmap rf mr:set foldmethod=syntaxzMzv?\v^\s*(it\|example)zz:noh`r:delmarks r + +let s:bcs = b:current_syntax +unlet b:current_syntax +syntax include @SQL syntax/sql.vim +let b:current_syntax = s:bcs + +syntax region hereDocDashSQL matchgroup=Statement start=+<<[-~.]\?\z(SQL\%(DOC\)\?\)+ end=+^\s*\z1+ contains=@SQL - " Focus folding on spec" - nmap rf mr:set foldmethod=syntaxzMzv?\v^\s*(it\|example)zz:noh`r:delmarks r diff --git a/editors/vim/autocommands.vim b/editors/vim/autocommands.vim deleted file mode 100644 index b7462711..00000000 --- a/editors/vim/autocommands.vim +++ /dev/null @@ -1,55 +0,0 @@ - -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 - -" Strip trailing whitespace on command -nmap sw :call StripTrailingWhitespaces() - -" http://vim.wikia.com/wiki/Auto_highlight_current_word_when_idle -" augroup auto_highlight - " au! - " set updatetime=500 - " au CursorHold * let @/ = '\V\<'.escape(expand(''), '\').'\>' -" augroup end - -augroup the_rest - au! - - " Attempted fix for Vim losing mouse support when inside Tmux - autocmd TermResponse,CursorHold,CursorHoldI * set ttymouse=xterm2 - - " Create parent directory if it doesn't exist before writing file - " (http://stackoverflow.com/questions/4292733/vim-creating-parent-directories-on-save) - autocmd BufWritePre * if expand("")!~#'^\w\+:/' && !isdirectory(expand("%:h")) | execute "silent! !mkdir -p ".shellescape(expand('%:h'), 1) | redraw! | endif - - " Source vimrc after saving it - autocmd BufWritePost .vimrc,vimrc source $MYVIMRC | NERDTreeToggle | NERDTreeToggle - - " Auto save files on window blur - autocmd FocusLost * :silent! up - - " make and python use real tabs - autocmd FileType make set noexpandtab - autocmd FileType python set noexpandtab - - autocmd FileType scss syntax cluster sassCssAttributes add=@cssColors - - " Thorfile, Rakefile and Gemfile are Ruby - autocmd BufRead,BufNewFile {Gemfile,Rakefile,Thorfile,config.ru} set ft=ruby - - autocmd BufRead,BufNewFile gitconfig set ft=gitconfig - - " Strip trailing whitespace on save - autocmd BufWritePre * :call StripTrailingWhitespaces() -augroup end - - diff --git a/editors/vim/autoload/.gitignore b/editors/vim/autoload/.gitignore new file mode 100644 index 00000000..43c9cabb --- /dev/null +++ b/editors/vim/autoload/.gitignore @@ -0,0 +1 @@ +plug.vim diff --git a/editors/vim/bundle/.gitignore b/editors/vim/bundle/.gitignore deleted file mode 100644 index 72e8ffc0..00000000 --- a/editors/vim/bundle/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/editors/vim/bundle/vundle b/editors/vim/bundle/vundle deleted file mode 160000 index 3bf598d1..00000000 --- a/editors/vim/bundle/vundle +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3bf598d169993d703c21115876c36e460a51b100 diff --git a/editors/vim/bundles.vim b/editors/vim/bundles.vim deleted file mode 100644 index 86dcaab4..00000000 --- a/editors/vim/bundles.vim +++ /dev/null @@ -1,187 +0,0 @@ -augroup bundles - autocmd! - - filetype off - - set rtp+=~/.vim/bundle/vundle/ - call vundle#rc() - - " Let Vundle manage Vundle - Bundle 'gmarik/vundle' - - " Languages/Syntaxes/Frameworks {{{ - " Ruby {{{ - Bundle 'vim-ruby/vim-ruby' - Bundle 'tpope/vim-endwise' - Bundle 'tpope/vim-rake' - Bundle 'tpope/vim-haml' - Bundle 'ecomba/vim-ruby-refactoring' - Bundle 'thisivan/vim-ruby-matchit' - - Bundle 'tpope/vim-cucumber' - " }}} - - " Clojure {{{ - Bundle 'paredit.vim' - Bundle 'VimClojure' - let g:vimclojure#ParenRainbow = 1 - let vimclojure#FuzzyIndent = 1 - autocmd FileType clojure set lispwords-='->' - autocmd FileType clojure set lispwords-='->>' - " }}} - - " Markdown/Textile/etc {{{ - Bundle 'tpope/vim-markdown' - Bundle 'matthias-guenther/hammer.vim' - " }}} - - " HTML/CSS/Javascript {{{ - Bundle 'kchmck/vim-coffee-script' - Bundle 'pangloss/vim-javascript' - Bundle 'css3' - Bundle 'othree/html5-syntax.vim' - " }}} - - " }}} - - " Git {{{ - Bundle 'tpope/vim-fugitive' - Bundle 'tpope/vim-git' - Bundle 'tjennings/git-grep-vim' - " }}} - - " Text objects {{{ - Bundle 'kana/vim-textobj-user' - Bundle 'nelstrom/vim-textobj-rubyblock' - Bundle 'michaeljsmith/vim-indent-object' - Bundle 'argtextobj.vim' - " }}} - - " Utility {{{ - - Bundle 'tpope/vim-surround' - - Bundle 'Raimondi/delimitMate' - autocmd FileType clojure let delimitMate_quotes = "\"" - - Bundle 'AutoComplPop' - let g:acp_enableAtStartup = 0 - let g:acp_completeoptPreview = 1 - let g:acp_behaviorKeywordLength = 3 - let g:acp_behaviorKeywordIgnores = [ - \ 'the', 'def', 'end', - \ 'else', 'elsif', 'elif', 'endif', 'then', - \ 'case', 'done', 'do' - \ ] - - Bundle 'Lokaltog/vim-easymotion' - let g:EasyMotion_keys = "arstdhneio" " Colemak home row - - Bundle 'Lokaltog/vim-powerline' - - Bundle 'Gundo' - nnoremap u :GundoToggle - - Bundle 'kien/rainbow_parentheses.vim' - autocmd VimEnter *.{rb,coffee} RainbowParenthesesToggle - autocmd Syntax *.{rb,coffee} RainbowParenthesesLoadRound - autocmd Syntax *.{rb,coffee} RainbowParenthesesLoadSquare - autocmd Syntax *.{rb,coffee} RainbowParenthesesLoadBraces - - Bundle 'Tabular' - autocmd VimEnter * AddTabularPattern! first_eq /\%(=.*\)\@=]\@!/l1c1l0 - autocmd VimEnter * AddTabularPattern! first_rocket /\%(=>.*\)\@/l1c1l0 - autocmd VimEnter * AddTabularPattern! first_key /\v%(%(\h\w*|"[^"]+"):.*)@ a = mT:Tabularize first_eq`T - nmap a> mT:Tabularize first_rocket`T - nmap a: mT:Tabularize first_key`T - - vmap a= :Tabularize first_eqgv - vmap a> :Tabularize first_rocketgv - vmap a: :Tabularize first_keygv - - " Auto-align - "" Cucumber - inoremap :call align()a - function! s:align() - let p = '^\s*|\s.*\s|\s*$' - if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p) - let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g')) - let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*')) - Tabularize/|/l1 - normal! 0 - call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.')) - endif - endfunction - - Bundle 'scrooloose/nerdcommenter' - let NERDCreateDefaultMappings = 0 - let NERDSpaceDelims = 1 " space between comment and code - map // NERDCommenterToggle - vmap // NERDCommenterToggle gv - map / // - vmap / // - - Bundle 'ZoomWin' - map z :ZoomWin - imap z :ZoomWina - - Bundle 'vimwiki' - let g:vimwiki_hl_cb_checked = 1 - let g:vimwiki_menu = 'Plugin.Vimwiki' - let g:vimwiki_badsyms = ' ' - let g:vimwiki_use_mouse = 1 - let g:vimwiki_dir_link = 'index' - let g:vimwiki_list = [ - \ { - \ 'path': '~/Dropbox/Wiki/Text', - \ 'path_html': '~/Dropbox/Wiki/HTML', - \ 'nested_syntaxes': { - \ 'ruby': 'ruby' - \ } - \ } - \] - - Bundle 'scrooloose/nerdtree' - let g:NERDTreeIgnore = ['\.rbc$', '\~$', '.DS_Store$'] - let g:NERDTreeChDirMode = 2 - let g:NERDTreeMouseMode = 3 - let g:NERDTreeQuitOnOpen = 1 - let g:NERDTreeMinimalUI = 1 - let g:NERDTreeDirArrows = 1 - let g:NERDTreeHijackNetrw = 0 - map n :NERDTreeToggle - map N :NERDTreeFind - - Bundle 'Command-T' - let g:CommandTMaxFiles = 20000 - let g:CommandTMaxHeight = 10 - nnoremap t :CommandT - nnoremap b :CommandTBuffer - nnoremap f :CommandTFlush - - Bundle 'Indent-Guides' - let g:indent_guides_auto_colors = 0 - let g:indent_guides_enable_on_vim_startup = 1 - autocmd VimEnter * IndentGuidesEnable - autocmd FileType clojure IndentGuidesDisable - - Bundle 'Syntastic' - let g:syntastic_enable_signs = 1 - let g:syntastic_auto_loc_list = 0 - let g:syntastic_disabled_filetypes = ['cucumber'] - " }}} - - " Other {{{ - Bundle 'AnsiEsc.vim' - Bundle 'thisivan/vim-matchit' - - Bundle 'aklt/plantuml-syntax' - au BufNewFile,BufRead *.uml set filetype=plantuml - " }}} - - autocmd BufWritePost bundles.vim source ~/.vim/bundles.vim - filetype plugin indent on -augroup END diff --git a/editors/vim/coc-settings.json b/editors/vim/coc-settings.json new file mode 100644 index 00000000..ce8ec0dc --- /dev/null +++ b/editors/vim/coc-settings.json @@ -0,0 +1,31 @@ +{ + "coc.preferences.formatOnSaveFiletypes": [ + "html", + "json", + "css", + "markdown", + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "rust" + ], + "coc.preferences.colorSupport": true, + + "diagnostic.displayByAle": true, + + "suggest.echodocSupport": true, + + "codeLens.separator": "👓", + "codeLens.enable": true, + + "tsserver.enableJavascript": false, + + "solargraph.autoformat": true, + "solargraph.formatting": true, + + "html.autoClosingTags": true, + + "languageserver": { + } +} diff --git a/editors/vim/colors/Tomorrow-Night.vim b/editors/vim/colors/Tomorrow-Night.vim deleted file mode 100644 index 203239b6..00000000 --- a/editors/vim/colors/Tomorrow-Night.vim +++ /dev/null @@ -1,334 +0,0 @@ -" Tomorrow Night - Full Colour and 256 Colour -" http://chriskempson.com -" -" Hex colour conversion functions borrowed from the theme "Desert256"" - -" Default GUI Colours -let s:foreground = "c5c8c6" -let s:background = "1d1f21" -let s:selection = "373b41" -let s:line = "282a2e" -let s:comment = "969896" -let s:red = "cc6666" -let s:orange = "de935f" -let s:yellow = "f0c674" -let s:green = "b5bd68" -let s:aqua = "8abeb7" -let s:blue = "81a2be" -let s:purple = "b294bb" - -" Console 256 Colours -if !has("gui_running") - let s:background = "303030" - let s:line = "3a3a3a" - let s:selection = "585858" -end - -set background=dark -hi clear -syntax reset - -let g:colors_name = "Tomorrow-Night" - -if has("gui_running") || &t_Co == 88 || &t_Co == 256 - " Returns an approximate grey index for the given grey level - fun grey_number(x) - if &t_Co == 88 - if a:x < 23 - return 0 - elseif a:x < 69 - return 1 - elseif a:x < 103 - return 2 - elseif a:x < 127 - return 3 - elseif a:x < 150 - return 4 - elseif a:x < 173 - return 5 - elseif a:x < 196 - return 6 - elseif a:x < 219 - return 7 - elseif a:x < 243 - return 8 - else - return 9 - endif - else - if a:x < 14 - return 0 - else - let l:n = (a:x - 8) / 10 - let l:m = (a:x - 8) % 10 - if l:m < 5 - return l:n - else - return l:n + 1 - endif - endif - endif - endfun - - " Returns the actual grey level represented by the grey index - fun grey_level(n) - if &t_Co == 88 - if a:n == 0 - return 0 - elseif a:n == 1 - return 46 - elseif a:n == 2 - return 92 - elseif a:n == 3 - return 115 - elseif a:n == 4 - return 139 - elseif a:n == 5 - return 162 - elseif a:n == 6 - return 185 - elseif a:n == 7 - return 208 - elseif a:n == 8 - return 231 - else - return 255 - endif - else - if a:n == 0 - return 0 - else - return 8 + (a:n * 10) - endif - endif - endfun - - " Returns the palette index for the given grey index - fun grey_colour(n) - if &t_Co == 88 - if a:n == 0 - return 16 - elseif a:n == 9 - return 79 - else - return 79 + a:n - endif - else - if a:n == 0 - return 16 - elseif a:n == 25 - return 231 - else - return 231 + a:n - endif - endif - endfun - - " Returns an approximate colour index for the given colour level - fun rgb_number(x) - if &t_Co == 88 - if a:x < 69 - return 0 - elseif a:x < 172 - return 1 - elseif a:x < 230 - return 2 - else - return 3 - endif - else - if a:x < 75 - return 0 - else - let l:n = (a:x - 55) / 40 - let l:m = (a:x - 55) % 40 - if l:m < 20 - return l:n - else - return l:n + 1 - endif - endif - endif - endfun - - " Returns the actual colour level for the given colour index - fun rgb_level(n) - if &t_Co == 88 - if a:n == 0 - return 0 - elseif a:n == 1 - return 139 - elseif a:n == 2 - return 205 - else - return 255 - endif - else - if a:n == 0 - return 0 - else - return 55 + (a:n * 40) - endif - endif - endfun - - " Returns the palette index for the given R/G/B colour indices - fun rgb_colour(x, y, z) - if &t_Co == 88 - return 16 + (a:x * 16) + (a:y * 4) + a:z - else - return 16 + (a:x * 36) + (a:y * 6) + a:z - endif - endfun - - " Returns the palette index to approximate the given R/G/B colour levels - fun colour(r, g, b) - " Get the closest grey - let l:gx = grey_number(a:r) - let l:gy = grey_number(a:g) - let l:gz = grey_number(a:b) - - " Get the closest colour - let l:x = rgb_number(a:r) - let l:y = rgb_number(a:g) - let l:z = rgb_number(a:b) - - if l:gx == l:gy && l:gy == l:gz - " There are two possibilities - let l:dgr = grey_level(l:gx) - a:r - let l:dgg = grey_level(l:gy) - a:g - let l:dgb = grey_level(l:gz) - a:b - let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb) - let l:dr = rgb_level(l:gx) - a:r - let l:dg = rgb_level(l:gy) - a:g - let l:db = rgb_level(l:gz) - a:b - let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db) - if l:dgrey < l:drgb - " Use the grey - return grey_colour(l:gx) - else - " Use the colour - return rgb_colour(l:x, l:y, l:z) - endif - else - " Only one possibility - return rgb_colour(l:x, l:y, l:z) - endif - endfun - - " Returns the palette index to approximate the 'rrggbb' hex string - fun rgb(rgb) - let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0 - let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0 - let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0 - - return colour(l:r, l:g, l:b) - endfun - - " Sets the highlighting for the given group - fun X(group, fg, bg, attr) - if a:fg != "" - exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . rgb(a:fg) - endif - if a:bg != "" - exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . rgb(a:bg) - endif - if a:attr != "" - exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr - endif - endfun - - " Vim Highlighting - call X("Normal", s:foreground, s:background, "") - call X("LineNr", s:foreground, "", "") - call X("NonText", s:selection, "", "") - call X("SpecialKey", s:selection, "", "") - call X("Search", s:background, s:yellow, "") - call X("TabLine", s:foreground, s:background, "reverse") - call X("StatusLine", s:foreground, s:background, "reverse") - call X("StatusLineNC", s:foreground, s:background, "reverse") - call X("Visual", "", s:selection, "") - call X("Directory", s:blue, "", "") - call X("ModeMsg", s:green, "", "") - call X("MoreMsg", s:green, "", "") - call X("Question", s:green, "", "") - call X("WarningMsg", s:red, "", "") - if version >= 700 - call X("CursorLine", "", s:line, "none") - call X("CursorColumn", "", s:line, "none") - call X("PMenu", s:foreground, s:selection, "none") - call X("PMenuSel", s:foreground, s:selection, "reverse") - end - - " Standard Highlighting - call X("Comment", s:comment, "", "") - call X("Todo", s:comment, "", "") - call X("Title", s:comment, "", "") - call X("Identifier", s:red, "", "none") - call X("Statement", s:foreground, "", "") - call X("Conditional", s:foreground, "", "") - call X("Repeat", s:foreground, "", "") - call X("Structure", s:purple, "", "") - call X("Function", s:blue, "", "") - call X("Constant", s:orange, "", "") - call X("String", s:green, "", "") - call X("Special", s:foreground, "", "") - call X("PreProc", s:purple, "", "") - call X("Operator", s:aqua, "", "none") - call X("Type", s:blue, "", "none") - call X("Define", s:purple, "", "none") - call X("Include", s:blue, "", "") - "call X("Ignore", "666666", "", "") - - " Vim Highlighting - call X("vimCommand", s:red, "", "none") - - " C Highlighting - call X("cType", s:yellow, "", "") - call X("cStorageClass", s:purple, "", "") - - " PHP Highlighting - call X("phpVarSelector", s:red, "", "") - call X("phpKeyword", s:purple, "", "") - call X("phpRepeat", s:purple, "", "") - call X("phpConditional", s:purple, "", "") - call X("phpStatement", s:purple, "", "") - call X("phpMemberSelector", s:foreground, "", "") - - " Ruby Highlighting - call X("rubySymbol", s:green, "", "") - call X("rubyConstant", s:yellow, "", "") - call X("rubyAttribute", s:blue, "", "") - call X("rubyInclude", s:blue, "", "") - call X("rubyLocalVariableOrMethod", s:orange, "", "") - call X("rubyCurlyBlock", s:orange, "", "") - - " Python Highlighting - call X("pythonInclude", s:purple, "", "") - call X("pythonStatement", s:purple, "", "") - call X("pythonConditional", s:purple, "", "") - call X("pythonFunction", s:blue, "", "") - - " JavaScript Highlighting - call X("javaScriptBraces", s:foreground, "", "") - call X("javaScriptFunction", s:purple, "", "") - call X("javaScriptConditional", s:purple, "", "") - call X("javaScriptRepeat", s:purple, "", "") - call X("javaScriptNumber", s:orange, "", "") - call X("javaScriptMember", s:orange, "", "") - - " Ident Guides - " call X("IndentGuidesOdd", "", s:background, "") - call X("IndentGuidesEven", "", s:line, "") - - " Delete Functions - delf X - delf rgb - delf colour - delf rgb_colour - delf rgb_level - delf rgb_number - delf grey_colour - delf grey_level - delf grey_number -endif diff --git a/editors/vim/colors/molokai_mac.vim b/editors/vim/colors/molokai_mac.vim deleted file mode 100644 index 7f9ef208..00000000 --- a/editors/vim/colors/molokai_mac.vim +++ /dev/null @@ -1,218 +0,0 @@ -" Vim color file -" -" Author: Tomas Restrepo -" -" Note: Based on the monokai theme for textmate -" by Wimer Hazenberg and its darker variant -" by Hamish Stuart Macpherson -" -" A few additional edits by Mac (http://veryhappythings.github.com) - -hi clear - -set background=dark -if version > 580 - " no guarantees for version 5.8 and below, but this makes it stop - " complaining - hi clear - if exists("syntax_on") - syntax reset - endif -endif -let g:colors_name="molokai_mac" - -if exists("g:molokai_original") - let s:molokai_original = g:molokai_original -else - let s:molokai_original = 0 -endif - - -hi Boolean guifg=#AE81FF -hi Character guifg=#E6DB74 -hi Number guifg=#AE81FF -hi String guifg=#E6DB74 -hi Conditional guifg=#D06189 gui=bold -hi Constant guifg=#AE81FF gui=bold -hi Cursor guifg=#000000 guibg=#F8F8F0 -hi Debug guifg=#BCA3A3 gui=bold -hi Define guifg=#66D9EF -hi Delimiter guifg=#8F8F8F -hi DiffAdd guibg=#13354A -hi DiffChange guifg=#89807D guibg=#4C4745 -hi DiffDelete guifg=#960050 guibg=#1E0010 -hi DiffText guibg=#4C4745 gui=italic,bold - -hi Directory guifg=#A6E22E gui=bold -hi Error guifg=#960050 guibg=#1E0010 -hi ErrorMsg guifg=#F92672 guibg=#232526 gui=bold -hi Exception guifg=#A6E22E gui=bold -hi Float guifg=#AE81FF -hi FoldColumn guifg=#465457 guibg=#000000 -hi Folded guifg=#465457 guibg=#000000 -hi Function guifg=#A6E22E -hi Identifier guifg=#FD971F -hi Ignore guifg=#808080 guibg=bg -hi IncSearch guifg=#C4BE89 guibg=#000000 - -hi Keyword guifg=#F977B3 gui=bold -hi Label guifg=#E6DB74 gui=none -hi Macro guifg=#C4BE89 gui=italic -hi SpecialKey guifg=#66D9EF gui=bold - -hi MatchParen guifg=#000000 guibg=#DD770D gui=bold -hi ModeMsg guifg=#E6DB74 -hi MoreMsg guifg=#E6DB74 -hi Operator guifg=#F92672 - -" complete menu -hi Pmenu guifg=#66D9EF guibg=#000000 -hi PmenuSel guibg=#808080 -hi PmenuSbar guibg=#080808 -hi PmenuThumb guifg=#66D9EF - -hi PreCondit guifg=#A6E22E gui=bold -hi PreProc guifg=#A6E22E -hi Question guifg=#66D9EF -hi Repeat guifg=#F92672 gui=bold -hi Search guifg=#FFFFFF guibg=#455354 -" marks column -hi SignColumn guifg=#A6E22E guibg=#232526 -hi SpecialChar guifg=#F92672 gui=bold -hi SpecialComment guifg=#465457 gui=bold -hi Special guifg=#66D9EF guibg=bg gui=italic -hi SpecialKey guifg=#888A85 gui=italic -if has("spell") - hi SpellBad guisp=#FF0000 gui=undercurl - hi SpellCap guisp=#7070F0 gui=undercurl - hi SpellLocal guisp=#70F0F0 gui=undercurl - hi SpellRare guisp=#FFFFFF gui=undercurl -endif -hi Statement guifg=#E27B9D -hi StatusLine guifg=#455354 guibg=fg -hi StatusLineNC guifg=#808080 guibg=#080808 -hi StorageClass guifg=#FD971F gui=italic -hi Structure guifg=#66D9EF -hi Tag guifg=#F92672 gui=italic -hi Title guifg=#ef5939 -hi Todo guifg=#FFFFFF guibg=bg gui=bold - -hi Typedef guifg=#66D9EF -hi Type guifg=#66D9EF gui=none -hi Underlined guifg=#808080 gui=underline - -hi VertSplit guifg=#808080 guibg=#080808 gui=bold -hi VisualNOS guibg=#403D3D -hi Visual guibg=#403D3D -hi WarningMsg guifg=#FFFFFF guibg=#333333 gui=bold -hi WildMenu guifg=#66D9EF guibg=#000000 - -if s:molokai_original == 1 - hi Normal guifg=#F8F8F2 guibg=#272822 - hi Comment guifg=#938E77 - hi CursorLine guibg=#3E3D32 - hi CursorColumn guibg=#3E3D32 - hi LineNr guifg=#BCBCBC guibg=#3B3A32 - hi NonText guifg=#BCBCBC guibg=#3B3A32 -else - hi Normal guifg=#F8F8F2 guibg=#1B1D1E - hi Comment guifg=#465457 - hi CursorLine guibg=#293739 - hi CursorColumn guibg=#293739 - hi LineNr guifg=#BCBCBC guibg=#232526 - hi NonText guifg=#BCBCBC guibg=#232526 -end - -" -" Support for 256-color terminal -" -if &t_Co > 255 - hi Boolean ctermfg=135 - hi Character ctermfg=144 - hi Number ctermfg=135 - hi String ctermfg=144 - hi Conditional ctermfg=161 cterm=bold - hi Constant ctermfg=135 cterm=bold - hi Cursor ctermfg=16 ctermbg=253 - hi Debug ctermfg=225 cterm=bold - hi Define ctermfg=81 - hi Delimiter ctermfg=241 - - hi DiffAdd ctermbg=24 - hi DiffChange ctermfg=181 ctermbg=239 - hi DiffDelete ctermfg=162 ctermbg=53 - hi DiffText ctermbg=102 cterm=bold - - hi Directory ctermfg=118 cterm=bold - hi Error ctermfg=219 ctermbg=89 - hi ErrorMsg ctermfg=199 ctermbg=16 cterm=bold - hi Exception ctermfg=118 cterm=bold - hi Float ctermfg=135 - hi FoldColumn ctermfg=67 ctermbg=16 - hi Folded ctermfg=67 ctermbg=16 - hi Function ctermfg=118 - hi Identifier ctermfg=208 - hi Ignore ctermfg=244 ctermbg=232 - hi IncSearch ctermfg=193 ctermbg=16 - - hi Keyword ctermfg=161 cterm=bold - hi Label ctermfg=229 cterm=none - hi Macro ctermfg=193 - hi SpecialKey ctermfg=81 - - hi MatchParen ctermfg=16 ctermbg=208 cterm=bold - hi ModeMsg ctermfg=229 - hi MoreMsg ctermfg=229 - hi Operator ctermfg=161 - - " complete menu - hi Pmenu ctermfg=81 ctermbg=16 - hi PmenuSel ctermbg=244 - hi PmenuSbar ctermbg=232 - hi PmenuThumb ctermfg=81 - - hi PreCondit ctermfg=118 cterm=bold - hi PreProc ctermfg=118 - hi Question ctermfg=81 - hi Repeat ctermfg=161 cterm=bold - hi Search ctermfg=253 ctermbg=66 - - " marks column - hi SignColumn ctermfg=118 ctermbg=234 - hi SpecialChar ctermfg=161 cterm=bold - hi SpecialComment ctermfg=245 cterm=bold - hi Special ctermfg=81 ctermbg=232 - hi SpecialKey ctermfg=245 - - hi Statement ctermfg=161 cterm=bold - hi StatusLine ctermfg=238 ctermbg=253 - hi StatusLineNC ctermfg=244 ctermbg=232 - hi StorageClass ctermfg=208 - hi Structure ctermfg=81 - hi Tag ctermfg=161 - hi Title ctermfg=166 - hi Todo ctermfg=231 ctermbg=232 cterm=bold - - hi Typedef ctermfg=81 - hi Type ctermfg=81 cterm=none - hi Underlined ctermfg=244 cterm=underline - - hi VertSplit ctermfg=244 ctermbg=232 cterm=bold - hi VisualNOS ctermbg=238 - hi Visual ctermbg=235 - hi WarningMsg ctermfg=231 ctermbg=238 cterm=bold - hi WildMenu ctermfg=81 ctermbg=16 - - hi Normal ctermfg=252 ctermbg=233 - hi Comment ctermfg=59 - hi CursorLine ctermbg=234 cterm=none - hi CursorColumn ctermbg=234 - hi LineNr ctermfg=237 ctermbg=234 - hi NonText ctermfg=238 - - hi IndentGuidesEven ctermbg=234 - hi ShowMarksHLo ctermfg=208 ctermbg=234 - hi ShowMarksHLl ctermfg=208 ctermbg=234 - hi ShowMarksHLu ctermfg=208 ctermbg=234 - hi ShowMarksHLm ctermfg=208 ctermbg=234 -end diff --git a/editors/vim/colors/railscasts.vim b/editors/vim/colors/railscasts.vim deleted file mode 100644 index 22aa0a43..00000000 --- a/editors/vim/colors/railscasts.vim +++ /dev/null @@ -1,100 +0,0 @@ -" Vim color scheme -" -" Name: railscasts.vim -" Maintainer: Nick Moffitt -" Last Change: 01 Mar 2008 -" License: WTFPL -" Version: 2.1 -" -" This theme is based on Josh O'Rourke's Vim clone of the railscast -" textmate theme. The key thing I have done here is supply 256-color -" terminal equivalents for as many of the colors as possible, and fixed -" up some of the funny behaviors for editing e-mails and such. -" -" To use for gvim: -" 1: install this file as ~/.vim/colors/railscasts.vim -" 2: put "colorscheme railscasts" in your .gvimrc -" -" If you are using Ubuntu, you can get the benefit of this in your -" terminals using ordinary vim by taking the following steps: -" -" 1: sudo apt-get install ncurses-term -" 2: put the following in your .vimrc -" if $COLORTERM == 'gnome-terminal' -" set term=gnome-256color -" colorscheme railscasts -" else -" colorscheme default -" endif -" 3: if you wish to use this with screen, add the following to your .screenrc: -" attrcolor b ".I" -" termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm' -" defbce "on" -" term screen-256color-bce - -set background=dark -hi clear -if exists("syntax_on") - syntax reset -endif - -let g:colors_name = "railscasts" - -hi link htmlTag xmlTag -hi link htmlTagName xmlTagName -hi link htmlEndTag xmlEndTag - -hi Directory guifg=#CC7833 ctermfg=173 cterm=NONE -hi NonText guifg=#565656 ctermfg=240 cterm=NONE -hi SpecialKey guifg=#565656 ctermfg=240 cterm=NONE - -highlight Normal guifg=#E6E1DC guibg=#111111 -highlight Cursor guifg=#000000 ctermfg=0 guibg=#FFFFFF ctermbg=15 -highlight CursorLine guibg=#000000 ctermbg=233 cterm=NONE - -highlight Comment guifg=#BC9458 ctermfg=180 gui=italic -highlight Constant guifg=#6D9CBE ctermfg=73 -highlight Define guifg=#CC7833 ctermfg=173 -highlight Error guifg=#FFC66D ctermfg=221 guibg=#990000 ctermbg=88 -highlight Function guifg=#FFC66D ctermfg=221 gui=NONE cterm=NONE -highlight Identifier guifg=#6D9CBE ctermfg=73 gui=NONE cterm=NONE -highlight Include guifg=#CC7833 ctermfg=173 gui=NONE cterm=NONE -highlight PreCondit guifg=#CC7833 ctermfg=173 gui=NONE cterm=NONE -highlight Keyword guifg=#CC7833 ctermfg=173 cterm=NONE -highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE -highlight Number guifg=#A5C261 ctermfg=107 -highlight PreProc guifg=#E6E1DC ctermfg=103 -highlight Search guifg=NONE ctermfg=NONE guibg=#2b2b2b ctermbg=235 gui=italic cterm=underline -highlight Statement guifg=#CC7833 ctermfg=173 gui=NONE cterm=NONE -highlight String guifg=#A5C261 ctermfg=107 -highlight Title guifg=#FFFFFF ctermfg=15 -highlight Type guifg=#DA4939 ctermfg=167 gui=NONE cterm=NONE -highlight Visual guibg=#5A647E ctermbg=60 - -highlight DiffAdd guifg=#E6E1DC ctermfg=7 guibg=#519F50 ctermbg=71 -highlight DiffDelete guifg=#E6E1DC ctermfg=7 guibg=#660000 ctermbg=52 -highlight Special guifg=#DA4939 ctermfg=167 - -highlight pythonBuiltin guifg=#6D9CBE ctermfg=73 gui=NONE cterm=NONE -highlight rubyBlockParameter guifg=#FFFFFF ctermfg=15 -highlight rubyClass guifg=#CC7833 ctermfg=173 cterm=NONE -highlight rubyConstant guifg=#DA4939 ctermfg=167 -highlight rubyInstanceVariable guifg=#D0D0FF ctermfg=189 -highlight rubyInterpolation guifg=#519F50 ctermfg=107 -highlight rubyLocalVariableOrMethod guifg=#D0D0FF ctermfg=189 -highlight rubyPredefinedConstant guifg=#DA4939 ctermfg=167 -highlight rubyPseudoVariable guifg=#FFC66D ctermfg=221 -highlight rubyStringDelimiter guifg=#A5C261 ctermfg=143 - -highlight xmlTag guifg=#E8BF6A ctermfg=179 -highlight xmlTagName guifg=#E8BF6A ctermfg=179 -highlight xmlEndTag guifg=#E8BF6A ctermfg=179 - -highlight mailSubject guifg=#A5C261 ctermfg=107 -highlight mailHeaderKey guifg=#FFC66D ctermfg=221 -highlight mailEmail guifg=#A5C261 ctermfg=107 gui=italic cterm=underline - -highlight SpellBad guifg=#D70000 ctermfg=160 ctermbg=NONE cterm=underline -highlight SpellRare guifg=#D75F87 ctermfg=168 guibg=NONE ctermbg=NONE gui=underline cterm=underline -highlight SpellCap guifg=#D0D0FF ctermfg=189 guibg=NONE ctermbg=NONE gui=underline cterm=underline -highlight MatchParen guifg=#FFFFFF ctermfg=15 guibg=#005f5f ctermbg=23 diff --git a/editors/vim/colors/tubster.vim b/editors/vim/colors/tubster.vim deleted file mode 100644 index c792c6fa..00000000 --- a/editors/vim/colors/tubster.vim +++ /dev/null @@ -1,103 +0,0 @@ -" Vim color file -" Converted from Textmate theme Tubster using Coloration v0.3.2 (http://github.com/sickill/coloration) - -set background=dark -highlight clear - -if exists("syntax_on") - syntax reset -endif - -let g:colors_name = "Tubster" - -hi Cursor ctermfg=NONE ctermbg=15 cterm=NONE guifg=NONE guibg=#ffffff gui=NONE -hi Visual ctermfg=NONE ctermbg=59 cterm=NONE guifg=NONE guibg=#535c72 gui=NONE -hi CursorLine ctermfg=NONE ctermbg=59 cterm=NONE guifg=NONE guibg=#373636 gui=NONE -hi CursorColumn ctermfg=NONE ctermbg=59 cterm=NONE guifg=NONE guibg=#373636 gui=NONE -hi ColorColumn ctermfg=NONE ctermbg=59 cterm=NONE guifg=NONE guibg=#373636 gui=NONE -hi LineNr ctermfg=244 ctermbg=59 cterm=NONE guifg=#858280 guibg=#373636 gui=NONE -hi VertSplit ctermfg=240 ctermbg=240 cterm=NONE guifg=#5c5a59 guibg=#5c5a59 gui=NONE -hi MatchParen ctermfg=167 ctermbg=NONE cterm=NONE guifg=#cc6633 guibg=NONE gui=NONE -hi StatusLine ctermfg=188 ctermbg=240 cterm=bold guifg=#e6e1dc guibg=#5c5a59 gui=bold -hi StatusLineNC ctermfg=188 ctermbg=240 cterm=NONE guifg=#e6e1dc guibg=#5c5a59 gui=NONE -hi Pmenu ctermfg=15 ctermbg=NONE cterm=NONE guifg=#ffffff guibg=NONE gui=NONE -hi PmenuSel ctermfg=NONE ctermbg=59 cterm=NONE guifg=NONE guibg=#535c72 gui=NONE -hi IncSearch ctermfg=NONE ctermbg=58 cterm=NONE guifg=NONE guibg=#5b3928 gui=NONE -hi Search ctermfg=NONE ctermbg=58 cterm=NONE guifg=NONE guibg=#5b3928 gui=NONE -hi Directory ctermfg=74 ctermbg=NONE cterm=NONE guifg=#34a2d9 guibg=NONE gui=NONE -hi Folded ctermfg=241 ctermbg=235 cterm=NONE guifg=#666666 guibg=#232323 gui=NONE - -hi Normal ctermfg=188 ctermbg=235 cterm=NONE guifg=#e6e1dc guibg=#232323 gui=NONE -hi Boolean ctermfg=68 ctermbg=NONE cterm=NONE guifg=#3399cc guibg=NONE gui=NONE -hi Character ctermfg=74 ctermbg=NONE cterm=NONE guifg=#34a2d9 guibg=NONE gui=NONE -hi Comment ctermfg=241 ctermbg=NONE cterm=NONE guifg=#666666 guibg=NONE gui=italic -hi Conditional ctermfg=167 ctermbg=NONE cterm=NONE guifg=#cc6633 guibg=NONE gui=NONE -hi Constant ctermfg=74 ctermbg=NONE cterm=NONE guifg=#34a2d9 guibg=NONE gui=NONE -hi Define ctermfg=167 ctermbg=NONE cterm=NONE guifg=#cc6633 guibg=NONE gui=NONE -hi ErrorMsg ctermfg=15 ctermbg=160 cterm=NONE guifg=#ffffff guibg=#cc0000 gui=NONE -hi WarningMsg ctermfg=15 ctermbg=160 cterm=NONE guifg=#ffffff guibg=#cc0000 gui=NONE -hi Float ctermfg=113 ctermbg=NONE cterm=NONE guifg=#99cc66 guibg=NONE gui=NONE -hi Function ctermfg=221 ctermbg=NONE cterm=NONE guifg=#ffcc33 guibg=NONE gui=NONE -hi Identifier ctermfg=167 ctermbg=NONE cterm=NONE guifg=#cc6633 guibg=NONE gui=NONE -hi Keyword ctermfg=167 ctermbg=NONE cterm=NONE guifg=#cc6633 guibg=NONE gui=NONE -hi Label ctermfg=113 ctermbg=NONE cterm=NONE guifg=#99cc33 guibg=NONE gui=NONE -hi NonText ctermfg=238 ctermbg=236 cterm=NONE guifg=#404040 guibg=#2d2d2c gui=NONE -hi Number ctermfg=113 ctermbg=NONE cterm=NONE guifg=#99cc66 guibg=NONE gui=NONE -hi Operator ctermfg=167 ctermbg=NONE cterm=NONE guifg=#cc6633 guibg=NONE gui=NONE -hi PreProc ctermfg=167 ctermbg=NONE cterm=NONE guifg=#cc6633 guibg=NONE gui=NONE -hi Special ctermfg=188 ctermbg=NONE cterm=NONE guifg=#e6e1dc guibg=NONE gui=NONE -hi SpecialKey ctermfg=238 ctermbg=59 cterm=NONE guifg=#404040 guibg=#373636 gui=NONE -hi Statement ctermfg=167 ctermbg=NONE cterm=NONE guifg=#cc6633 guibg=NONE gui=NONE -hi StorageClass ctermfg=167 ctermbg=NONE cterm=NONE guifg=#cc6633 guibg=NONE gui=NONE -hi String ctermfg=113 ctermbg=NONE cterm=NONE guifg=#99cc33 guibg=NONE gui=NONE -hi Tag ctermfg=221 ctermbg=NONE cterm=NONE guifg=#ffcc33 guibg=NONE gui=NONE -hi Title ctermfg=188 ctermbg=NONE cterm=bold guifg=#e6e1dc guibg=NONE gui=bold -hi Todo ctermfg=241 ctermbg=NONE cterm=inverse,bold guifg=#666666 guibg=NONE gui=inverse,bold,italic -hi Type ctermfg=15 ctermbg=NONE cterm=NONE guifg=#ffffff guibg=NONE gui=NONE -hi Underlined ctermfg=NONE ctermbg=NONE cterm=underline guifg=NONE guibg=NONE gui=underline -hi rubyClass ctermfg=167 ctermbg=NONE cterm=NONE guifg=#cc6633 guibg=NONE gui=NONE -hi rubyFunction ctermfg=221 ctermbg=NONE cterm=NONE guifg=#ffcc33 guibg=NONE gui=NONE -hi rubyInterpolationDelimiter ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE -hi rubySymbol ctermfg=74 ctermbg=NONE cterm=NONE guifg=#34a2d9 guibg=NONE gui=NONE -hi rubyConstant ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE -hi rubyStringDelimiter ctermfg=113 ctermbg=NONE cterm=NONE guifg=#99cc33 guibg=NONE gui=NONE -hi rubyBlockParameter ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE -hi rubyInstanceVariable ctermfg=68 ctermbg=NONE cterm=NONE guifg=#3399cc guibg=NONE gui=NONE -hi rubyInclude ctermfg=167 ctermbg=NONE cterm=NONE guifg=#cc6633 guibg=NONE gui=NONE -hi rubyGlobalVariable ctermfg=68 ctermbg=NONE cterm=NONE guifg=#3399cc guibg=NONE gui=NONE -hi rubyRegexp ctermfg=113 ctermbg=NONE cterm=NONE guifg=#99cc33 guibg=NONE gui=NONE -hi rubyRegexpDelimiter ctermfg=113 ctermbg=NONE cterm=NONE guifg=#99cc33 guibg=NONE gui=NONE -hi rubyEscape ctermfg=71 ctermbg=NONE cterm=NONE guifg=#519f50 guibg=NONE gui=NONE -hi rubyControl ctermfg=167 ctermbg=NONE cterm=NONE guifg=#cc6633 guibg=NONE gui=NONE -hi rubyClassVariable ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE -hi rubyOperator ctermfg=167 ctermbg=NONE cterm=NONE guifg=#cc6633 guibg=NONE gui=NONE -hi rubyException ctermfg=167 ctermbg=NONE cterm=NONE guifg=#cc6633 guibg=NONE gui=NONE -hi rubyPseudoVariable ctermfg=68 ctermbg=NONE cterm=NONE guifg=#3399cc guibg=NONE gui=NONE -hi rubyRailsUserClass ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE -hi rubyRailsARAssociationMethod ctermfg=167 ctermbg=NONE cterm=NONE guifg=#da4939 guibg=NONE gui=NONE -hi rubyRailsARMethod ctermfg=167 ctermbg=NONE cterm=NONE guifg=#da4939 guibg=NONE gui=NONE -hi rubyRailsRenderMethod ctermfg=167 ctermbg=NONE cterm=NONE guifg=#da4939 guibg=NONE gui=NONE -hi rubyRailsMethod ctermfg=167 ctermbg=NONE cterm=NONE guifg=#da4939 guibg=NONE gui=NONE -hi erubyDelimiter ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE -hi erubyComment ctermfg=241 ctermbg=NONE cterm=NONE guifg=#666666 guibg=NONE gui=italic -hi erubyRailsMethod ctermfg=167 ctermbg=NONE cterm=NONE guifg=#da4939 guibg=NONE gui=NONE -hi htmlTag ctermfg=221 ctermbg=NONE cterm=NONE guifg=#ffcc33 guibg=NONE gui=NONE -hi htmlEndTag ctermfg=221 ctermbg=NONE cterm=NONE guifg=#ffcc33 guibg=NONE gui=NONE -hi htmlTagName ctermfg=221 ctermbg=NONE cterm=NONE guifg=#ffcc33 guibg=NONE gui=NONE -hi htmlArg ctermfg=221 ctermbg=NONE cterm=NONE guifg=#ffcc33 guibg=NONE gui=NONE -hi htmlSpecialChar ctermfg=74 ctermbg=NONE cterm=NONE guifg=#34a2d9 guibg=NONE gui=NONE -hi javaScriptFunction ctermfg=167 ctermbg=NONE cterm=NONE guifg=#cc6633 guibg=NONE gui=NONE -hi javaScriptRailsFunction ctermfg=167 ctermbg=NONE cterm=NONE guifg=#da4939 guibg=NONE gui=NONE -hi javaScriptBraces ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE -hi yamlKey ctermfg=221 ctermbg=NONE cterm=NONE guifg=#ffcc33 guibg=NONE gui=NONE -hi yamlAnchor ctermfg=68 ctermbg=NONE cterm=NONE guifg=#3399cc guibg=NONE gui=NONE -hi yamlAlias ctermfg=68 ctermbg=NONE cterm=NONE guifg=#3399cc guibg=NONE gui=NONE -hi yamlDocumentHeader ctermfg=113 ctermbg=NONE cterm=NONE guifg=#99cc33 guibg=NONE gui=NONE -hi cssURL ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE -hi cssFunctionName ctermfg=167 ctermbg=NONE cterm=NONE guifg=#da4939 guibg=NONE gui=NONE -hi cssColor ctermfg=74 ctermbg=NONE cterm=NONE guifg=#34a2d9 guibg=NONE gui=NONE -hi cssPseudoClassId ctermfg=221 ctermbg=NONE cterm=NONE guifg=#ffcc33 guibg=NONE gui=NONE -hi cssClassName ctermfg=221 ctermbg=NONE cterm=NONE guifg=#ffcc33 guibg=NONE gui=NONE -hi cssValueLength ctermfg=113 ctermbg=NONE cterm=NONE guifg=#99cc66 guibg=NONE gui=NONE -hi cssCommonAttr ctermfg=113 ctermbg=NONE cterm=NONE guifg=#99cc33 guibg=NONE gui=NONE -hi cssBraces ctermfg=NONE ctermbg=NONE cterm=NONE guifg=NONE guibg=NONE gui=NONE diff --git a/editors/vim/dirs/backups/.gitkeep b/editors/vim/dirs/backups/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/editors/vim/dirs/swaps/.gitkeep b/editors/vim/dirs/swaps/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/editors/vim/dirs/undos/.gitkeep b/editors/vim/dirs/undos/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/editors/vim/ftdetect/ruby.vim b/editors/vim/ftdetect/ruby.vim index ed7838f9..4927b499 100644 --- a/editors/vim/ftdetect/ruby.vim +++ b/editors/vim/ftdetect/ruby.vim @@ -7,9 +7,6 @@ au BufNewFile,BufRead *.builder,*.rxml,*.rjs set filetype=ruby " Rakefile au BufNewFile,BufRead [rR]akefile,*.rake set filetype=ruby -" Rantfile -au BufNewFile,BufRead [rR]antfile,*.rant set filetype=ruby - " IRB config au BufNewFile,BufRead .irbrc,irbrc set filetype=ruby @@ -21,3 +18,6 @@ au BufNewFile,BufRead [tT]horfile,*.thor set filetype=ruby " Gemfile au BufNewFile,BufRead Gemfile set filetype=ruby + +" Rackup +au BufNewFile,BufRead config.ru set filetype=ruby diff --git a/editors/vim/ftdetect/sh.vim b/editors/vim/ftdetect/sh.vim new file mode 100644 index 00000000..bb76d24e --- /dev/null +++ b/editors/vim/ftdetect/sh.vim @@ -0,0 +1,2 @@ +au BufNewFile,BufRead freshrc set filetype=sh + diff --git a/editors/vim/gvimrc b/editors/vim/gvimrc deleted file mode 100644 index 80623cc8..00000000 --- a/editors/vim/gvimrc +++ /dev/null @@ -1,23 +0,0 @@ -set guioptions-=T " hide toolbar -set guioptions+=Rr " Turn on scroll bars - -if has("gui_macvim") - set transparency=7 - - " Fullscreen takes up entire screen - set fuoptions=maxhorz,maxvert - - "Mac OS X style command line editing - cnoremap - cnoremap - - " Command-/ to toggle comments - map ,/ - imap ,/ - vmap ,/ -end - -" Source vimrc after saving it -autocmd! BufWritePost .gvimrc,gvimrc source $MYGVIMRC -autocmd! BufWritePost .vimrc,vimrc source $MYVIMRC | source $MYGVIMRC | NERDTreeToggle | NERDTreeToggle - diff --git a/editors/vim/init.nvim b/editors/vim/init.nvim new file mode 100644 index 00000000..f182e5b2 --- /dev/null +++ b/editors/vim/init.nvim @@ -0,0 +1,3 @@ +set runtimepath^=~/.vim runtimepath+=~/.vim/after +let &packpath = &runtimepath +source ~/.vimrc diff --git a/editors/vim/ui.vim b/editors/vim/ui.vim deleted file mode 100644 index 0feed9b7..00000000 --- a/editors/vim/ui.vim +++ /dev/null @@ -1,153 +0,0 @@ -syntax on - -" Visual - set ruler - set guioptions=ce - set showmatch " Briefly jump to a paren once it's balanced - set linespace=2 - set background=dark - set laststatus=2 - colorscheme molokai_mac - -" Tabs/Whitespace - set tabstop=2 - set shiftwidth=2 - set autoindent - set smarttab - set expandtab - set nowrap - set list - set backspace=indent,eol,start " allow backspacing over everything in insert mode - - " Toggle show tabs and trailing spaces (,c) - set listchars=tab:▸\ ,trail:¡,eol:ÂŹ,nbsp:_ - set fillchars=vert:\ ,fold:- - nnoremap c :set nolist! - -" Misc - set switchbuf=useopen " Don't re-open already opened buffers - set nostartofline " Avoid moving cursor to BOL when jumping around - set virtualedit=all " Let cursor move past the last char - set whichwrap=b,s,h,l,<,>,[,] - let mapleader = ',' - set autoread " watch for file changes - set mouse=a - set ttymouse=xterm2 " Needed to get mouse working when in Tmux/screen - set fileformats=unix - set history=1000 - set hidden - set title " Show title in Terminal - set shortmess=atI - -" Bells - set novisualbell " No blinking - set noerrorbells " No noise. - set vb t_vb= " disable any beeps or flashes on error - -" Searching - set hlsearch - set incsearch - set ignorecase - set smartcase - - " Remove highlighting when entering insert (not working... ) - autocmd InsertEnter * nohlsearch - - " center result - nnoremap n nzz - nnoremap N Nzz - nnoremap * *zz - nnoremap # #zz - nnoremap g* g*zz - nnoremap g# g#zz - -" Work around bug that leaves cursor in middle of line - nnoremap dd ddI - -" Tab completion - set wildmode=list:longest,list:full - set wildignore+=*.o,*.obj,.git,*.rbc,*.swp - -" Folding - set foldenable " Turn on folding - set foldmethod=syntax " Fold on the marker - set foldlevel=100 " Don't autofold anything (but I can still fold manually) - set foldopen=block,hor,mark,percent,quickfix,tag " what movements open folds - -" Directories for swp files - " persistent undos - set undofile - set undodir=~/.vim/dirs/undos - - set backupdir=~/.vim/dirs/backups - set directory=~/.vim/dirs/swaps - -" Nicer text navigation - nmap j gj - nmap k gk - -" Reselect visual block after adjusting indentation - vnoremap < >gv - -" Nicer splitting - set splitbelow - set splitright - map :new - map :vnew - -" Emacs-like keys for the command line - cnoremap - cnoremap - cnoremap - -" Move around in insert mode - inoremap - inoremap - inoremap - inoremap - -" way better... - map 0 ^ - - nmap ] :tabnext - nmap [ :tabprev - -" Opens an edit command with the path of the currently -" edited file filled in Normal mode: e - map e :e =expand("%:p:h") . "/" - -" Always show cursorline, but only in current window. - set scrolloff=3 - set scrolljump=10 - set cursorline - autocmd WinEnter * :setlocal cursorline - autocmd WinLeave * :setlocal nocursorline - - set number - - " For when other people use my setup - nmap \ - - " Easier - nnoremap ; : - - " I keep deleting words when I want to switch windows - imap - - " OS X clipboard when yanking/pasting - set clipboard=unnamed - - " May only work in iTerm2 and may have other bad effects, - " but this shows a block in normal mode, and vertical bar - " in insert mode. - if exists('$TMUX') - " https://github.com/sjl/vitality.vim/issues/8#issuecomment-7664649 - let &t_SI = "\[3 q" - let &t_EI = "\[0 q" - else - let &t_SI = "\]50;CursorShape=1\x7" - let &t_EI = "\]50;CursorShape=0\x7" - endif - - runtime macros/matchit.vim diff --git a/editors/vim/vimrc b/editors/vim/vimrc index 1df194ee..14a54e4b 100644 --- a/editors/vim/vimrc +++ b/editors/vim/vimrc @@ -1,43 +1,587 @@ set nocompatible -source ~/.vim/ui.vim -source ~/.vim/autocommands.vim -source ~/.vim/bundles.vim +let mapleader = "\" -" This helps with RVM etc -set shell=zsh +if empty(glob('~/.vim/autoload/plug.vim')) + silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs + \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + autocmd VimEnter * PlugInstall | source $MYVIMRC +endif + +call plug#begin('~/.cache/vim/plugs') + +Plug 'w0ng/vim-hybrid' " color scheme + +Plug 'mhinz/vim-startify' +let g:startify_session_persistence = 1 +let g:startify_session_autoload = 1 +let g:startify_fortune_use_unicode = 1 +let g:startify_update_oldfiles = 1 +let g:startify_change_to_vcs_root = 1 +let g:startify_change_to_dir = 0 +let g:startify_lists = [ + \ { 'type': 'dir', 'header': [' Recent '. getcwd()] }, + \ { 'type': 'files', 'header': [' Recent'] }, + \ { 'type': 'bookmarks', 'header': [' Bookmarks'] }, + \ { 'type': 'sessions', 'header': [' Sessions'] }, + \ { 'type': 'commands', 'header': [' Commands'] }, + \ ] + +Plug 'tpope/vim-sensible' " Sensible defaults, duh + +" Out of the box support for many languages +Plug 'sheerun/vim-polyglot', { 'tag': '*' } + +Plug 'scrooloose/nerdtree', { 'tag': '*' } +let g:NERDTreeWinPos='right' +let g:NERDTreeRespectWildIgnore=1 " Hide things from wildignore +let g:NERDTreeMouseMode = 3 " Nerd tree: single clicks open file/dir +let g:NERDTreeNaturalSort = 1 +nmap tt :NERDTreeToggle +nmap fo :NERDTreeFind +"Plug 'tpope/vim-vinegar' " Nicer netrw +let loaded_netrwPlugin=1 " Disable netrw completely http://stackoverflow.com/a/21687112 + +Plug 'mbbill/undotree', { 'on': ['UndotreeToggle', 'UndotreeFocus', 'UndotreeShow', 'UndotreeHide'] } +let g:undotree_WindowLayout = 2 +let g:undotree_SetFocusWhenToggle = 1 +nmap u :UndotreeToggle +nmap tu :UndotreeToggle + +Plug 'tpope/vim-commentary' +" There is no ASCII char for Control+/ (common shortcut for commentign), but +" most terminals match that key combo to Control+_, so we will capture that +" instead. +nmap gcc +xmap gcgv +imap gcc + +Plug 'tpope/vim-dispatch' +Plug 'tpope/vim-eunuch' +Plug 'tpope/vim-endwise' " Auto-add 'end' etc appropriately in various languages +Plug 'tpope/vim-fugitive', {'tag': '*', 'branch': 'master'} +Plug 'rhysd/committia.vim' " More convenient UI when using Vim as EDITOR for `git commit` +Plug 'hotwatermorning/auto-git-diff' " Show diffs in split when doing a `git rebase -i` +Plug 'tpope/vim-git' +Plug 'tpope/vim-repeat' +Plug 'tpope/vim-sleuth' " auto-config indent and tabs etc based on other files +Plug 'tpope/vim-surround' " quoting/parenthesizing made simple +Plug 'wellle/targets.vim' +Plug 'terryma/vim-expand-region' +if has('signs') + Plug 'airblade/vim-gitgutter' +endif +Plug 'kana/vim-smartinput' " smart pairwise characters + +Plug '~/.fzf' " Installation of bins handled by Fresh, separately +Plug 'junegunn/fzf.vim' +if executable('ag') + let $FZF_DEFAULT_COMMAND = 'ag -l --hidden .' +endif +map :GFiles +map :Files +" autocmd FileType fzf nmap :q + +" make t, f, T, F, etc all multi-line +Plug 'dahu/vim-fanfingtastic' + +" Preview register contents before selecting the register +Plug 'junegunn/vim-peekaboo' + +Plug 'junegunn/vim-easy-align', { 'on': ['(EasyAlign)', 'EasyAlign'] } +vmap (EasyAlign) + +" When re-opening a file, start cursor on last edit location +Plug 'farmergreg/vim-lastplace' + +Plug 'thisivan/vim-matchit' " extended matching for html, latex, and many other languages +Plug 'kana/vim-textobj-user' " Create new text objects +Plug 'michaeljsmith/vim-indent-object' + +Plug 'haya14busa/incsearch.vim', { 'on': ['(incsearch-forward)', '(incsearch-backward)', '(incsearch-stay)']} +Plug 'haya14busa/incsearch-fuzzy.vim', { 'on': ['(incsearch-fuzzy-/)', '(incsearch-fuzzy-?)', '(incsearch-fuzzy-stay)']} +nmap / (incsearch-forward) +xmap / (incsearch-forward) +nmap ? (incsearch-backward) +xmap ? (incsearch-backward) +map g/ (incsearch-stay) +map z/ (incsearch-fuzzy-/) +map z? (incsearch-fuzzy-?) +nmap zg/ (incsearch-fuzzy-stay) + +Plug 'Yggdroot/indentLine' +let g:indentLine_color_term = 239 +let g:indentLine_color_gui = '#504945' +let g:indentLine_fileTypeExclude = ['help', 'man', 'startify', 'vimfiler', 'markdown', 'fzf'] +let g:indentLine_char = '┊' + +" Run a find-and-replace using the last search term +nnoremap :%s////g + +" Make * and # work with a visual selection (in normal mode, it falls back to +" default behaviour of searching for current word) +Plug 'thinca/vim-visualstar' + +Plug 'honza/vim-snippets' " Contains snippets that coc-snippets can expand +Plug 'neoclide/coc.nvim', {'branch': 'release'} +let g:coc_global_extensions = [ +\ 'coc-actions', +\ 'coc-css', +\ 'coc-highlight', +\ 'coc-html', +\ 'coc-json', +\ 'coc-lists', +\ 'coc-rust-analyzer', +\ 'coc-snippets', +\ 'coc-solargraph', +\ 'coc-tabnine', +\ 'coc-tailwindcss', +\ 'coc-tsserver', +\ 'coc-vimlsp', +\] + +Plug 'liuchengxu/vim-which-key' ", { 'on': ['WhichKey', 'WhichKey!'] } +set timeoutlen=300 +autocmd! User vim-which-key call which_key#register('', 'g:which_key_map') +nnoremap :WhichKey '' + +Plug 'tpope/vim-bundler' +Plug 'tpope/vim-rails' +Plug 'tpope/vim-rake' +Plug 'thisivan/vim-ruby-matchit' +Plug 'nelstrom/vim-textobj-rubyblock', { 'for': 'ruby' } + +Plug 'gko/vim-coloresque' + +Plug 'dense-analysis/ale' +let g:ale_completion_enabled = 1 +let g:ale_fix_on_save = 1 +let g:ale_fixers = { +\ '*': ['remove_trailing_lines', 'trim_whitespace'], +\ 'javascript': ['eslint'], +\ 'elixir': ['mix_format'], +\ 'rust': [], +\ 'ruby': [], +\} +let g:ale_lint_on_save = 1 +let g:ale_linters = { +\ 'rust': [], +\ 'ruby': [], +\} + +" https://github.com/dense-analysis/ale#faq-coc-nvim +let g:ale_disable_lsp = 1 + +Plug 'vim-test/vim-test' +nmap tn :TestNearest +nmap tf :TestFile +nmap ts :TestSuite +nmap tl :TestLast +nmap tg :TestVisit + +" Change working directory to .git root +Plug 'airblade/vim-rooter' +let g:rooter_cd_cmd="lcd" + +Plug 'vim-airline/vim-airline' +let g:airline_powerline_fonts = 1 +let g:airline#extensions#tabline#enabled = 1 +let g:airline#extensions#tabline#left_sep = ' ' +let g:airline#extensions#tabline#left_alt_sep = '|' + +" ^A / ^Z on a column of numbers will increment them in ascending order +" (i.e. a bullett list) +Plug 'triglav/vim-visual-increment' + +Plug 'dyng/ctrlsf.vim' + +Plug 'mg979/vim-visual-multi' + +call plug#end() +hi Normal ctermbg=none + +" if hidden not set, TextEdit might fail. +set hidden + +" Better display for messages +set cmdheight=2 + +" Smaller updatetime for CursorHold & CursorHoldI +set updatetime=300 + +" always show signcolumns +set signcolumn=yes + +" Use tab for trigger completion with characters ahead and navigate. +" Use command ':verbose imap ' to make sure tab is not mapped by other plugin. +inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ coc#refresh() +inoremap pumvisible() ? "\" : "\" + +function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction + +" Use for trigger completion. +inoremap coc#refresh() + +" Use for confirm completion, `u` means break undo chain at current position. +" Coc only does snippet and additional edit on confirm. +"inoremap pumvisible() ? "\" : "\u\" +" NOTE: above mapping disabled due to https://github.com/tpope/vim-endwise/issues/22#issuecomment-446042476 +let g:endwise_no_mappings = v:true +" inoremap CustomCocCR pumvisible() ? coc#_select_confirm() : "\u\\=coc#on_enter()\" +inoremap CustomCocCR pumvisible() ? "\" : "\u\\=coc#on_enter()\" +imap CustomCocCRDiscretionaryEnd + +" Use `[c` and `]c` for navigate diagnostics +nmap [c (coc-diagnostic-prev) +nmap ]c (coc-diagnostic-next) + +" Remap keys for gotos +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) + +" Use K for show documentation in preview window +nnoremap K :call show_documentation() + +function! s:show_documentation() + if &filetype == 'vim' + execute 'h '.expand('') + else + call CocAction('doHover') + endif +endfunction + +" Highlight symbol under cursor on CursorHold +autocmd CursorHold * silent call CocActionAsync('highlight') + +" Remap for rename current word +nmap rn (coc-rename) + +" Remap for format selected region +vmap f (coc-format-selected) +nmap f (coc-format-selected) + +" Setup formatexpr specified filetype(s). +augroup mygroup + autocmd! + autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') +augroup end + +" Remap for do codeAction of selected region, ex: `aap` for current paragraph +vmap a (coc-codeaction-selected) +nmap a (coc-codeaction-selected) + +" Remap for do codeAction of current line +nmap ac (coc-codeaction) + +syntax on -" http://tim.theenchanter.com/2008/07/crontab-temp-file-must-be-edited-in.html -set backupskip=/tmp/*,/private/tmp/*" +" Visual + set ruler + set guioptions=ce + set linespace=2 + set background=dark + set laststatus=2 + colorscheme hybrid + + set showmatch " Briefly jump to a paren once it's balanced + set matchpairs+=\<:\> + " With `Cursor guibg=fg guifg=bg` + default MatchParen styling, it makes the + " cursor seem like it has actually jumped to the patching pair. This instead + " makes the MatchParen style preserve the background color, so that the + " Cursor can flip it appropriately. + hi! MatchParen cterm=NONE,bold gui=NONE,bold guibg=bg guifg=lightblue ctermbg=bg ctermfg=lightblue + +" Tabs/Whitespace + set tabstop=2 " a Tab take up 2 spaces + set shiftwidth=2 " (un)indent 2 spaces at at ime + set autoindent " preserve previous indent level when inserting new line + set smarttab " insert/delete a tab's work of spaces at a time + set expandtab " insert actual spaces, not tabs + set nowrap " don't wrap long lines + set backspace=indent,eol,start " allow backspacing over everything in insert mode + + " Toggle show tabs and trailing spaces (,c) + set list + set listchars=tab:⤑\ ,trail:¡,eol:↵,nbsp:_ + set fillchars=vert:\ ,fold:- + nnoremap tc :set list! list? + +" Misc + set switchbuf=usetab,newtab " Open new buffers in tab, switch to existing tab if already open + set nostartofline " Avoid moving cursor to BOL when jumping around + set virtualedit=all " Let cursor move past the last char + set whichwrap=b,s,h,l,<,>,[,] + set autoread " watch for file changes + set mouse=a " mouse can be handy sometimes + if !has('nvim') + set ttymouse=xterm2 " Needed to get mouse working when in Tmux/screen + endif + set fileformats=unix + set history=1000 + set title " Show title in Terminal + +" Bells + set visualbell + set noerrorbells " No noise. + set vb t_vb= " disable any beeps or flashes on error + +" Searching + set hlsearch " highlight search matches and keep them highlighted + set incsearch " start matching search before hitting enter + set ignorecase " case-insensitive searching by default + set smartcase " but if searching with multiple cases, treat it as case-sensitive + + " center current search result in middle of screen + nnoremap n nzz + nnoremap N Nzz + nnoremap * *zz + nnoremap # #zz + nnoremap g* g*zz + nnoremap g# g#zz + +" Work around bug that leaves cursor in middle of line + nnoremap dd ddI + +" Tab completion + set wildmode=list:longest,list:full + set wildignore+=*.o,*.obj,.git,*.rbc,*.swp + + nmap :tabnew + +" Navigate cursor up/down by lines on screen, not lines in file + nmap j gj + nmap k gk + +" Reselect visual block after adjusting indentation + vnoremap < >gv + +" Adjust indentation with single keypress + nnoremap < << + nnoremap > >> + +" Nicer splitting + set splitbelow + set splitright + +" Emacs-like keys for the command line and insert mode + noremap! + noremap! + +" Always show cursorline, but only in current window. + set scrolloff=3 + set scrolljump=10 + +set number " line numbers +set relativenumber + +" I keep deleting words when I want to switch windows +imap + +" Map control-S to save ( makes sure no range is inserted into command +" execution) +nmap :w +vmap :wgv + +" Share clipboard with OS +set clipboard=unnamed,unnamedplus + +" May only work in iTerm2 and may have other bad effects, +" but this shows a block in normal mode, and vertical bar +" in insert mode. +if exists('$TMUX') + " https://github.com/sjl/vitality.vim/issues/8#issuecomment-7664649 + let &t_SI = "\[3 q" + let &t_EI = "\[0 q" + + if !has('nvim') + set term=screen-256color + endif +else + let &t_SI = "\]50;CursorShape=1\x7" + let &t_EI = "\]50;CursorShape=0\x7" +endif + +runtime macros/matchit.vim + +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 + +" Strip trailing whitespace on command +nmap sw :call StripTrailingWhitespaces() + +augroup the_rest + au! + + if !has('nvim') + " Attempted fix for Vim losing mouse support when inside Tmux + autocmd TermResponse,CursorHold,CursorHoldI * set ttymouse=xterm2 + endif + + " Create parent directory if it doesn't exist before writing file + " (http://stackoverflow.com/questions/4292733/vim-creating-parent-directories-on-save) + autocmd BufWritePre * if expand("")!~#'^\w\+:/' && !isdirectory(expand("%:h")) | execute "silent! !mkdir -p ".shellescape(expand('%:h'), 1) | redraw! | endif + + " make and python use real tabs + autocmd FileType make set noexpandtab + autocmd FileType python set noexpandtab + + autocmd BufRead,BufNewFile gitconfig set ft=gitconfig + + " Strip trailing whitespace on save + " TODO: do not do this for all file types. In particular, bypass this for git patchsets (i.e. from `git add -p`) as + " it can fuck with cleanly applying patches + autocmd BufWritePre * :call StripTrailingWhitespaces() +augroup end + +silent! !bash -c "mkdir -p ~/.cache/vim/{backups,swaps,undos} &>/dev/null" +set undofile " persistent undos +set undodir=~/.cache/vim/undos// " where to store undo histories (trailing // is important) +set directory=~/.cache/vim/swaps// " store swap files here (trailing // is important) +set backupdir=~/.cache/vim/backups// " store file backups here (trailing // is important) +set backupskip=/tmp/*,/private/tmp/*" " don't use backups for tmp files + +set autoread + +set modeline +set modelines=5 " For when you forget to sudo.. Really Write the file. cmap w!! w !sudo tee % >/dev/null -" Send visual selection to gist.github.com -" Requires gist (brew install gist) -vnoremap G :w !gist -p -t %:e \| pbcopy - " CTags map rt :!ctags --extra=+f -R * -set tags=tmp/tags;/,./tmp/tags;/,tags;/,./tags;/ +set tags=./.git/tags;./tmp/tags;/,./tags;/ + +nmap tp :set invpaste paste? +nmap tn :set invnumber number? +nmap tr :set invrelativenumber relativenumber? + +if executable('ag') + let g:ackprg = 'ag --vimgrep --hidden' +endif + " comment line +" For working on highlight/syntax rules +map :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" + +" I pretty much only work with Postgres SQL, so assume *.sql files belong to +" that syntax: +let g:sql_type_default = 'pgsql' + +" Make copy/paste work kinda normally +" +" https://stackoverflow.com/a/14786750/1155048 +set pastetoggle= +inoremap + +vnoremap "+y -" ,w - write file -nnoremap ,w :write +" Copy current file path to clipboard +nnoremap :let @+ = expand("%:p") \| echo '"' . expand("%:p") . '" copied to clipboard.' -set pastetoggle=p -map p :set invpaste paste? +" Search for current visual selection +vnoremap y/" -" Theme development help -nmap :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' -\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" -\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" +" Bubble lines up/down +nmap :m-2 +nmap :m+1 +nmap :m-2 +nmap :m+1 +vmap :m-2gv +vmap :m'>+1gv +vmap :m-2gv +vmap :m'>+1gv -" Quick editing of common dot-files -map vv :edit $MYVIMRC -map gg :edit $MYGVIMRC -map .. :cd ~/.config:enew +" highlight last inserted text +nnoremap gV `[v`] + +nmap [b :bprevious +nmap ]b :bnext +nmap ]t :tprevious +nmap [t :tnext + +set formatoptions= " Clear so I can add with comments (see `:help fo-table`) +set formatoptions+=c " Auto-wrap comments, inserting current comment leader +set formatoptions+=r " Insert comment leader when hitting within a comment +set formatoptions+=j " Remove comment leader when joining comment lines +set formatoptions+=o " Ditto except for when using o or O +set formatoptions+=q " Allow formatting text with `gq` +set formatoptions+=n " Recognise numbered lists for sake of indenting wrapped content + +set nojoinspaces " Don't insert 2 spaces after punctuation when joining jines + +hi ColorColumn guibg=#222222 ctermbg=235 +set colorcolumn=79,120,150 +set textwidth=119 + +" Show incremental previews of commands (such as :s[ubstitute]) +if has('nvim') + set inccommand=nosplit +endif + +" If there's no EOL at the end of the file, don't mess up the diff by adding +" one +set nofixeol + +set noautochdir + +" https://dougblack.io/words/a-good-vimrc.html +set lazyredraw + +" Show current syntax item for position under cursor +" https://vi.stackexchange.com/a/11877/11631 +nnoremap zS :echo join(reverse(map(synstack(line('.'), col('.')), 'synIDattr(v:val,"name")')), ' ') + +" Start elixir tooling with a custom MIX_ENV so that compilation by that +" tooling doesn't negatively affect Phoenix auto-reloading +" +" https://github.com/phoenixframework/phoenix/issues/1165#issuecomment-437130681 +let $MIX_ENV='test' + +" Terminal Function +" Courtesy of https://www.reddit.com/r/vim/comments/8n5bzs/using_neovim_is_there_a_way_to_display_a_terminal/dzt3fix +let g:term_buf = 0 +let g:term_win = 0 +function! TermToggle(height) + if win_gotoid(g:term_win) + hide + else + botright new + exec "resize " . a:height + try + exec "buffer " . g:term_buf + catch + call termopen($SHELL, {"detach": 0}) + let g:term_buf = bufnr("") + set nonumber + set norelativenumber + set signcolumn=no + endtry + startinsert! + let g:term_win = win_getid() + endif +endfunction +nnoremap te :call TermToggle(12) +nnoremap :call TermToggle(12) +inoremap :call TermToggle(12) +tnoremap :call TermToggle(12) if filereadable(expand('~/.vimrc.local')) source ~/.vimrc.local endif - diff --git a/freshrc b/freshrc new file mode 100644 index 00000000..9260b5c7 --- /dev/null +++ b/freshrc @@ -0,0 +1,131 @@ +# vim: ft=sh + +fresh freshshell/fresh bin/fresh --bin +fresh freshshell/fresh-open bin/fresh-open --bin + +fresh-options --file=~/.ctags + fresh misc/ctags + + fresh romainl/ctags-patterns-for-javascript ctagsrc + fresh jb55/typescript-ctags .ctags + fresh rust-lang/rust.vim ctags/rust.ctags + fresh mmorearty/elixir-ctags .ctags + fresh https://gist.github.com/noisesmith/ebe8b3f185e34a7de04b1189b21ba59b.git .ctags # Clojure +fresh-options + +fresh languages/clojure/lein/profiles.clj --file=~/.lein/profiles.clj + +fresh-options --file=~/.rubocop.yml + # # disabled because it relies on custom cops and specific rubocop versions: + # fresh testdouble/standard config/base.yml + fresh languages/ruby/rubocop.yml +fresh-options + +fresh-options --file # each file as is + fresh languages/ruby/gemrc + fresh languages/ruby/irbrc + + # asdf conf + fresh languages/asdfrc + fresh languages/ruby/default-gems # asdf-ruby only + + fresh misc/ackrc + fresh misc/agignore + fresh misc/inputrc + fresh misc/nanorc + fresh misc/psqlrc + fresh misc/tmux/tmux.conf + + fresh vcs/git/gitattributes + fresh vcs/git/gitconfig + fresh vcs/git/gitconfig.merge + fresh vcs/git/gitconfig.pushurls + fresh vcs/git/gitignore + fresh --file=~/.git_template/ vcs/git/git_template +fresh-options + +fresh editors/vim/init.nvim --file ~/.config/nvim/init.vim + +fresh-options --file=~/.vimrc --marker='"' + fresh editors/vim/vimrc +fresh-options + +fresh-options --file=~/.zshrc --marker + fresh shells/path.sh # this must come first so we can check for tmux + fresh shells/tmux.sh # this must happen before p10k to guarantee it has tty + + fresh shells/zsh/p10k-instant-prompt.zsh + + fresh freshshell/fresh contrib/source-build.sh + + fresh mathiasbynens/dotfiles .functions + fresh twe4ked/dotfiles shell/zsh/completion.zsh + + fresh junegunn/fzf shell/completion.zsh + fresh junegunn/fzf shell/key-bindings.zsh + + fresh shells/common/\*.sh + fresh shells/zsh/lib/\*.zsh + + fresh shells/zsh/p10k.zsh + + fresh shells/local.zsh +fresh-options + +fresh-options --file=~/.bashrc --marker + fresh shells/path.sh + fresh shells/tmux.sh + fresh shells/common/\*.sh + fresh shells/bash/\*.bash + fresh shells/bash/lib/\*.bash + fresh shells/local.bash +fresh-options + +fresh zsh-users/zsh-completions src --file=completion/ +fresh freshshell/fresh contrib/completion/fresh-completion.zsh --file=completion/_fresh +fresh thoughtbot/dotfiles zsh/completion/_ag --file=completion/_ag +fresh shells/zsh/completions --file=completion/ + +fresh romkatv/powerlevel10k . --file=vendor/powerlevel10k/ + +fresh zdharma-continuum/fast-syntax-highlighting . --file=vendor/zsh-fast-syntax-highlighting/ +fresh zsh-users/zsh-history-substring-search . --file=vendor/zsh-history-substring-search/ +fresh zsh-users/zsh-autosuggestions . --file=vendor/zsh-autosuggestions/ + +fresh garybernhardt/dotfiles bin/run-command-on-git-revisions --bin +fresh sivel/speedtest-cli speedtest.py --bin=~/bin/speedtest + +fresh junegunn/fzf . --file=~/.fzf/ + +[ -f ~/.gitconfig.local ] || cp ~/.dotfiles/vcs/git/gitconfig.local ~/.gitconfig.local + + +fresh_after_build() { + # Fix executable bit + # https://github.com/freshshell/fresh/issues/159 + chmod +x ~/.git_template/hooks/* + + ~/.fresh/source/junegunn/fzf/install --bin + + # If WSL (Windows Subsystem for Linux) + if [ -n ${WSL_DISTRO_NAME:-} ] || grep -sqi microsoft /proc/sys/kernel/osrelease; then + if ! grep -qs '\[credential\]' ~/.gitconfig.local; then + cat >> ~/.gitconfig.local <<-EOF +# https://liamederzeel.com/store-git-credentials-in-wsl/ +[credential] + helper = /mnt/c/Program\\\\ Files/Git/mingw64/libexec/git-core/git-credential-wincred.exe +EOF + fi + fi + + # Install Vim plugins + if [ -z "${SKIP_VIM_PLUGINS:-}" ]; then + vim='vim' + command -v nvim &>/dev/null && vim='nvim' + $vim +PlugUpdate +PlugClean +qall + fi + + if [ -d ~/.asdf/installs ]; then + find ~/.asdf/installs -maxdepth 2 -mindepth 2 -type d -printf '%P\n' | sort -Vru -t/ -k1,1 | tr / ' ' > ~/.tool-versions + fi +} diff --git a/karabiner-ref.xml b/karabiner-ref.xml new file mode 100644 index 00000000..7ef15aec --- /dev/null +++ b/karabiner-ref.xml @@ -0,0 +1,4 @@ + + + + diff --git a/karabiner.xml b/karabiner.xml new file mode 100644 index 00000000..0475b473 --- /dev/null +++ b/karabiner.xml @@ -0,0 +1,139 @@ + + + YUBI_ENABLE + + + Ignore Yubikey key presses + Ideal for scenarios where you may accidentally touch the + Yubikey and output an unwanted code. This rule requires + double-pressing SHIFT_R, which enables the Yubikey for a + single token output. + + In addition, it always allows the Yubikey to work if a text + field is in focus or if the current application is a terminal. + + private.yubikey_ignore + + + + __DoublePressModifier__ KeyCode::SHIFT_R, + + + KeyCode::SHIFT_R, + + + KeyCode::VK_LOCK_YUBI_ENABLE + + + + DeviceVendor::YUBICO + ModifierFlag::YUBI_ENABLE + + + TERMINAL + AXTextField + + __KeyToKey__ KeyCode::A, KeyCode::VK_NONE + __KeyToKey__ KeyCode::B, KeyCode::VK_NONE + __KeyToKey__ KeyCode::C, KeyCode::VK_NONE + __KeyToKey__ KeyCode::D, KeyCode::VK_NONE + __KeyToKey__ KeyCode::E, KeyCode::VK_NONE + __KeyToKey__ KeyCode::F, KeyCode::VK_NONE + __KeyToKey__ KeyCode::G, KeyCode::VK_NONE + __KeyToKey__ KeyCode::H, KeyCode::VK_NONE + __KeyToKey__ KeyCode::I, KeyCode::VK_NONE + __KeyToKey__ KeyCode::J, KeyCode::VK_NONE + __KeyToKey__ KeyCode::K, KeyCode::VK_NONE + __KeyToKey__ KeyCode::L, KeyCode::VK_NONE + __KeyToKey__ KeyCode::M, KeyCode::VK_NONE + __KeyToKey__ KeyCode::N, KeyCode::VK_NONE + __KeyToKey__ KeyCode::O, KeyCode::VK_NONE + __KeyToKey__ KeyCode::P, KeyCode::VK_NONE + __KeyToKey__ KeyCode::Q, KeyCode::VK_NONE + __KeyToKey__ KeyCode::R, KeyCode::VK_NONE + __KeyToKey__ KeyCode::S, KeyCode::VK_NONE + __KeyToKey__ KeyCode::T, KeyCode::VK_NONE + __KeyToKey__ KeyCode::U, KeyCode::VK_NONE + __KeyToKey__ KeyCode::V, KeyCode::VK_NONE + __KeyToKey__ KeyCode::W, KeyCode::VK_NONE + __KeyToKey__ KeyCode::X, KeyCode::VK_NONE + __KeyToKey__ KeyCode::Y, KeyCode::VK_NONE + __KeyToKey__ KeyCode::Z, KeyCode::VK_NONE + __KeyToKey__ KeyCode::SEMICOLON, KeyCode::VK_NONE + __KeyToKey__ KeyCode::QUOTE, KeyCode::VK_NONE + __KeyToKey__ KeyCode::TAB, KeyCode::VK_NONE + __KeyToKey__ KeyCode::RETURN, KeyCode::VK_NONE + __KeyToKey__ KeyCode::SPACE, KeyCode::VK_NONE + + + + DeviceVendor::YUBICO + ModifierFlag::YUBI_ENABLE + + + + __KeyToKey__ KeyCode::RETURN, KeyCode::RETURN, + + Option::KEYTOKEY_AFTER_KEYUP, KeyCode::VK_LOCK_YUBI_ENABLE_FORCE_OFF + + + + + + COLEMAK + com.apple.keylayout.Colemak + + + + Yubikey from Colemak to QWERTY + If the system layout is set to Colemak, remap the Yubikey + back to QWERTY so that the tokens are correct. + private.yubikey_colemak_qwerty + DeviceVendor::YUBICO + COLEMAK + __KeyToKey__ KeyCode::F, KeyCode::E + __KeyToKey__ KeyCode::P, KeyCode::R + __KeyToKey__ KeyCode::G, KeyCode::T + __KeyToKey__ KeyCode::J, KeyCode::Y + __KeyToKey__ KeyCode::L, KeyCode::U + __KeyToKey__ KeyCode::U, KeyCode::I + __KeyToKey__ KeyCode::Y, KeyCode::O + __KeyToKey__ KeyCode::SEMICOLON, KeyCode::P + __KeyToKey__ KeyCode::R, KeyCode::S + __KeyToKey__ KeyCode::S, KeyCode::D + __KeyToKey__ KeyCode::T, KeyCode::F + __KeyToKey__ KeyCode::D, KeyCode::G + __KeyToKey__ KeyCode::N, KeyCode::J + __KeyToKey__ KeyCode::E, KeyCode::K + __KeyToKey__ KeyCode::I, KeyCode::L + __KeyToKey__ KeyCode::O, KeyCode::SEMICOLON + __KeyToKey__ KeyCode::K, KeyCode::N + + + + Apple keyboard from Colemak to QWERTY + If the system layout is set to Colemak, remap the Yubikey + back to QWERTY so that the tokens are correct. + private.apple_colemak_qwerty + DeviceVendor::APPLE_INC, DeviceProduct::APPLE_EXTERNAL_KEYBOARD_0x021d + COLEMAK + __KeyToKey__ KeyCode::F, KeyCode::E + __KeyToKey__ KeyCode::P, KeyCode::R + __KeyToKey__ KeyCode::G, KeyCode::T + __KeyToKey__ KeyCode::J, KeyCode::Y + __KeyToKey__ KeyCode::L, KeyCode::U + __KeyToKey__ KeyCode::U, KeyCode::I + __KeyToKey__ KeyCode::Y, KeyCode::O + __KeyToKey__ KeyCode::SEMICOLON, KeyCode::P + __KeyToKey__ KeyCode::R, KeyCode::S + __KeyToKey__ KeyCode::S, KeyCode::D + __KeyToKey__ KeyCode::T, KeyCode::F + __KeyToKey__ KeyCode::D, KeyCode::G + __KeyToKey__ KeyCode::N, KeyCode::J + __KeyToKey__ KeyCode::E, KeyCode::K + __KeyToKey__ KeyCode::I, KeyCode::L + __KeyToKey__ KeyCode::O, KeyCode::SEMICOLON + __KeyToKey__ KeyCode::K, KeyCode::N + + + diff --git a/languages/asdfrc b/languages/asdfrc new file mode 100644 index 00000000..8544bb6b --- /dev/null +++ b/languages/asdfrc @@ -0,0 +1 @@ +legacy_version_file = yes \ No newline at end of file diff --git a/languages/clojure/lein/profiles.clj b/languages/clojure/lein/profiles.clj index 6cd92107..2cde826e 100644 --- a/languages/clojure/lein/profiles.clj +++ b/languages/clojure/lein/profiles.clj @@ -1,16 +1,18 @@ -{:user {:plugins [[lein-beanstalk "0.2.2"] - [lein-light "0.0.4"] - [lein-marginalia "0.7.1"] - [lein-clojars "0.9.0"] - [lein-tarsier "0.9.1"] - ;[lein-pedantic "0.0.2"] - [lein-outdated "1.0.0"] - [lein-ring "0.7.5"] - [lein-swank "1.4.0"]] - :dependencies [[clj-stacktrace "0.2.4"]] - :injections [(let [orig (ns-resolve (doto 'clojure.stacktrace require) - 'print-cause-trace) - new (ns-resolve (doto 'clj-stacktrace.repl require) - 'pst)] - (alter-var-root orig (constantly @new)))] - :vimclojure-opts {:repl true}}} +{:user {:plugins [;[lein-beanstalk "0.2.7"] + ;[lein-marginalia "0.7.1"] + [cider/cider-nrepl "0.9.1"] + [refactor-nrepl "1.1.0"] + [lein-clojars "0.9.1"] + [lein-ancient "0.6.7"] + [lein-depgraph "0.1.0"] + [lein-pprint "1.1.2"] + [lein-ring "0.9.6"]] + :dependencies [[io.aviso/pretty "0.1.18"] + [alembic "0.3.2"] + [org.clojure/tools.nrepl "0.2.10"] + [clj-stacktrace "0.2.8"]] + :repl-options {:skip-default-intro true} + :global-vars {*print-length* 103 + *print-level* 15} + :injections [(require 'io.aviso.repl) + (io.aviso.repl/install-pretty-exceptions)]}} diff --git a/languages/ruby/autotest/autotest b/languages/ruby/autotest/autotest deleted file mode 100644 index 8e06e4d6..00000000 --- a/languages/ruby/autotest/autotest +++ /dev/null @@ -1,19 +0,0 @@ -# require 'autotest/redgreen' -require 'autotest/timestamp' - -module Autotest::Growl - def self.growl title, msg, img, pri=0, sticky="" - system "growlnotify -n autotest -d #{title} --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}" - end - - Autotest.add_hook :ran_command do |at| - unless at.results.empty? - output = at.results.last.slice(/(\d+)\s.*(?:examples|assertions)?,\s(\d+)\s.*failures?/) - if output =~ /[1-9]\sfailures?/ - growl "Tests", "#{output}", "~/.config/ruby/autotest/ruby_fail.png", 2, "-s" - else - growl "Tests", "#{output}", "~/.config/ruby/autotest/ruby_ok.png" - end - end - end -end diff --git a/languages/ruby/default-gems b/languages/ruby/default-gems new file mode 100644 index 00000000..516d007a --- /dev/null +++ b/languages/ruby/default-gems @@ -0,0 +1,6 @@ +bundler +pry +gem-ctags +rails +rake +pg \ No newline at end of file diff --git a/languages/ruby/global.gems b/languages/ruby/global.gems deleted file mode 100644 index 1b9bfdc4..00000000 --- a/languages/ruby/global.gems +++ /dev/null @@ -1,7 +0,0 @@ -launchy -ghost -flog -bundler -heroku -rake -gem-ctags diff --git a/languages/ruby/irbrc b/languages/ruby/irbrc index 9ece9ac1..3a24b866 100755 --- a/languages/ruby/irbrc +++ b/languages/ruby/irbrc @@ -1,9 +1,10 @@ -begin - require 'rubygems' unless defined? Gem - require 'irbtools' -rescue LoadError - $stderr.puts "Please install 'irbtools' or add it to your Gemfile" -end +require 'irb/ext/save-history' +require 'irb/completion' + +ARGV.concat %w[--readline --prompt-mode simple] + +IRB.conf[:SAVE_HISTORY] = 1000 +IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" class Object # Return a list of methods defined locally for a particular object. Useful @@ -13,3 +14,33 @@ class Object (obj.methods - obj.class.superclass.instance_methods).sort end end + +require 'rubygems' +begin + require 'pry' + Pry.start + exit +rescue LoadError + if defined?(::Bundler) + pry_specs = ENV['GEM_PATH'].split(':'). + flat_map { |path| Dir.glob("#{path}/specifications/pry-*.gemspec") }. + flat_map { |path| Gem::Specification.load(path) } + + pry_specs = pry_specs. + reverse_sort_by(&:version). + uniq_by(&:name) + + pry_specs.each do |spec| + $LOAD_PATH << spec.lib_dirs_glob + end + + begin + require 'pry' + Pry.start + exit + rescue LoadError => e + puts e + end + end + +end diff --git a/languages/ruby/pryrc b/languages/ruby/pryrc new file mode 100644 index 00000000..0d459bd8 --- /dev/null +++ b/languages/ruby/pryrc @@ -0,0 +1,41 @@ +if defined?(::Bundler) + pry_specs = ENV['GEM_PATH'].split(':'). + flat_map { |path| Dir.glob("#{path}/specifications/{method_source,pry,coderay}-*.gemspec") }. + flat_map { |path| Gem::Specification.load(path) } + + pry_specs = pry_specs. + sort_by(&:version). + reverse. + uniq(&:name) + + pry_specs.each do |spec| + $LOAD_PATH << spec.lib_dirs_glob + end +end + +begin + require('pry-inline') +rescue LoadError +end + +begin + require('pry-state') +rescue LoadError +end + +begin + #require('pry-syntax-hacks') +rescue LoadError +end + +if defined?(PryByebug) + Pry.commands.alias_command 'c', 'continue' + Pry.commands.alias_command 's', 'step' + Pry.commands.alias_command 'n', 'next' + Pry.commands.alias_command 'f', 'finish' + Pry.commands.alias_command 'u', 'up' +end + +if defined?(Rails) && Rails.env + include Rails::ConsoleMethods +end diff --git a/languages/ruby/railsrc b/languages/ruby/railsrc new file mode 100644 index 00000000..76388d89 --- /dev/null +++ b/languages/ruby/railsrc @@ -0,0 +1 @@ +-d postgresql -T diff --git a/languages/ruby/rspec b/languages/ruby/rspec new file mode 100644 index 00000000..fdd4d9d8 --- /dev/null +++ b/languages/ruby/rspec @@ -0,0 +1,2 @@ +--color +--order rand diff --git a/languages/ruby/rubocop.yml b/languages/ruby/rubocop.yml new file mode 100644 index 00000000..0bae1ad2 --- /dev/null +++ b/languages/ruby/rubocop.yml @@ -0,0 +1,283 @@ +# In general, we should care more about consistency and avoidance of +# bike-shedding than any specific aesthetic choice on code quality. +# +# However, in some cases, the default Rubocop rules merit changing where their +# defaults don't optimally live up to some additional values: +# +# 1. Correctness +# +# If a certain style will generally result in fewer errors, it should be +# preferred. E.g.: using attr_readers instead of @ivars will produce +# noticeable exceptions vs un-noticed nils; prefixed access modifiers to +# method definitions prevent accidental scope changes as methods are moved. +# +# 2. Focused diffs +# +# Trailing commas, aligning relative to indentation level (params, +# conditional assignment, etc), minimising whitespace changes, "flat" module +# namespacing, all produce less whitespace noise in diffs as they change and +# evolve. +# +# 3. Code clarity +# +# Access modifier prefixes and allowing for some flexibility in formatting +# numbers improve the ability to communicate intent and context in code. +# Likewise, choosing whether to use guard clauses or conditionals is a +# matter of readability that a developer can judge better than a linter. +# +# 4. Pragmatism +# +# Formatting code for easy paste-ability into IRB/Pry is a good example of +# this. +# +# 5. Appropriate subjectivity +# +# Certain choices are best made by a human code reviewer, not a linter. +# While consistency is important, it can sometimes be in conflict with +# clarity or other team values. + +AllCops: + TargetRubyVersion: ~ + ExtraDetails: true + +Metrics/AbcSize: + Enabled: false + +# Disable code "length" metrics other than line length, as they are somewhat +# subjective and not directly great measures of code complexity (though are +# often pretty decent trailing indicators) +Metrics/ModuleLength: + Enabled: false +Metrics/ClassLength: + Enabled: false +Metrics/BlockLength: + Enabled: false +Metrics/MethodLength: + Enabled: false + +# Discourage methods with many _unnamed_ arguments (as parameter ordering can +# be confusing), but allow many named arguments. +Metrics/ParameterLists: + CountKeywordArgs: false + +Bundler/OrderedGems: + Enabled: false + +Layout/DefEndAlignment: + AutoCorrect: true + +# An explicit return (e.g. deep within conditionals) can be both clearer and +# more resilient to bugs from refactoring, where the return is no longer in +# tail position of the method. +Style/RedundantReturn: + Enabled: false + +Style/EmptyMethod: + Enabled: false + +# Use trailing method dots, because it maximises paste-ability into REPLs +Layout/DotPosition: + EnforcedStyle: trailing + +Layout/MultilineMethodCallIndentation: + EnforcedStyle: indented + +Layout/FirstHashElementIndentation: + EnforcedStyle: consistent +Layout/FirstArrayElementIndentation: + EnforcedStyle: consistent + +# Prefer: +# +# some_method 'foo', +# 'bar', +# 'baz' +# +# over: +# +# +# some_method 'foo', +# 'bar', +# 'baz' +# +# because renaming a method reduce irrelevant indentation changes. +# +# Generally, put positional arguments on the first line, and kwargs on +# subsequent lines, but this isn't universally the best choice. +# +# Better yet, if parameters must be spread over multiple lines, prefer the +# following (for which there is not a rule): +# +# some_method( +# 'foo', +# 'bar', +# 'baz', +# ) +# +Layout/ParameterAlignment: + EnforcedStyle: with_fixed_indentation + +# Encourage trailing commas on multi-line lists to allow easy re-ordering and +# clearer diffs on changes. +Style/TrailingCommaInArrayLiteral: + EnforcedStyleForMultiline: consistent_comma +Style/TrailingCommaInHashLiteral: + EnforcedStyleForMultiline: consistent_comma + +# This cop does not work consistently and often interprets non-multi-line calls +# as multi-line adding commas where it shouldn't! Since argument lists are +# generally fixed length and rarely re-ordered, the arguments above for +# hash/array literal commas is not as strong and we will instead never have +# trailing commas in method calls. +Style/TrailingCommaInArguments: + EnforcedStyleForMultiline: no_comma + +# The "new_line" style for this is close to what we want, but it behaves poorly +# in cases where an argument is an array or hash and is spread across multiple +# lines. +Layout/MultilineMethodCallBraceLayout: + Enabled: false + +# Rewrite long lines +Layout/LineLength: + Enabled: true + AutoCorrect: true + +# In-lining access modifiers removes risk of accidentally changing access level +# when re-ordering methods and improves clarity about method access +Style/AccessModifierDeclarations: + EnforcedStyle: inline + +# It is better to have deterministic booleans in some cases, and `!!` is the +# most precise way to coerce truthy values (`!x.nil?` is NOT the same thing). +Style/DoubleNegation: + Enabled: false + +# Prefer: +# +# foo = +# if foo? +# bar +# else +# baz +# end +# +# over alternatives, as it offers the right balance between: consistent +# indentation, minimising unnecessary diff churn (e.g. when renaming the +# variable), and shorter line length. +Layout/MultilineAssignmentLayout: + Enabled: true +Layout/EndAlignment: + EnforcedStyleAlignWith: variable + +Lint/AmbiguousBlockAssociation: + Exclude: + # Describe blocks in particular can be quite large + - '**/*_spec.rb' + +# Well-named classes are more important than documentation +Style/Documentation: + Enabled: false + +Style/BlockDelimiters: + AutoCorrect: false # Best caught in code review + EnforcedStyle: semantic + BracesRequiredMethods: ['sig'] # Sorbet + IgnoredMethods: ['expect', 'let', 'let!', 'subject', 'it', 'fit', 'xit', 'before', 'after'] + Exclude: + - '**/*_spec.rb' + +# Prefer namespaced class definitions on single line to: +# +# 1. allow renaming/re-organizing namespaces without superfluous diffs full of +# whitespace changes; +# 3. have consistent consant lookup, relative to self or top-level +Style/ClassAndModuleChildren: + EnforcedStyle: compact + +# Don't autocorrect to allow alternative underscoring, +# ie 2017_12_25 +Style/NumericLiterals: + Enabled: true + AutoCorrect: false + +# Leave it to the coder to make this decision +Style/GuardClause: + Enabled: false + +# Default style prefers usage of a global function (Kernel#format). % is "ugly" +# and a named method would be preferred, but not over a global which may be +# overridden in the current class or not available (e.g. in BasicObject) +Style/FormatString: + EnforcedStyle: 'percent' + +# Disable this performance optimization - it can make the code less clear, and +# the =~ operator introduces global variables +#Performance/RedundantMatch: +# Enabled: false + +# We have several comments discussing unicode normalization. This rule doesn't +# particularly seem useful for code quality or team practices, so disabling. +Style/AsciiComments: + Enabled: false + +# An explicit self can provide clarity in some situations, even if technically +# redundant. Appropriate usage of self is better caught in code review by +# peers. +Style/RedundantSelf: + Enabled: false + +# A specialized exception class will take one or more arguments and construct +# the message from it. Both variants make sense. +Style/RaiseArgs: + Enabled: false + +# Consistency is best, so since we definitely need double quotes often, let's +# just use them everywhere. +Style/StringLiterals: + EnforcedStyle: 'double_quotes' + +# This feels subjective and best left to code review to determine what is +# suitable on a case by case basis. +Style/EmptyCaseCondition: + Enabled: false + +# Just because you _can_ fix a conditional on the same line, doesn't mean you +# should. Postfix conditionals are great for guards and other simple cases, +# but in other cases this can obscure intent. +Style/IfUnlessModifier: + Enabled: false + +# This doesn't take into account sorbet typed: comments +Layout/EmptyLineAfterMagicComment: + Enabled: false + +Layout/SpaceInsideHashLiteralBraces: + EnforcedStyle: no_space + EnforcedStyleForEmptyBraces: no_space + +Style/FrozenStringLiteralComment: + AutoCorrect: true + Enabled: false + +# Ideally we'd have a rule here with more options as this is not perfect +# either, but this is added to prevent situations such as: +# +# validate :email, +# presence: true, +# email: true +# +# Instead: +# +# validate :email, +# presence: true, +# email: true +# +# But ideally: +# +# validate :email, { +# presence: true, +# email: true +# } +Layout/ArgumentAlignment: + EnforcedStyle: with_fixed_indentation diff --git a/languages/ruby/rubyrc.rb b/languages/ruby/rubyrc.rb new file mode 100644 index 00000000..19050e2f --- /dev/null +++ b/languages/ruby/rubyrc.rb @@ -0,0 +1,17 @@ +# try_require = ->(code) do +# begin +# require(code) +# rescue LoadError +# puts "#{code} not installed" +# end +# end +# try_require.('pry') +# try_require.('pry-doc') +# try_require.('pry-byebug') +puts "hi" +require 'bundler/inline' +gemfile(true) do + gem 'pry' + gem 'pry-doc' + gem 'pry-byebug' +end diff --git a/misc/agignore b/misc/agignore new file mode 100644 index 00000000..70e5fb63 --- /dev/null +++ b/misc/agignore @@ -0,0 +1,3 @@ +tags +TAGS +.git diff --git a/misc/ctags b/misc/ctags index af314034..e83e573b 100644 --- a/misc/ctags +++ b/misc/ctags @@ -1,19 +1,42 @@ -# Ruby --regex-ruby=/(^|[:;])[ \t]*([A-Z][[:alnum:]_]+) *=/\2/c,class,constant/ --regex-ruby=/(^|;)[ \t]*(has_many|belongs_to|has_one|has_and_belongs_to_many)\(? *:([[:alnum:]_]+)/\3/f,function,association/ --regex-ruby=/(^|;)[ \t]*(named_)?scope\(? *:([[:alnum:]_]+)/\3/f,function,named_scope/ --regex-ruby=/(^|;)[ \t]*event\(? *:([[:alnum:]_]+)/\2/f,function,aasm_event/ --regex-ruby=/(^|;)[ \t]*event\(? *:([[:alnum:]_]+)/\2!/f,function,aasm_event/ --regex-ruby=/(^|;)[ \t]*event\(? *:([[:alnum:]_]+)/\2?/f,function,aasm_event/ +--regex-ruby=/#[ \t]*(FIXME|TODO)[ \t]*\:*(.*)/\1/T,Tag,Tags/ -# Clojure ---langmap=Lisp:+.clj - -# CofeeScript ---langdef=coffee ---langmap=coffee:.coffee ---regex-coffee=/^class ([A-Za-z.]+)( extends [A-Za-z.]+)?$/\1/c,class/ ---regex-coffee=/^[ \t]*@?([A-Za-z.]+):.*[-=]>.*$/\1/f,function/ ---regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=.*[-=]>.*$/\1/f,function/ ---regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/v,variable/ +--langdef=CoffeeScript +--langmap=CoffeeScript:.coffee +--regex-coffeescript=/^class ([A-Za-z.]+)( extends [A-Za-z.]+)?$/\1/c,class/ +--regex-coffeescript=/^[ \t]*@?([A-Za-z.]+):.*[-=]>.*$/\1/f,function/ +--regex-coffeescript=/^[ \t]*([A-Za-z.]+)[ \t]+=.*[-=]>.*$/\1/f,function/ +--regex-coffeescript=/^[ \t]*([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/v,variable/ +--regex-coffeescript=/#[ \t]*(FIXME|TODO)[ \t]*\:*(.*)/\1/T,Tag,Tags/ +--exclude=.git +--exclude=.svn +--exclude=.hg +--exclude=min +--exclude=vendor +--exclude=\*.min.\* +--exclude=\*.map +--exclude=\*.swp +--exclude=\*.bak +--exclude=\*.pyc +--exclude=\*.class +--exclude=\*.sln +--exclude=\*.Master +--exclude=\*.csproj +--exclude=\*.csproj.user +--exclude=\*.cache +--exclude=\*.dll +--exclude=\*.pdb +--exclude=tags +--exclude=cscope.\* +--exclude=\*.tar.\* +--exclude=dist +--exclude=test +--exclude=tests +--exclude=.tmp +--exclude=*bundle.* diff --git a/misc/psqlrc b/misc/psqlrc new file mode 100644 index 00000000..257c6c49 --- /dev/null +++ b/misc/psqlrc @@ -0,0 +1,18 @@ +-- By default, NULL displays as an empty space. Is it actually an empty +-- string, or is it null? This makes that distinction visible. +\pset null '[NULL]' +-- Use table format (with headers across the top) by default, but switch to +-- expanded table format when there's a lot of data, which makes it much +-- easier to read. +\x auto +-- Verbose error reports. +\set VERBOSITY verbose +-- Use a separate history file per-database. +\set HISTFILE ~/.psql_history- :DBNAME +-- If a command is run more than once in a row, only store it once in the +-- history. +\set HISTCONTROL ignoredups +-- Autocomplete keywords (like SELECT) in upper-case, even if you started +-- typing them in lower case. +\set COMP_KEYWORD_CASE upper +\timing diff --git a/misc/tmux/tmux.conf b/misc/tmux/tmux.conf index 2b12185c..cea44434 100644 --- a/misc/tmux/tmux.conf +++ b/misc/tmux/tmux.conf @@ -10,16 +10,10 @@ setw -g mode-keys vi set -g default-terminal "screen-256color" bind R source-file ~/.tmux.conf -bind \ confirm-before kill-server - -unbind z -bind z run ". ~/.config/misc/tmux/zoom.sh" +bind '\' confirm-before kill-server # Mouse - setw -g mode-mouse on - set -g mouse-resize-pane - set -g mouse-select-pane - set -g mouse-select-window + set -g mouse # Copy/Pasting bind [ copy-mode @@ -64,33 +58,28 @@ bind z run ". ~/.config/misc/tmux/zoom.sh" # Statusbar settings set -g status-keys vi - set -g display-time 2000 # How long messages are displayed for - - # default statusbar colors - set-option -g status-utf8 on - set-option -g status-fg colour15 - set-option -g status-bg black - - setw -g window-status-fg colour15 - setw -g window-status-bg black - setw -g window-status-attr none - - setw -g window-status-current-fg black - setw -g window-status-current-bg colour15 - setw -g window-status-current-attr bold - - setw -g window-status-current-format '(#[fg=red]#I#[default] #W#F)' - setw -g window-status-format '(#[fg=yellow]#I#[default] #W#F)' - - set-option -g status-left ' ❐ #[fg=red]#S#[default] ▐' - set-option -g status-right '▐ ⌚ #[fg=green]#(date "+%H:%M")#[default] ▐ #[fg=colour210]#(whoami)@#H#[default]' + set -g display-time 4000 # How long messages are displayed for - set-option -g status-right-length 1000 - set-option -g status-left-length 60 +setw -g aggressive-resize on # https://github.com/sjl/vitality.vim/issues/8#issuecomment-7664649 set-option -g terminal-overrides '*88col*:colors=88,*256col*:colors=256,xterm*:XT:Ms=\E]52;%p1%s;%p2%s\007:Cc=\E]12;%p1%s\007:Cr=\E]112\007:Cs=\E]50;CursorShape=%?%p1%{3}%<%t%{0}%e%p1%{2}%-%;%d\007' set -sg escape-time 0 # needed to distinguish between ESC and Meta in emacs -bind C-c run "tmux save-buffer - | pbcopy" -bind C-v run "pbpaste | tmux load-buffer - && tmux paste-buffer" +if-shell "uname | grep -q Darwin" { + if-shell "command -v reattach-to-user-namespace &>/dev/null" { + set-option -g default-command "reattach-to-user-namespace -l zsh" + } { + set-option -g default-command "zsh" + } + bind C-c run "tmux save-buffer - | pbcopy" + bind C-v run "pbpaste | tmux load-buffer - && tmux paste-buffer" +} + +if-shell "uname | grep -q Linux" { + if-shell "command -v zsh &>/dev/null" { + set-option -g default-command "zsh" + } { + set-option -g default-command "bash" + } +} diff --git a/shells/README.md b/shells/README.md new file mode 100644 index 00000000..ad250ce0 --- /dev/null +++ b/shells/README.md @@ -0,0 +1,144 @@ +# Unix shell initialization + +(NOTE: taken from https://github.com/sstephenson/rbenv/wiki/Unix-shell-initialization) + +Shell initialization files are ways to persist common shell configuration, such +as: + +* `$PATH` and other environment variables +* shell prompt +* shell tab-completion +* aliases, functions +* key bindings + + +## Shell modes + +Which initialization files get sourced by the shell is dependent on the +combination of modes in which a particular shell process runs. There are two +main, non-exclusive modes: + +* **login** - e.g. when user logs in to a system with non-graphical interface or + via SSH; +* **interactive** - shell that has a prompt and whose standard input and error + are both connected to terminals. + +These modes can be manually activated with the following flags to bash/zsh: + +* `-l`, `--login` +* `-i` + +Here are some common operations and shell modes they result in: + +* log in to a remote system via SSH: + **login + interactive** +* execute a script remotely, e.g. `ssh user@host 'echo $PWD'` or with + [Capistrano][]: **non‑login, non‑interactive** +* execute a script remotely and request a terminal, e.g. `ssh user@host -t 'echo $PWD'`: **non-login, interactive** +* start a new shell process, e.g. `bash`: + **non‑login, interactive** +* run a script, `bash myscript.sh`: + **non‑login, non‑interactive** +* run an executable with `#!/usr/bin/env bash` shebang: + **non‑login, non‑interactive** +* open a new graphical terminal window/tab: + * on Mac OS X: **login, interactive** + * on Linux: **non‑login, interactive** + + +## Shell init files + +In order of activation: + +### bash + +1. **login** mode: + 1. `/etc/profile` + 2. `~/.bash_profile`, `~/.bash_login`, `~/.profile` (only first one that exists) +2. interactive **non-login**: + 1. `/etc/bash.bashrc` (some Linux; not on Mac OS X) + 2. `~/.bashrc` +3. **non-interactive**: + 1. source file in `$BASH_ENV` + +### Zsh + +1. `/etc/zshenv` +2. `~/.zshenv` +3. **login** mode: + 1. `/etc/zprofile` + 2. `~/.zprofile` +4. **interactive**: + 1. `/etc/zshrc` + 2. `~/.zshrc` +5. **login** mode: + 1. `/etc/zlogin` + 2. `~/.zlogin` + +### [dash][] + +1. **login** mode: + 1. `/etc/profile` + 2. `~/.profile` +2. **interactive**: + 1. source file in `$ENV` + +### [fish][] + +1. `/config.fish` +2. `/etc/fish/config.fish` +3. `~/.config/fish/config.fish` + +### Practical guide to which files get sourced when + +* Opening a new Terminal window/tab: + * **bash** + * OS X: `.bash_profile` or `.profile` (1st found) + * Linux: `.profile` (Ubuntu, once per desktop login session) + `.bashrc` + * **Zsh** + * OS X: `.zshenv` + `.zprofile` + `.zshrc` + * Linux: `.profile` (Ubuntu, once per desktop login session) + `.zshenv` + `.zshrc` +* Logging into a system via SSH: + * **bash**: `.bash_profile` or `.profile` (1st found) + * **Zsh**: `.zshenv` + `.zprofile` + `.zshrc` +* Executing a command remotely with `ssh` or Capistrano: + * **bash**: `.bashrc` + * **Zsh**: `.zshenv` +* Remote git hook triggered by push over SSH: + * *no init files* get sourced, since hooks are running [within a restricted shell](http://git-scm.com/docs/git-shell) + * PATH will be roughly: `/usr/libexec/git-core:/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin` + +## Misc. things that affect `$PATH` + +* OS X: + * `/etc/paths`, `/etc/paths.d/*` + * [`~/.MacOSX/environment.plist`][plist] - affects **all** graphical programs + * `/etc/launchd.conf` + * TextMate: Preferences -> Advanced -> Shell Variables +* Linux: + * `/etc/environment` + +## Final notes + +This guide was tested with: + +* bash 4.2.37, 4.2.39 +* Zsh 4.3.11, 5.0 + +On these operating systems/apps: + +* Mac OS X 10.8 (Mountain Lion): Terminal.app, iTerm2 +* Ubuntu 12.10: Terminal + +See also: + +* [Environment Variables](https://help.ubuntu.com/community/EnvironmentVariables) +* path_helper(8) +* launchd.conf(5) +* pam_env(8) + + + [Capistrano]: https://github.com/capistrano/capistrano/wiki + [dash]: http://gondor.apana.org.au/~herbert/dash/ + [fish]: http://ridiculousfish.com/shell/user_doc/html/index.html#initialization + [plist]: http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/EnvironmentVars.html#//apple_ref/doc/uid/20002093-113982 diff --git a/shells/bash/bash_profile b/shells/bash/bash_profile index ea05214a..3b9ef7ae 100644 --- a/shells/bash/bash_profile +++ b/shells/bash/bash_profile @@ -1 +1,6 @@ -source ~/.bashrc \ No newline at end of file +source ~/.bashrc +# added by oblique-fortunes +if command fortune >/dev/null; then fortune oblique; fi + + +export PATH="$HOME/.cargo/bin:$PATH" diff --git a/shells/bash/bashrc b/shells/bash/bashrc index 6e4bf657..0010795f 100644 --- a/shells/bash/bashrc +++ b/shells/bash/bashrc @@ -2,4 +2,4 @@ CURRENT_SHELL="bash" SHELL_FILES="$(dirname $(readlink $BASH_SOURCE))" DOT_FILES="$(dirname $(dirname $SHELL_FILES))" -source $DOT_FILES/shells/bootstrap.sh +source $HOME/.dotfiles/shells/bootstrap.sh diff --git a/shells/bash/config.bash b/shells/bash/config.bash index ab476c60..4158d64e 100644 --- a/shells/bash/config.bash +++ b/shells/bash/config.bash @@ -15,6 +15,6 @@ shopt -s checkwinsize histappend cdable_vars extglob nullglob cdspell cmdhist ho # Bash 4 and above only shopt -s globstar autocd checkjobs 2>/dev/null -complete -C $DOT_FILES/bash/rake-completion.rb -o default rake} +complete -C $HOME/.dotfiles/bash/rake-completion.rb -o default rake} alias reload="source ~/.bashrc" diff --git a/shells/bash/lib/50_completions.bash b/shells/bash/lib/50_completions.bash index e4271e2b..f2aeb1ab 100644 --- a/shells/bash/lib/50_completions.bash +++ b/shells/bash/lib/50_completions.bash @@ -1,3 +1,2 @@ # Git completion support in bash -source $DOT_FILES/vcs/git/git-completion - +source $HOME/.dotfiles/vcs/git/git-completion diff --git a/shells/bootstrap.sh b/shells/bootstrap.sh deleted file mode 100644 index 2b10c6a5..00000000 --- a/shells/bootstrap.sh +++ /dev/null @@ -1,18 +0,0 @@ -COMMON_SHELL_FILES="$SHELL_FILES/../common" - -source "$SHELL_FILES/../path.sh" -source "$SHELL_FILES/../tmux.sh" - -CDPATH=".:${HOME}" -if [ -d "$HOME/Code" ]; then - CDPATH="$CDPATH:$HOME/Code" -fi - -source "$SHELL_FILES"/config.*sh - -files=`ls -1 "$COMMON_SHELL_FILES"/*.sh "$SHELL_FILES"/lib/*.*sh` -for file in $files; do - source $file -done - -[ -f "$HOME/.shellrc.local" ] && source "$HOME/.shellrc.local" diff --git a/shells/common/aliases.sh b/shells/common/aliases.sh index bb4e9932..08edd62c 100644 --- a/shells/common/aliases.sh +++ b/shells/common/aliases.sh @@ -1,24 +1,22 @@ -which hub &>/dev/null && alias git='nocorrect hub' +which hub &>/dev/null && alias git='hub' -alias ll='ls -lah' -alias l='ls' -alias b='cd -' alias cdr='cd ./$(git rev-parse --show-cdup)' # useful command to find what you should be aliasing: alias profileme="history | awk '{print \$2}' | awk 'BEGIN{FS=\"|\"}{print \$1}' | sort | uniq -c | sort -n | tail -n 20 | sort -nr" -# rails stuff -alias sc="if [ -f script/console ]; then script/console; else script/rails console; fi" -alias ss="if [ -f script/server ]; then script/server; else script/rails server; fi" -alias gen='if [ -f script/generate ]; then script/generate; else script/rails generate; fi' alias webshare='python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"' -alias pubkey="cat $HOME/.ssh/*.pub" +alias pubkeys="cat $HOME/.ssh/*.pub" alias colorslist="set | egrep 'COLOR_\w*'" # lists all the colors alias jsonify='python -mjson.tool' +if [ `uname` = "Linux" ]; then + alias pbcopy='xclip -selection clipboard' + alias pbpaste='xclip -selection clipboard -o' +fi + if [ -n "$SSH_CONNECTION" ]; then # Never open GUI vim when SSHd into a box alias mvim='vim' diff --git a/shells/common/asdf.sh b/shells/common/asdf.sh new file mode 100644 index 00000000..56d506b9 --- /dev/null +++ b/shells/common/asdf.sh @@ -0,0 +1,8 @@ +if [ -f "$HOME/.asdf/asdf.sh" ]; then + . $HOME/.asdf/asdf.sh +elif command -v brew &>/dev/null && [ -f "`brew --prefix`/opt/asdf/libexec/asdf.sh" ]; then + . `brew --prefix`/opt/asdf/libexec/asdf.sh +fi + +# Colemak alias +command -v asdf &>/dev/null && alias arst=asdf diff --git a/shells/common/exports.sh b/shells/common/exports.sh index 628576ff..b6fb351c 100644 --- a/shells/common/exports.sh +++ b/shells/common/exports.sh @@ -1,13 +1,31 @@ -which vim &>/dev/null && editor="$(which vim)" +command -v vim &>/dev/null && editor="$(which vim)" +command -v nvim &>/dev/null && editor="$(which nvim)" + +if command -v ag &>/dev/null; then + # Ignore anything in .gitignore but still list other hidden files (e.g. .env) + export FZF_DEFAULT_COMMAND="ag -l --hidden --ignore .git/" +fi + +# Many editor integrations (linters, language server, etc) mess up Phoenix auto +# reloading by compiling changed files themselves (causing Phoenix to think +# that the live version is up-to-date). +# +# Each tool has various work-arounds to make this work, but the simplest thing +# (for editors started from the terminal) is to simply change the environment +# everything runs under by default. +editor="env MIX_ENV=test $editor" export EDITOR="$editor -f" export VISUAL="$editor" +# Enable shell history in IEx and Erlang REPLs +export ERL_AFLAGS="-kernel shell_history enabled" + export TERM=xterm-256color -export GREP_OPTIONS='--color=auto' -export GREP_COLOR='1;32' export CLICOLOR=1 export HISTSIZE=1000000 export HISTIGNORE="clear:bg:fg:cd:cd -:exit:date:w:* --help" +export GOPATH="$HOME/Code/Go" +PATH="$PATH:$GOPATH/bin" diff --git a/shells/common/functions.sh b/shells/common/functions.sh index 49c6ff2c..a01d649b 100644 --- a/shells/common/functions.sh +++ b/shells/common/functions.sh @@ -1,3 +1,25 @@ +function zeus() { + command zeus $* + st=$? + stty sane # zeus keeps screwing up the terminal sometimes + return $st +} + +function e() { + if [ "$#" -eq 0 ]; then + emacsclient -a '' -n -c . + else + emacsclient -a '' -n -c $@ + fi +} + +function ep() { + ( + cdr # attempt to cd to root directory; fail silently + e # open current directory using editor + ) 2>/dev/null +} + function GET() { curl -i -X GET -H "X-Requested-With: XMLHttpRequest" $* } @@ -57,12 +79,12 @@ function extract() { # Custom "command not found" handling (ala method_missing): # Zsh -function command_not_found_handler() { - /usr/bin/env ruby $DOT_FILES/misc/method_missing.rb $* +function __disabled__command_not_found_handler() { + /usr/bin/env ruby $HOME/.dotfiles/misc/method_missing.rb $* } # Bash (call Zsh version) -function command_not_found_handle() { +function __disabled__command_not_found_handle() { command_not_found_handler $* return $? } diff --git a/shells/common/git.sh b/shells/common/git.sh deleted file mode 100644 index bf9d00fb..00000000 --- a/shells/common/git.sh +++ /dev/null @@ -1,27 +0,0 @@ -export GIT_EDITOR="$EDITOR" - -alias gi='git init' -alias gst='git status -s' -alias gl='git pull --rebase' -alias gp='git push' -alias gpa='git push-all' # see [alias] in ~/.gitconfig -alias ga='git add' -alias gcl='git config --list' -alias gc='git commit -v' -alias gca='git commit -v -a' -alias gb='git branch --color' -alias gba='gb -a' -alias gco='git checkout' -alias gdc='git-svn dcommit' -alias gd='git diff' -alias gk='gitk --all &' -alias gx="open -b nl.frim.GitX" -alias grm="git stat | grep deleted | awk '{print $3}' | xargs git rm" -alias gpatch='git diff master -p' -alias glg="git log --decorate --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative" -alias ignore_empty='find . \( -type d -empty \) -and \( -not -regex ./\.git.* \) -exec touch {}/.gitignore \;' - -if [[ -d "/usr/local/git" ]]; then - PATH="/usr/local/git/bin:$PATH" - MANPATH="/usr/local/git/man:$MANPATH" -fi diff --git a/shells/common/osx.sh b/shells/common/osx.sh index 72eb17b4..f4ab71e0 100644 --- a/shells/common/osx.sh +++ b/shells/common/osx.sh @@ -1,109 +1,109 @@ -osx || return # Only for OS X - -alias serial="ioreg -l | grep IOPlatformSerialNumber | cut -f 10 -d' ' | cut -d'\"' -f 2 | pbcopy && echo 'Copied to clipboard'" - -function __setup_tmux_wrappers() { - local wrap="reattach-to-user-namespace" - local editors="VISUAL $(env | grep EDITOR | cut -d= -f1)" - - alias vim="$wrap vim" - alias mvim="$wrap mvim" - - for editor in $editors; do - eval "$editor='$wrap $(eval "echo \$$editor")'" - done -} - -if which reattach-to-user-namespace >/dev/null 2>&1; then - # and http://writeheavy.com/2011/10/23/reintroducing-tmux-to-the-osx-clipboard.html - [ -n "$TMUX" ] && __setup_tmux_wrappers -else - if [ -n "$TMUX" ]; then - echo "Installing pbpaste/pbcopy wrappers to get them working in Tmux..." - formula="https://raw.github.com/phinze/homebrew/15e923f17f282e6dcd2b2155947163ffed7ec8c9/Library/Formula/reattach-to-user-namespace.rb" - brew install --HEAD "$formula" --wrap-pbpaste-and-pbcopy >/dev/null 2>&1 && echo "Done." || echo "Failed." - __setup_tmux_wrappers +if osx; then + alias serial="ioreg -l | grep IOPlatformSerialNumber | cut -f 10 -d' ' | cut -d'\"' -f 2 | pbcopy && echo 'Copied to clipboard'" + + function __setup_tmux_wrappers() { + local wrap="reattach-to-user-namespace" + local editors="VISUAL $(env | grep EDITOR | cut -d= -f1)" + + alias vim="$wrap vim" + alias mvim="$wrap mvim" + + for editor in $editors; do + eval "$editor='$wrap $(eval "echo \$$editor")'" + done + } + + if which reattach-to-user-namespace >/dev/null 2>&1; then + # and http://writeheavy.com/2011/10/23/reintroducing-tmux-to-the-osx-clipboard.html + [ -n "$TMUX" ] && __setup_tmux_wrappers + else + if [ -n "$TMUX" ]; then + echo "Installing pbpaste/pbcopy wrappers to get them working in Tmux..." + formula="--HEAD --wrap-pbcopy-and-pbpaste --wrap-launchctl reattach-to-user-namespace" + brew install $formula >/dev/null 2>&1 && echo "Done." || echo "Failed." + __setup_tmux_wrappers + fi fi -fi - -if [ -z "$JAVA_HOME" -a -d /System/Library/Frameworks/JavaVM.framework/Home ]; then - export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home -fi - -alias o='open .' - -# replacement netstat cmd to find ports used by apps on OS X -alias netstat="sudo lsof -i -P" -alias pubkey="cat $HOME/.ssh/*.pub | pbcopy && echo 'Keys copied to clipboard'" - -alias hidefile='/usr/bin/SetFile -a "V"' -alias showfile='/usr/bin/SetFile -a "v"' - -function manpdf() { man -t $@ | open -f -a Preview; } -function osinfo() { - x1="$(/usr/bin/sw_vers -productName)" - x2="$(/usr/bin/sw_vers -productVersion)" - x3="$(/usr/bin/sw_vers -buildVersion)" - x4="$(/usr/bin/arch)" - echo "${x1} - ${x2} - ${x3} - ${x4}" -} - -function tab() { - osascript 2>/dev/null </dev/null < /dev/null 2>&1 && test "$@" -ge 0 > /dev/null 2>&1); } - -# move the Terminal window -function mvtw() { - if [[ $# -eq 2 ]] && $(positive_int "$1") && $(positive_int "$2"); then - printf "\e[3;${1};${2};t" - return 0 - fi - return 1 -} - -# resize the Terminal window -function sizetw() { - if [[ $# -eq 2 ]] && $(positive_int "$1") && $(positive_int "$2"); then - printf "\e[8;${1};${2};t" - /usr/bin/clear - return 0 - fi - return 1 -} - -# full screen -function fullscreen() { printf "\e[3;0;0;t\e[8;0;0t"; /usr/bin/clear; return 0; } - -# default screen -function defaultscreen() { printf "\e[8;35;150;t"; printf "\e[3;300;240;t"; /usr/bin/clear; return 0; } - -# max columns -function maxc() { printf "\e[3;0;0;t\e[8;50;0t"; /usr/bin/clear; return 0; } - -# max rows -function maxr() { printf "\e[3;0;0;t\e[8;0;100t"; /usr/bin/clear; return 0; } - -# show number of lines & columns -function lc() { printf "lines: $(/usr/bin/tput lines)\ncolums: $(/usr/bin/tput cols)\n"; return 0; } + } + + # Minimise terminal window to Dock + function mintw() { printf "\e[2t"; return 0; } + + # Send Terminal window to background + function bgtw() { printf "\e[6t"; return 0; } + + function hidetw() { + /usr/bin/osascript -e 'tell application "System Events" to set visible of some item of ( get processes whose name = "Terminal" ) to false' + return 0 + } + + # positive integer test (including zero) + function positive_int() { return $(test "$@" -eq "$@" > /dev/null 2>&1 && test "$@" -ge 0 > /dev/null 2>&1); } + + # move the Terminal window + function mvtw() { + if [[ $# -eq 2 ]] && $(positive_int "$1") && $(positive_int "$2"); then + printf "\e[3;${1};${2};t" + return 0 + fi + return 1 + } + + # resize the Terminal window + function sizetw() { + if [[ $# -eq 2 ]] && $(positive_int "$1") && $(positive_int "$2"); then + printf "\e[8;${1};${2};t" + /usr/bin/clear + return 0 + fi + return 1 + } + + # full screen + function fullscreen() { printf "\e[3;0;0;t\e[8;0;0t"; /usr/bin/clear; return 0; } + + # default screen + function defaultscreen() { printf "\e[8;35;150;t"; printf "\e[3;300;240;t"; /usr/bin/clear; return 0; } + + # max columns + function maxc() { printf "\e[3;0;0;t\e[8;50;0t"; /usr/bin/clear; return 0; } + + # max rows + function maxr() { printf "\e[3;0;0;t\e[8;0;100t"; /usr/bin/clear; return 0; } + + # show number of lines & columns + function lc() { printf "lines: $(/usr/bin/tput lines)\ncolums: $(/usr/bin/tput cols)\n"; return 0; } +fi \ No newline at end of file diff --git a/shells/common/rbenv.sh b/shells/common/rbenv.sh deleted file mode 100644 index fa039118..00000000 --- a/shells/common/rbenv.sh +++ /dev/null @@ -1,2 +0,0 @@ -which rbenv &>/dev/null || return -eval "$(rbenv init - $CURRENT_SHELL)" diff --git a/shells/common/ruby.sh b/shells/common/ruby.sh index 82ccefd8..e7484511 100644 --- a/shells/common/ruby.sh +++ b/shells/common/ruby.sh @@ -3,18 +3,36 @@ export IRBRC="$HOME/.irbrc" export RBXOPT="-Xrbc.db=/tmp/rbx -X19" export JRUBY_OPTS="--1.9" -function __database_yml { - if [[ -f config/database.yml ]]; then - ruby -ryaml -rerb -e "puts YAML::load(ERB.new(IO.read('config/database.yml')).result)['${RAILS_ENV:-development}']['$1']" - fi -} +# if [ -f $SHELL_FILES/../../languages/ruby/rubyrc.rb ]; then +# echo setting RUBYOPT +# export RUBYOPT="-r$SHELL_FILES/../../languages/ruby/rubyrc" +# fi -export PSQL_EDITOR='vim +"set syntax=sql"' -function psql -{ - if [[ "$(__database_yml adapter)" == 'postgresql' ]]; then - PGDATABASE="$(__database_yml database)" "$(which psql)" "$@" - return $? - fi - "$(/usr/bin/which psql)" "$@" -} +if [ -f "/usr/local/share/chruby/chruby.sh" ]; then + source /usr/local/share/chruby/chruby.sh + source /usr/local/share/chruby/auto.sh + + function current_ruby() { + if [ "x$RUBY_ROOT" != "x" ]; then + basename $RUBY_ROOT + else + return 1 + fi + } +elif command -v rbenv; then + eval "$(rbenv init - $CURRENT_SHELL)" + + function current_ruby() { + rbenv version-name + } +elif command -v rvm; then + source $HOME/.rvm/scripts/rvm + + function current_ruby() { + rvm-prompt + } +else + function current_ruby() { + exit 0 + } +fi diff --git a/shells/common/wsl.sh b/shells/common/wsl.sh new file mode 100644 index 00000000..7a1e3cf3 --- /dev/null +++ b/shells/common/wsl.sh @@ -0,0 +1,32 @@ +if [ -n "${WSL_DISTRO_NAME:-}" ] || grep -sqiE 'WSL' /proc/sys/kernel/osrelease; then + # # Talk to Windows' SSH-Agent when under WSL, using https://github.com/rupor-github/wsl-ssh-agent + # # wsl-ssh-agent started with: + # # + # # wsl-ssh-agent-gui.exe -setenv -envname=WSL_AUTH_SOCK -lemonade=2489;127.0.0.1/24 + # # + # [ -n ${WSL_AUTH_SOCK} ] && export SSH_AUTH_SOCK=${WSL_AUTH_SOCK} + + # Above does not work currently due to WSL1 -> WSL2 turbulence. Workaround below. + # Based on: https://github.com/rupor-github/wsl-ssh-agent/tree/4e08e3fa84380f4d62bfdf607ae6b2c680e1ff3e#wsl-2-compatibility + + # where I installed it (must be on Windows' filesystem) + NPIPERELAY_DIR="/mnt/c/Program Files/WSL-SSH-Agent" + + export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock + + ss -a | grep -q $SSH_AUTH_SOCK + + if [ $? -ne 0 ]; then + rm -f $SSH_AUTH_SOCK + ( + PATH="$NPIPERELAY_DIR:$PATH" + setsid socat \ + UNIX-LISTEN:$SSH_AUTH_SOCK,fork \ + EXEC:"npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork & + ) >/dev/null 2>&1 + fi + + # https://github.com/microsoft/WSL/issues/4166#issuecomment-618159162 + [ -z "$(ps -ef | grep cron | grep -v grep)" ] && sudo /etc/init.d/cron start &>/dev/null + hash -d win=/mnt/c/Users/me +fi \ No newline at end of file diff --git a/shells/local.bash b/shells/local.bash new file mode 100644 index 00000000..b24448f6 --- /dev/null +++ b/shells/local.bash @@ -0,0 +1 @@ +[ -f "$HOME/.local.bash" ] && source "$HOME/.local.bash" \ No newline at end of file diff --git a/shells/local.zsh b/shells/local.zsh new file mode 100644 index 00000000..cb419191 --- /dev/null +++ b/shells/local.zsh @@ -0,0 +1 @@ +[ -f "$HOME/.local.zshrc" ] && source "$HOME/.local.zshrc" diff --git a/shells/path.sh b/shells/path.sh index c0a125ea..7092cda3 100644 --- a/shells/path.sh +++ b/shells/path.sh @@ -1,3 +1,16 @@ +## TODO: remove duplicates when appending/prepending +## TODO: Ideally, __prepend will add (or move existing) entry to front while __append will add (or move) +## entry to back. Anything unmentioned should stay in the middle and anything mentioned should not +## be doubled up with system-provided. + +function __prepend_path { + if [ -z "$(eval echo \$$1)" ]; then + eval "$1=\"$2\"" + else + eval "$1=\"$2:\$$1\"" + fi +} + function __append_path { if [ -z "$(eval echo \$$1)" ]; then eval "$1=\"$2\"" @@ -6,15 +19,19 @@ function __append_path { fi } -[ -d "$HOME/bin" ] && __append_path "new_path" "$HOME/bin" -[ -d "$DOT_FILES/bin" ] && __append_path "new_path" "$DOT_FILES/bin" -[ -d '/usr/local/bin' ] && __append_path "new_path" "/usr/local/bin" -[ -d '/usr/local/sbin' ] && __append_path "new_path" "/usr/local/sbin" -[ -d '/opt/local/bin' ] && __append_path "new_path" "/opt/local/bin" -[ -d '/opt/local/sbin' ] && __append_path "new_path" "/opt/local/sbin" -[ -d '/usr/X11/bin' ] && __append_path "new_path" "/usr/X11/bin" -[ -d '/usr/bin' ] && __append_path "new_path" "/usr/bin" -[ -d '/usr/sbin' ] && __append_path "new_path" "/usr/sbin" -[ -d '/bin' ] && __append_path "new_path" "/bin" -[ -d '/sbin' ] && __append_path "new_path" "/sbin" -PATH="$new_path" +[ -d '/usr/local/bin' ] && __prepend_path "PATH" "/usr/local/bin" +[ -d '/usr/local/sbin' ] && __prepend_path "PATH" "/usr/local/sbin" +[ -d '/opt/local/bin' ] && __prepend_path "PATH" "/opt/local/bin" +[ -d '/opt/local/sbin' ] && __prepend_path "PATH" "/opt/local/sbin" +[ -d '/opt/bin' ] && __prepend_path "PATH" "/opt/bin" +[ -d '/opt/sbin' ] && __prepend_path "PATH" "/opt/sbin" +[ -d "$HOME/bin" ] && __prepend_path "PATH" "$HOME/bin" +[ -d "$HOME/.local/bin" ] && __prepend_path "PATH" "$HOME/.local/bin" +[ -d "$HOME/.cargo/bin" ] && __prepend_path "PATH" "$HOME/.cargo/bin" +[ -d "$HOME/.emacs.d/bin" ] && __prepend_path "PATH" "$HOME/.emacs.d/bin" +[ -d "$HOME/.dotfiles/bin" ] && __prepend_path "PATH" "$HOME/.dotfiles/bin" +[ -d '/usr/X11/bin' ] && __append_path "PATH" "/usr/X11/bin" +[ -d '/usr/bin' ] && __append_path "PATH" "/usr/bin" +[ -d '/usr/sbin' ] && __append_path "PATH" "/usr/sbin" +[ -d '/bin' ] && __append_path "PATH" "/bin" +[ -d '/sbin' ] && __append_path "PATH" "/sbin" diff --git a/shells/tmux.sh b/shells/tmux.sh index 2fc0fbdc..a092170c 100644 --- a/shells/tmux.sh +++ b/shells/tmux.sh @@ -1,22 +1,15 @@ -# I always want to be in a Tmux session. Always. -# -# This creates a single always-running "login" session, and creates -# new session as needed that are bound to "login"'s window group. -# This lets me have a different terminals tabs/windows have the same tmux -# windows but be looking at different ones individually +# I always want to be in a Tmux session when SSHing into a box. -# If we aren't in Tmux, set it up -if [ -z "$TMUX" ]; then - if which tmux 2>&1 >/dev/null; then - if [ -z "$(tmux ls | grep 'login:')" ]; then - tmux new-session -d -s login # Create a detached session called login - tmux new-session -t login # Create a *new* session bound to the same windows - else - last_session="$(tmux list-windows -t login | tail -n1 | cut -d: -f1)" - tmux new-session -t login \; new-window -a -t $last_session # Create a *new* session bound to "login" and create a new window - fi +# If we aren't already in Tmux or emacs, set it up +if command -v tmux &>/dev/null && [ "$SSH_CONNECTION" -a -z "$TMUX" -a -z "$INSIDE_EMACS" -a -z "$EMACS" -a -z "$VIM" -a -z "$VIMRUNTIME" ]; then + if tty >/dev/null; then + if tmux has-session -t login 2>/dev/null; then + tmux new-session -t login \; new-window + else + tmux new-session -s login + fi - # When Tmux exits, we exit - exit - fi + # When Tmux exits, we exit + exit + fi fi diff --git a/shells/zsh/.gitignore b/shells/zsh/.gitignore deleted file mode 100644 index b6d6fefa..00000000 --- a/shells/zsh/.gitignore +++ /dev/null @@ -1 +0,0 @@ -oh-my-zsh \ No newline at end of file diff --git a/shells/zsh/config.zsh b/shells/zsh/config.zsh index 427b26ca..a83a73e4 100644 --- a/shells/zsh/config.zsh +++ b/shells/zsh/config.zsh @@ -1,6 +1,6 @@ alias reload="source ~/.zshrc" -fpath=($SHELL_FILES/completions $fpath) +[[ $EMACS = t ]] && unsetopt zle # Option-Left + Option-Right for moving word-by-word in OS X bindkey "\e\e[C" vi-forward-word diff --git a/shells/zsh/lib/completion-waiting-dots.zsh b/shells/zsh/lib/completion-waiting-dots.zsh new file mode 100644 index 00000000..b3cb37c1 --- /dev/null +++ b/shells/zsh/lib/completion-waiting-dots.zsh @@ -0,0 +1,8 @@ +# http://stackoverflow.com/a/844299 +expand-or-complete-with-dots() { + echo -n "\e[31m...\e[0m" + zle expand-or-complete + zle redisplay +} +zle -N expand-or-complete-with-dots +bindkey "^I" expand-or-complete-with-dots diff --git a/shells/zsh/lib/fish.zsh b/shells/zsh/lib/fish.zsh index b2c380d5..7a41fd19 100644 --- a/shells/zsh/lib/fish.zsh +++ b/shells/zsh/lib/fish.zsh @@ -1,2 +1,33 @@ -source $SHELL_FILES/lib/syntax-highlighting/zsh-syntax-highlighting.zsh -source $SHELL_FILES/lib/history-substring-search/zsh-history-substring-search.zsh +source $FRESH_PATH/build/vendor/zsh-autosuggestions/zsh-autosuggestions.zsh +source $FRESH_PATH/build/vendor/zsh-history-substring-search/zsh-history-substring-search.zsh +source $FRESH_PATH/build/vendor/zsh-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh + +autoload -U up-line-or-beginning-search +zle -N up-line-or-beginning-search + +autoload -U down-line-or-beginning-search +zle -N down-line-or-beginning-search + +# bind UP and DOWN arrow keys to prefix search history (diff keys for diff terms) +bindkey '^[[A' up-line-or-beginning-search +bindkey '^[OA' up-line-or-beginning-search +bindkey '^[[B' down-line-or-beginning-search +bindkey '^[OB' down-line-or-beginning-search + +# bind SHIFT-UP / SHIFT-DOWN & PAGE UP / PAGE DOWN to search history matching current contents (non-prefix) +bindkey '^[[5~' history-substring-search-up +bindkey '^[[1;2A' history-substring-search-up +bindkey '^[[6~' history-substring-search-down +bindkey '^[[1;2B' history-substring-search-down + +# Bind control + LEFT and RIGHT arrow keys to jump by word +bindkey "^[[1;5C" forward-word +bindkey "^[[1;5D" backward-word + +# bind P and N for EMACS mode +bindkey -M emacs '^P' history-substring-search-up +bindkey -M emacs '^N' history-substring-search-down + +# bind k and j for VI mode +bindkey -M vicmd 'k' history-substring-search-up +bindkey -M vicmd 'j' history-substring-search-down diff --git a/shells/zsh/lib/history-substring-search b/shells/zsh/lib/history-substring-search new file mode 160000 index 00000000..1e768040 --- /dev/null +++ b/shells/zsh/lib/history-substring-search @@ -0,0 +1 @@ +Subproject commit 1e7680405239a835aa403a7457cad23750f98e72 diff --git a/shells/zsh/lib/history-substring-search/README.md b/shells/zsh/lib/history-substring-search/README.md deleted file mode 100644 index 64fe5282..00000000 --- a/shells/zsh/lib/history-substring-search/README.md +++ /dev/null @@ -1,92 +0,0 @@ -zsh-history-substring-search -============================================================================== - -This is a clean-room implementation of the [Fish shell][1]'s history search -feature, where you can type in any part of any previously entered command -and press the UP and DOWN arrow keys to cycle through the matching commands. - -[1]: http://fishshell.com -[2]: http://www.zsh.org/mla/users/2009/msg00818.html -[3]: http://sourceforge.net/projects/fizsh/ -[4]: https://github.com/robbyrussell/oh-my-zsh/pull/215 -[5]: https://github.com/zsh-users/zsh-history-substring-search -[6]: https://github.com/zsh-users/zsh-syntax-highlighting - ----------------------------------------------------------------------------- -Usage ----------------------------------------------------------------------------- - -1. Load this script into your interactive ZSH session: - - % source zsh-history-substring-search.zsh - - If you want to use [zsh-syntax-highlighting][6] along with this script, - then make sure that you load it *before* you load this script: - - % source zsh-syntax-highlighting.zsh - % source zsh-history-substring-search.zsh - -2. Type any part of any previous command and then: - - * Press the UP arrow key to select the nearest command that (1) contains - your query and (2) is older than the current command in the command - history. - - * Press the DOWN arrow key to select the nearest command that (1) - contains your query and (2) is newer than the current command in the - command history. - - * Press ^U (the Control and U keys simultaneously) to abort the search. - -3. If a matching command spans more than one line of text, press the LEFT - arrow key to move the cursor away from the end of the command, and then: - - * Press the UP arrow key to move the cursor to the line above. When the - cursor reaches the first line of the command, pressing the UP arrow - key again will cause this script to perform another search. - - * Press the DOWN arrow key to move the cursor to the line below. When - the cursor reaches the last line of the command, pressing the DOWN - arrow key again will cause this script to perform another search. - ----------------------------------------------------------------------------- -Configuration ----------------------------------------------------------------------------- - -This script defines the following global variables. You may override their -default values only after having loaded this script into your ZSH session. - -* HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND is a global variable that defines - how the query should be highlighted inside a matching command. Its default - value causes this script to highlight using bold, white text on a magenta - background. See the "Character Highlighting" section in the zshzle(1) man - page to learn about the kinds of values you may assign to this variable. - -* HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND is a global variable that - defines how the query should be highlighted when no commands in the - history match it. Its default value causes this script to highlight using - bold, white text on a red background. See the "Character Highlighting" - section in the zshzle(1) man page to learn about the kinds of values you - may assign to this variable. - -* HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS is a global variable that defines - how the command history will be searched for your query. Its default value - causes this script to perform a case-insensitive search. See the "Globbing - Flags" section in the zshexpn(1) man page to learn about the kinds of - values you may assign to this variable. - ----------------------------------------------------------------------------- -History ----------------------------------------------------------------------------- - -This script was originally written by [Peter Stephenson][2], who published it -to the ZSH users mailing list (thereby making it public domain) in September -2009. It was later revised by Guido van Steen and released under the BSD -license (see below) as part of [the fizsh project][3] in January 2011. - -It was later extracted from fizsh release 1.0.1, refactored heavily, and -repackaged as both an [oh-my-zsh plugin][4] and as an independently loadable -[ZSH script][5] by Suraj N. Kurapati in 2011. - -It was [further developed][4] by Guido van Steen, Suraj N. Kurapati, Sorin -Ionescu, and Vincent Guerci in 2011. diff --git a/shells/zsh/lib/history-substring-search/zsh-history-substring-search.plugin.zsh b/shells/zsh/lib/history-substring-search/zsh-history-substring-search.plugin.zsh deleted file mode 100644 index b393f66d..00000000 --- a/shells/zsh/lib/history-substring-search/zsh-history-substring-search.plugin.zsh +++ /dev/null @@ -1,12 +0,0 @@ -# This file integrates the zsh-history-substring-search script into oh-my-zsh. - -source "${0:r:r}.zsh" - -if test "$CASE_SENSITIVE" = true; then - unset HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS -fi - -if test "$DISABLE_COLOR" = true; then - unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - unset HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND -fi diff --git a/shells/zsh/lib/history-substring-search/zsh-history-substring-search.zsh b/shells/zsh/lib/history-substring-search/zsh-history-substring-search.zsh deleted file mode 100644 index e03e3103..00000000 --- a/shells/zsh/lib/history-substring-search/zsh-history-substring-search.zsh +++ /dev/null @@ -1,554 +0,0 @@ -#!/usr/bin/env zsh -############################################################################## -# -# Copyright (c) 2009 Peter Stephenson -# Copyright (c) 2011 Guido van Steen -# Copyright (c) 2011 Suraj N. Kurapati -# Copyright (c) 2011 Sorin Ionescu -# Copyright (c) 2011 Vincent Guerci -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# * Neither the name of the FIZSH nor the names of its contributors -# may be used to endorse or promote products derived from this -# software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################## - -#----------------------------------------------------------------------------- -# configuration variables -#----------------------------------------------------------------------------- - -HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold' -HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold' -HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i' - -#----------------------------------------------------------------------------- -# the main ZLE widgets -#----------------------------------------------------------------------------- - -function history-substring-search-up() { - _history-substring-search-begin - - _history-substring-search-up-history || - _history-substring-search-up-buffer || - _history-substring-search-up-search - - _history-substring-search-end -} - -function history-substring-search-down() { - _history-substring-search-begin - - _history-substring-search-down-history || - _history-substring-search-down-buffer || - _history-substring-search-down-search - - _history-substring-search-end -} - -zle -N history-substring-search-up -zle -N history-substring-search-down - -bindkey '\e[A' history-substring-search-up -bindkey '\e[B' history-substring-search-down - -#----------------------------------------------------------------------------- -# implementation details -#----------------------------------------------------------------------------- - -zmodload -F zsh/parameter - -# -# We have to "override" some keys and widgets if the -# zsh-syntax-highlighting plugin has not been loaded: -# -# https://github.com/nicoulaj/zsh-syntax-highlighting -# -if [[ $+functions[_zsh_highlight] -eq 0 ]]; then - # - # Dummy implementation of _zsh_highlight() - # that simply removes existing highlights - # - function _zsh_highlight() { - region_highlight=() - } - - # - # Remove existing highlights when the user - # inserts printable characters into $BUFFER - # - function ordinary-key-press() { - if [[ $KEYS == [[:print:]] ]]; then - region_highlight=() - fi - zle .self-insert - } - zle -N self-insert ordinary-key-press - - # - # Override ZLE widgets to invoke _zsh_highlight() - # - # https://github.com/nicoulaj/zsh-syntax-highlighting/blob/ - # bb7fcb79fad797a40077bebaf6f4e4a93c9d8163/zsh-syntax-highlighting.zsh#L121 - # - #--------------8<-------------------8<-------------------8<----------------- - # - # Copyright (c) 2010-2011 zsh-syntax-highlighting contributors - # All rights reserved. - # - # Redistribution and use in source and binary forms, with or without - # modification, are permitted provided that the following conditions are - # met: - # - # * Redistributions of source code must retain the above copyright - # notice, this list of conditions and the following disclaimer. - # - # * Redistributions in binary form must reproduce the above copyright - # notice, this list of conditions and the following disclaimer in the - # documentation and/or other materials provided with the distribution. - # - # * Neither the name of the zsh-syntax-highlighting contributors nor the - # names of its contributors may be used to endorse or promote products - # derived from this software without specific prior written permission. - # - # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - # Load ZSH module zsh/zleparameter, needed to override user defined widgets. - zmodload zsh/zleparameter 2>/dev/null || { - echo 'zsh-syntax-highlighting: failed loading zsh/zleparameter, exiting.' >&2 - return -1 - } - - # Override ZLE widgets to make them invoke _zsh_highlight. - for event in ${${(f)"$(zle -la)"}:#(_*|orig-*|.run-help|.which-command)}; do - if [[ "$widgets[$event]" == completion:* ]]; then - eval "zle -C orig-$event ${${${widgets[$event]}#*:}/:/ } ; $event() { builtin zle orig-$event && _zsh_highlight } ; zle -N $event" - else - case $event in - accept-and-menu-complete) - eval "$event() { builtin zle .$event && _zsh_highlight } ; zle -N $event" - ;; - - # The following widgets should NOT remove any previously - # applied highlighting. Therefore we do not remap them. - .forward-char|.backward-char|.up-line-or-history|.down-line-or-history) - ;; - - .*) - clean_event=$event[2,${#event}] # Remove the leading dot in the event name - case ${widgets[$clean_event]-} in - (completion|user):*) - ;; - *) - eval "$clean_event() { builtin zle $event && _zsh_highlight } ; zle -N $clean_event" - ;; - esac - ;; - *) - ;; - esac - fi - done - unset event clean_event - #-------------->8------------------->8------------------->8----------------- -fi - -function _history-substring-search-begin() { - setopt localoptions extendedglob - - _history_substring_search_move_cursor_eol=false - _history_substring_search_query_highlight= - - # - # Continue using the previous $_history_substring_search_result by default, - # unless the current query was cleared or a new/different query was entered. - # - if [[ -z $BUFFER || $BUFFER != $_history_substring_search_result ]]; then - # - # For the purpose of highlighting we will also keep - # a version without doubly-escaped meta characters. - # - _history_substring_search_query=$BUFFER - - # - # $BUFFER contains the text that is in the command-line currently. - # we put an extra "\\" before meta characters such as "\(" and "\)", - # so that they become "\\\(" and "\\\)". - # - _history_substring_search_query_escaped=${BUFFER//(#m)[\][()|\\*?#<>~^]/\\$MATCH} - - # - # Find all occurrences of the search query in the history file. - # - # (k) turns it an array of line numbers. - # - # (on) seems to remove duplicates, which are default - # options. They can be turned off by (ON). - # - _history_substring_search_matches=(${(kon)history[(R)(#$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)*${_history_substring_search_query_escaped}*]}) - - # - # Define the range of values that $_history_substring_search_match_index - # can take: [0, $_history_substring_search_matches_count_plus]. - # - _history_substring_search_matches_count=$#_history_substring_search_matches - _history_substring_search_matches_count_plus=$(( _history_substring_search_matches_count + 1 )) - _history_substring_search_matches_count_sans=$(( _history_substring_search_matches_count - 1 )) - - # - # If $_history_substring_search_match_index is equal to - # $_history_substring_search_matches_count_plus, this indicates that we - # are beyond the beginning of $_history_substring_search_matches. - # - # If $_history_substring_search_match_index is equal to 0, this indicates - # that we are beyond the end of $_history_substring_search_matches. - # - # If we have initially pressed "up" we have to initialize - # $_history_substring_search_match_index to - # $_history_substring_search_matches_count_plus so that it will be - # decreased to $_history_substring_search_matches_count. - # - # If we have initially pressed "down" we have to initialize - # $_history_substring_search_match_index to - # $_history_substring_search_matches_count so that it will be increased to - # $_history_substring_search_matches_count_plus. - # - if [[ $WIDGET == history-substring-search-down ]]; then - _history_substring_search_match_index=$_history_substring_search_matches_count - else - _history_substring_search_match_index=$_history_substring_search_matches_count_plus - fi - fi -} - -function _history-substring-search-end() { - setopt localoptions extendedglob - - _history_substring_search_result=$BUFFER - - # move the cursor to the end of the command line - if [[ $_history_substring_search_move_cursor_eol == true ]]; then - CURSOR=${#BUFFER} - fi - - # highlight command line using zsh-syntax-highlighting - _zsh_highlight - - # highlight the search query inside the command line - if [[ -n $_history_substring_search_query_highlight && -n $_history_substring_search_query ]]; then - # - # The following expression yields a variable $MBEGIN, which - # indicates the begin position + 1 of the first occurrence - # of _history_substring_search_query_escaped in $BUFFER. - # - : ${(S)BUFFER##(#m$HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS)($_history_substring_search_query##)} - local begin=$(( MBEGIN - 1 )) - local end=$(( begin + $#_history_substring_search_query )) - region_highlight+=("$begin $end $_history_substring_search_query_highlight") - fi - - # For debugging purposes: - # zle -R "mn: "$_history_substring_search_match_index" m#: "${#_history_substring_search_matches} - # read -k -t 200 && zle -U $REPLY - - # Exit successfully from the history-substring-search-* widgets. - true -} - -function _history-substring-search-up-buffer() { - # - # Check if the UP arrow was pressed to move the cursor within a multi-line - # buffer. This amounts to three tests: - # - # 1. $#buflines -gt 1. - # - # 2. $CURSOR -ne $#BUFFER. - # - # 3. Check if we are on the first line of the current multi-line buffer. - # If so, pressing UP would amount to leaving the multi-line buffer. - # - # We check this by adding an extra "x" to $LBUFFER, which makes - # sure that xlbuflines is always equal to the number of lines - # until $CURSOR (including the line with the cursor on it). - # - local buflines XLBUFFER xlbuflines - buflines=(${(f)BUFFER}) - XLBUFFER=$LBUFFER"x" - xlbuflines=(${(f)XLBUFFER}) - - if [[ $#buflines -gt 1 && $CURSOR -ne $#BUFFER && $#xlbuflines -ne 1 ]]; then - zle up-line-or-history - return true - fi - - false -} - -function _history-substring-search-down-buffer() { - # - # Check if the DOWN arrow was pressed to move the cursor within a multi-line - # buffer. This amounts to three tests: - # - # 1. $#buflines -gt 1. - # - # 2. $CURSOR -ne $#BUFFER. - # - # 3. Check if we are on the last line of the current multi-line buffer. - # If so, pressing DOWN would amount to leaving the multi-line buffer. - # - # We check this by adding an extra "x" to $RBUFFER, which makes - # sure that xrbuflines is always equal to the number of lines - # from $CURSOR (including the line with the cursor on it). - # - local buflines XRBUFFER xrbuflines - buflines=(${(f)BUFFER}) - XRBUFFER="x"$RBUFFER - xrbuflines=(${(f)XRBUFFER}) - - if [[ $#buflines -gt 1 && $CURSOR -ne $#BUFFER && $#xrbuflines -ne 1 ]]; then - zle down-line-or-history - return true - fi - - false -} - -function _history-substring-search-up-history() { - # - # Behave like up in ZSH, except clear the $BUFFER - # when beginning of history is reached like in Fish. - # - if [[ -z $_history_substring_search_query ]]; then - - # we have reached the absolute top of history - if [[ $HISTNO -eq 1 ]]; then - BUFFER= - - # going up from somewhere below the top of history - else - zle up-line-or-history - fi - - return true - fi - - false -} - -function _history-substring-search-down-history() { - # - # Behave like down-history in ZSH, except clear the - # $BUFFER when end of history is reached like in Fish. - # - if [[ -z $_history_substring_search_query ]]; then - - # going down from the absolute top of history - if [[ $HISTNO -eq 1 && -z $BUFFER ]]; then - BUFFER=${history[1]} - _history_substring_search_move_cursor_eol=true - - # going down from somewhere above the bottom of history - else - zle down-line-or-history - fi - - return true - fi - - false -} - -function _history-substring-search-up-search() { - _history_substring_search_move_cursor_eol=true - - # - # Highlight matches during history-substring-up-search: - # - # The following constants have been initialized in - # _history-substring-search-up/down-search(): - # - # $_history_substring_search_matches is the current list of matches - # $_history_substring_search_matches_count is the current number of matches - # $_history_substring_search_matches_count_plus is the current number of matches + 1 - # $_history_substring_search_matches_count_sans is the current number of matches - 1 - # $_history_substring_search_match_index is the index of the current match - # - # The range of values that $_history_substring_search_match_index can take - # is: [0, $_history_substring_search_matches_count_plus]. A value of 0 - # indicates that we are beyond the end of - # $_history_substring_search_matches. A value of - # $_history_substring_search_matches_count_plus indicates that we are beyond - # the beginning of $_history_substring_search_matches. - # - # In _history-substring-search-up-search() the initial value of - # $_history_substring_search_match_index is - # $_history_substring_search_matches_count_plus. This value is set in - # _history-substring-search-begin(). _history-substring-search-up-search() - # will initially decrease it to $_history_substring_search_matches_count. - # - if [[ $_history_substring_search_match_index -ge 2 ]]; then - # - # Highlight the next match: - # - # 1. Decrease the value of $_history_substring_search_match_index. - # - # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index-- )) - BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]] - _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - - elif [[ $_history_substring_search_match_index -eq 1 ]]; then - # - # We will move beyond the end of $_history_substring_search_matches: - # - # 1. Decrease the value of $_history_substring_search_match_index. - # - # 2. Save the current buffer in $_history_substring_search_old_buffer, - # so that it can be retrieved by - # _history-substring-search-down-search() later. - # - # 3. Make $BUFFER equal to $_history_substring_search_query. - # - # 4. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index-- )) - _history_substring_search_old_buffer=$BUFFER - BUFFER=$_history_substring_search_query - _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND - - elif [[ $_history_substring_search_match_index -eq $_history_substring_search_matches_count_plus ]]; then - # - # We were beyond the beginning of $_history_substring_search_matches but - # UP makes us move back to $_history_substring_search_matches: - # - # 1. Decrease the value of $_history_substring_search_match_index. - # - # 2. Restore $BUFFER from $_history_substring_search_old_buffer. - # - # 3. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index-- )) - BUFFER=$_history_substring_search_old_buffer - _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - fi -} - -function _history-substring-search-down-search() { - _history_substring_search_move_cursor_eol=true - - # - # Highlight matches during history-substring-up-search: - # - # The following constants have been initialized in - # _history-substring-search-up/down-search(): - # - # $_history_substring_search_matches is the current list of matches - # $_history_substring_search_matches_count is the current number of matches - # $_history_substring_search_matches_count_plus is the current number of matches + 1 - # $_history_substring_search_matches_count_sans is the current number of matches - 1 - # $_history_substring_search_match_index is the index of the current match - # - # The range of values that $_history_substring_search_match_index can take - # is: [0, $_history_substring_search_matches_count_plus]. A value of 0 - # indicates that we are beyond the end of - # $_history_substring_search_matches. A value of - # $_history_substring_search_matches_count_plus indicates that we are beyond - # the beginning of $_history_substring_search_matches. - # - # In _history-substring-search-down-search() the initial value of - # $_history_substring_search_match_index is - # $_history_substring_search_matches_count. This value is set in - # _history-substring-search-begin(). - # _history-substring-search-down-search() will initially increase it to - # $_history_substring_search_matches_count_plus. - # - if [[ $_history_substring_search_match_index -le $_history_substring_search_matches_count_sans ]]; then - # - # Highlight the next match: - # - # 1. Increase $_history_substring_search_match_index by 1. - # - # 2. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index++ )) - BUFFER=$history[$_history_substring_search_matches[$_history_substring_search_match_index]] - _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - - elif [[ $_history_substring_search_match_index -eq $_history_substring_search_matches_count ]]; then - # - # We will move beyond the beginning of $_history_substring_search_matches: - # - # 1. Increase $_history_substring_search_match_index by 1. - # - # 2. Save the current buffer in $_history_substring_search_old_buffer, so - # that it can be retrieved by _history-substring-search-up-search() - # later. - # - # 3. Make $BUFFER equal to $_history_substring_search_query. - # - # 4. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index++ )) - _history_substring_search_old_buffer=$BUFFER - BUFFER=$_history_substring_search_query - _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND - - elif [[ $_history_substring_search_match_index -eq 0 ]]; then - # - # We were beyond the end of $_history_substring_search_matches but DOWN - # makes us move back to the $_history_substring_search_matches: - # - # 1. Increase $_history_substring_search_match_index by 1. - # - # 2. Restore $BUFFER from $_history_substring_search_old_buffer. - # - # 3. Use $HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - # to highlight the current buffer. - # - (( _history_substring_search_match_index++ )) - BUFFER=$_history_substring_search_old_buffer - _history_substring_search_query_highlight=$HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND - fi -} - -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et diff --git a/shells/zsh/lib/history.zsh b/shells/zsh/lib/history.zsh new file mode 100644 index 00000000..191d7f3c --- /dev/null +++ b/shells/zsh/lib/history.zsh @@ -0,0 +1,14 @@ +## Command history configuration +HISTFILE=$HOME/.zsh_history +HISTSIZE=1000000 +SAVEHIST=1000000 + +setopt EXTENDED_HISTORY +setopt HIST_EXPIRE_DUPS_FIRST +setopt HIST_IGNORE_ALL_DUPS +setopt HIST_IGNORE_DUPS +setopt HIST_IGNORE_SPACE +setopt HIST_NO_STORE +setopt HIST_REDUCE_BLANKS +setopt HIST_VERIFY +setopt SHARE_HISTORY diff --git a/shells/zsh/lib/prompt.zsh b/shells/zsh/lib/prompt.zsh index 5db829bf..d9cfeb5f 100644 --- a/shells/zsh/lib/prompt.zsh +++ b/shells/zsh/lib/prompt.zsh @@ -1,123 +1 @@ -autoload zsh/terminfo - -pr_reset="%f%u%k%s%b" # reset all codes - -if [ "$terminfo[colors]" -eq 256 ]; then - pr_red="%F{52}" - pr_blue="%F{25}" - pr_green="%F{28}" - pr_grey="%F{59}" -else - if [ "$terminfo[colors]" -eq 8 ]; then - pr_red="%F{red}" - pr_blue="%F{blue}" - pr_green="%F{green}" - pr_grey="%B%F{black}" - fi -fi - -# VCS configuration -autoload vcs_info -zstyle ':vcs_info:*' enable git hg svn -zstyle ':vcs_info:*' get-revision true -zstyle ':vcs_info:*' formats "(%s) %b@%6>>%i%<<…" "%r" "%R" "%S" -zstyle ':vcs_info:*' actionformats "(%s) %b@%6>>%i%<<…|%U%a%%u" -zstyle ':vcs_info:*' branchformat "%b:%r" -zstyle ':vcs_info:hg*:*' use-simple true -zstyle ':vcs_info:svn:*' formats "(%s) %b:r%i" "%r" -zstyle ':vcs_info:svn:*' branchformat "%b" - -# TODO: -# - Discover root of repo based on full path, not basename (to avoid underlining multiple path components) ($vcs_info_msg_2_) -function prompt_pwd() { - local repo="$vcs_info_msg_1_" - - parts=(${(s:/:)${${PWD}/#${HOME}/\~}}) - - i=0 - while (( i++ < ${#parts} )); do - part="$parts[i]" - if [[ "$part" == "$repo" ]]; then - # if this part of the path represents the repo, - # underline it, and skip truncating the component - parts[i]="%U$part%u" - else - # Shorten the path as long as it isn't the last piece - if [[ "$parts[${#parts}]" != "$part" ]]; then - parts[i]="$part[1,1]" - fi - fi - done - - local prompt_path="${(j:/:)parts}" - if [ "$parts[1]" != "~" ]; then - prompt_path="/$prompt_path" - fi - echo "$prompt_path" -} - - -function prompt_pwd_new() { - local parts path part cwd i=0 - typeset -L path - - - parts=(${(s:/:)${${PWD}/#${HOME}/\~}}) - - while (( i++ < ${#parts} )); do - part="$parts[i]" - - if [[ "$part" == "~" ]]; then - path="$part" - else - # This check is broken because LHS is collapsed, RHS is expanded - if [[ "$path/$part" == "${vcs_info_msg_2_/#${HOME}/~}" ]]; then - part="%U$part%u" - elif [[ "$parts[${#parts}]" != "$part" ]]; then - part="$part[1,1]" - fi - - path="$path/$part" - fi - - # if [[ "$part" == "$repo" ]]; then - # # if this part of the path represents the repo, - # # underline it, and skip truncating the component - # parts[i]="%U$part%u" - # else - # # Shorten the path as long as it isn't the last piece - # if [[ "$parts[${#parts}]" != "$part" ]]; then - # parts[i]="$part[1,1]" - # fi - # fi - done - - echo "$path" -} - -function precmd { - vcs_info - - local cwd="$pr_blue`prompt_pwd`$pr_reset" - local char="%0(?.$pr_green.$pr_red)♪$pr_reset" - local time="$pr_grey⌚ %*$pr_reset" - - local ruby - which rvm-prompt &>/dev/null && ruby="❖ `rvm-prompt`" - which rbenv &>/dev/null && ruby="❖ `rbenv version-name`" - - - local rev="$pr_grey$vcs_info_msg_0_$pr_reset" - rev="${rev/\(git\)/Âą}" - rev="${rev/\(hg\)/☿}" - rev="${rev/\(svn\)/↯}" - - local left right - left=($(user_at_host) $cwd $char) - right=($rev $ruby $time) - - PS1="$left [ " - RPS1="] $right" -} - - +source $FRESH_PATH/build/vendor/powerlevel10k/powerlevel10k.zsh-theme \ No newline at end of file diff --git a/shells/zsh/lib/syntax-highlighting b/shells/zsh/lib/syntax-highlighting new file mode 160000 index 00000000..dbd27cb3 --- /dev/null +++ b/shells/zsh/lib/syntax-highlighting @@ -0,0 +1 @@ +Subproject commit dbd27cb30a710809dd070669c331574fdc15b397 diff --git a/shells/zsh/lib/syntax-highlighting/.gitignore b/shells/zsh/lib/syntax-highlighting/.gitignore deleted file mode 100644 index 13b92153..00000000 --- a/shells/zsh/lib/syntax-highlighting/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.zwc* diff --git a/shells/zsh/lib/syntax-highlighting/COPYING.md b/shells/zsh/lib/syntax-highlighting/COPYING.md deleted file mode 100644 index 2aa64389..00000000 --- a/shells/zsh/lib/syntax-highlighting/COPYING.md +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted -provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions - and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of - conditions and the following disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors - may be used to endorse or promote products derived from this software without specific prior - written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/shells/zsh/lib/syntax-highlighting/README.md b/shells/zsh/lib/syntax-highlighting/README.md deleted file mode 100644 index 233870cb..00000000 --- a/shells/zsh/lib/syntax-highlighting/README.md +++ /dev/null @@ -1,47 +0,0 @@ -zsh-syntax-highlighting -======================= - -**[Fish shell](http://www.fishshell.com) like syntax highlighting for [Zsh](http://www.zsh.org).** - -*Requirements: zsh 4.3.9+.* - - -How to install --------------- - -### In your ~/.zshrc - -* Download the script or clone this repository: - - git clone git://github.com/zsh-users/zsh-syntax-highlighting.git - -* Source the script **at the end** of `~/.zshrc`: - - source /path/to/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh - -* Source `~/.zshrc` to take changes into account: - - source ~/.zshrc - - -### With oh-my-zsh - -* Download the script or clone this repository in [oh-my-zsh](http://github.com/robbyrussell/oh-my-zsh) plugins directory: - - cd ~/.oh-my-zsh/plugins/ - git clone git://github.com/zsh-users/zsh-syntax-highlighting.git - -* Activate the plugin in `~/.zshrc` (in **last** position): - - plugins=( [plugins...] zsh-syntax-highlighting) - -* Source `~/.zshrc` to take changes into account: - - source ~/.zshrc - - -How to tweak ------------- - -Syntax highlighting is done by pluggable highlighter scripts, see the [highlighters directory](zsh-syntax-highlighting/tree/master/highlighters) -for documentation and configuration settings. diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/README.md b/shells/zsh/lib/syntax-highlighting/highlighters/README.md deleted file mode 100644 index 1b075649..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/README.md +++ /dev/null @@ -1,49 +0,0 @@ -zsh-syntax-highlighting / highlighters -====================================== - -Syntax highlighting is done by pluggable highlighters: - -* [***main***](highlighters/main) - the base highlighter, and the only one active by default. -* [***brackets***](highlighters/brackets) - matches brackets and parenthesis. -* [***pattern***](highlighters/pattern) - matches user-defined patterns. -* [***cursor***](highlighters/cursor) - matches the cursor position. -* [***root***](highlighters/root) - triggered if the current user is root. - - -How to activate highlighters ----------------------------- - -To activate an highlighter, add it to the `ZSH_HIGHLIGHT_HIGHLIGHTERS` array in `~/.zshrc`, for example: - - ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor) - - -How to tweak highlighters -------------------------- - -Highlighters look up styles from the `ZSH_HIGHLIGHT_STYLES` array. Navigate into each highlighter directory to see what styles it defines and how to configure it. - - -How to implement a new highlighter ----------------------------------- - -To create your own ***myhighlighter*** highlighter: - -* Create your script at **highlighters/*myhighlighter*/*myhighlighter*-highlighter.zsh**. -* Implement the `_zsh_highlight_myhighlighter_highlighter_predicate` function. This function must return 0 when the highlighter needs to be called, for example: - - _zsh_highlight_myhighlighter_highlighter_predicate() { - # Call this highlighter in SVN repositories - [[ -d .svn ]] - } - -* Implement the `_zsh_highlight_myhighlighter_highlighter` function. This function does the actual syntax highlighting, by modifying `region_highlight`, for example: - - _zsh_highlight_myhighlighter_highlighter() { - # Colorize the whole buffer with blue background - region_highlight+=(0 $#BUFFER bg=blue) - } - -* Activate your highlighter in `~/.zshrc`: - - ZSH_HIGHLIGHT_HIGHLIGHTERS+=(myhighlighter) diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/brackets/README.md b/shells/zsh/lib/syntax-highlighting/highlighters/brackets/README.md deleted file mode 100644 index 9fd4f96f..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/brackets/README.md +++ /dev/null @@ -1,30 +0,0 @@ -zsh-syntax-highlighting / highlighters / brackets -================================================= - -This is the ***brackets*** highlighter, that highlights brackets, parenthesis and matches them. - - -How to activate it ------------------- -To activate it, add it to `ZSH_HIGHLIGHT_HIGHLIGHTERS`: - - ZSH_HIGHLIGHT_HIGHLIGHTERS=( [...] brackets) - - -How to tweak it ---------------- -This highlighter defines the following styles: - -* `bracket-error` - unmatched brackets -* `bracket-level-N` - brackets with nest level N -* `cursor-matchingbracket` - the matching bracket, if cursor is on a bracket - -To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, for example in `~/.zshrc`: - - # To define styles for nested brackets up to level 4 - ZSH_HIGHLIGHT_STYLES[bracket-level-1]='fg=blue,bold' - ZSH_HIGHLIGHT_STYLES[bracket-level-2]='fg=red,bold' - ZSH_HIGHLIGHT_STYLES[bracket-level-3]='fg=yellow,bold' - ZSH_HIGHLIGHT_STYLES[bracket-level-4]='fg=magenta,bold' - -The syntax for declaring styles is [documented here](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135). diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/brackets/brackets-highlighter.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/brackets/brackets-highlighter.zsh deleted file mode 100644 index 5166122d..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/brackets/brackets-highlighter.zsh +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - - -# Define default styles. -: ${ZSH_HIGHLIGHT_STYLES[bracket-error]:=fg=red,bold} -: ${ZSH_HIGHLIGHT_STYLES[bracket-level-1]:=fg=blue,bold} -: ${ZSH_HIGHLIGHT_STYLES[bracket-level-2]:=fg=green,bold} -: ${ZSH_HIGHLIGHT_STYLES[bracket-level-3]:=fg=magenta,bold} -: ${ZSH_HIGHLIGHT_STYLES[bracket-level-4]:=fg=yellow,bold} -: ${ZSH_HIGHLIGHT_STYLES[bracket-level-5]:=fg=cyan,bold} -: ${ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]:=standout} - -# Whether the brackets highlighter should be called or not. -_zsh_highlight_brackets_highlighter_predicate() -{ - _zsh_highlight_cursor_moved || _zsh_highlight_buffer_modified -} - -# Brackets highlighting function. -_zsh_highlight_brackets_highlighter() -{ - local level=0 pos - local -A levelpos lastoflevel matching typepos - - # Find all brackets and remember which one is matching - for (( pos = 0; $pos < ${#BUFFER}; pos++ )) ; do - local char=$BUFFER[pos+1] - case $char in - ["([{"]) - levelpos[$pos]=$((++level)) - lastoflevel[$level]=$pos - _zsh_highlight_brackets_highlighter_brackettype $char - ;; - [")]}"]) - matching[$lastoflevel[$level]]=$pos - matching[$pos]=$lastoflevel[$level] - levelpos[$pos]=$((level--)) - _zsh_highlight_brackets_highlighter_brackettype $char - ;; - ['"'\']) - # Skip everything inside quotes - local quotetype=$char - while (( $pos < ${#BUFFER} )) ; do - (( pos++ )) - [[ $BUFFER[$pos+1] == $quotetype ]] && break - done - ;; - esac - done - - # Now highlight all found brackets - for pos in ${(k)levelpos}; do - if [[ -n $matching[$pos] ]] && [[ $typepos[$pos] == $typepos[$matching[$pos]] ]]; then - local bracket_color_size=${#ZSH_HIGHLIGHT_STYLES[(I)bracket-level-*]} - local bracket_color_level=bracket-level-$(( (levelpos[$pos] - 1) % bracket_color_size + 1 )) - local style=$ZSH_HIGHLIGHT_STYLES[$bracket_color_level] - region_highlight+=("$pos $((pos + 1)) $style") - else - local style=$ZSH_HIGHLIGHT_STYLES[bracket-error] - region_highlight+=("$pos $((pos + 1)) $style") - fi - done - - # If cursor is on a bracket, then highlight corresponding bracket, if any - pos=$CURSOR - if [[ -n $levelpos[$pos] ]] && [[ -n $matching[$pos] ]]; then - local otherpos=$matching[$pos] - local style=$ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket] - region_highlight+=("$otherpos $((otherpos + 1)) $style") - fi -} - -# Helper function to differentiate type -_zsh_highlight_brackets_highlighter_brackettype() -{ - case $1 in - ["()"]) typepos[$pos]=round;; - ["[]"]) typepos[$pos]=bracket;; - ["{}"]) typepos[$pos]=curly;; - *) ;; - esac -} diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/mismatch-patentheses.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/mismatch-patentheses.zsh deleted file mode 100644 index ad72f758..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/mismatch-patentheses.zsh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - -BUFFER='echo ({x}]' - -expected_region_highlight=( - "5 5 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # ( - "6 6 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # { - "8 8 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # } - "9 9 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # ) -) diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/nested-parentheses.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/nested-parentheses.zsh deleted file mode 100644 index 68683e59..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/nested-parentheses.zsh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - -BUFFER='echo $(echo ${(z)array})' - -expected_region_highlight=( - "6 6 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # ( - "13 13 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # { - "14 14 $ZSH_HIGHLIGHT_STYLES[bracket-level-3]" # ( - "16 16 $ZSH_HIGHLIGHT_STYLES[bracket-level-3]" # ) - "22 22 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # } - "23 23 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # ) -) diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/quoted-patentheses.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/quoted-patentheses.zsh deleted file mode 100644 index 25890109..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/quoted-patentheses.zsh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - -BUFFER='echo "foo ( bar"' - -expected_region_highlight=( -"1 15 $ZSH_HIGHLIGHT_STYLES[none]" # We expect the brackets highlighter to do nothing -) diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/simple-parentheses.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/simple-parentheses.zsh deleted file mode 100644 index cd9a7599..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/simple-parentheses.zsh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - -BUFFER='echo ({x})' - -expected_region_highlight=( - "5 5 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # ( - "6 6 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # { - "8 8 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # } - "9 9 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # ) -) diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/unclosed-patentheses.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/unclosed-patentheses.zsh deleted file mode 100644 index 879c6186..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/unclosed-patentheses.zsh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - -BUFFER='echo ({x}' - -expected_region_highlight=( - "5 5 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # ( - "6 6 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # { - "8 8 $ZSH_HIGHLIGHT_STYLES[bracket-level-2]" # } -) diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/unclosed-patentheses2.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/unclosed-patentheses2.zsh deleted file mode 100644 index c6534eff..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/brackets/test-data/unclosed-patentheses2.zsh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - -BUFFER='echo {x})' - -expected_region_highlight=( - "5 5 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # { - "7 7 $ZSH_HIGHLIGHT_STYLES[bracket-level-1]" # } - "8 8 $ZSH_HIGHLIGHT_STYLES[bracket-error]" # ) -) diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/cursor/README.md b/shells/zsh/lib/syntax-highlighting/highlighters/cursor/README.md deleted file mode 100644 index d28ac190..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/cursor/README.md +++ /dev/null @@ -1,24 +0,0 @@ -zsh-syntax-highlighting / highlighters / cursor -================================================= - -This is the ***cursor*** highlighter, that highlights the cursor. - - -How to activate it ------------------- -To activate it, add it to `ZSH_HIGHLIGHT_HIGHLIGHTERS`: - - ZSH_HIGHLIGHT_HIGHLIGHTERS=( [...] cursor) - - -How to tweak it ---------------- -This highlighter defines the following styles: - -* `cursor` - the style for the current cursor position - -To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, for example in `~/.zshrc`: - - ZSH_HIGHLIGHT_STYLES[cursor]='bg=blue' - -The syntax for declaring styles is [documented here](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135). diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/cursor/cursor-highlighter.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/cursor/cursor-highlighter.zsh deleted file mode 100644 index b5868a46..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/cursor/cursor-highlighter.zsh +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - - -# Define default styles. -: ${ZSH_HIGHLIGHT_STYLES[cursor]:=standout} - -# Whether the cursor highlighter should be called or not. -_zsh_highlight_cursor_highlighter_predicate() -{ - _zsh_highlight_cursor_moved -} - -# Cursor highlighting function. -_zsh_highlight_cursor_highlighter() -{ - region_highlight+=("$CURSOR $(( $CURSOR + 1 )) $ZSH_HIGHLIGHT_STYLES[cursor]") -} diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/main/README.md b/shells/zsh/lib/syntax-highlighting/highlighters/main/README.md deleted file mode 100644 index 6900bfbf..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/main/README.md +++ /dev/null @@ -1,58 +0,0 @@ -zsh-syntax-highlighting / highlighters / main -============================================= - -This is the ***main*** highlighter, that highlights: - -* Commands -* Options -* Arguments -* Paths -* Strings - -How to activate it ------------------- -To activate it, add it to `ZSH_HIGHLIGHT_HIGHLIGHTERS`: - - ZSH_HIGHLIGHT_HIGHLIGHTERS=( [...] main) - -This highlighter is active by default. - - -How to tweak it ---------------- -This highlighter defines the following styles: - -* `unknown-token` - unknown tokens / errors -* `reserved-word` - shell reserved words -* `alias` - aliases -* `builtin` - shell builtin commands -* `function` - functions -* `command` - commands -* `precommand` - precommands (i.e. exec, builtin, ...) -* `commandseparator` - command separation tokens -* `hashed-command` - hashed commands -* `path` - paths -* `globbing` - globbing expressions -* `history-expansion` - history expansion expressions -* `single-hyphen-option` - single hyphen options -* `double-hyphen-option` - double hyphen options -* `back-quoted-argument` - backquoted expressions -* `single-quoted-argument` - single quoted arguments -* `double-quoted-argument` - double quoted arguments -* `dollar-double-quoted-argument` - dollar double quoted arguments -* `back-double-quoted-argument` - back double quoted arguments -* `assign` - variable assignments -* `default` - parts of the buffer that do not match anything - -To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, for example in `~/.zshrc`: - - # To differentiate aliases from other command types - ZSH_HIGHLIGHT_STYLES[alias]='fg=magenta,bold' - - # To have paths colored instead of underlined - ZSH_HIGHLIGHT_STYLES[path]='fg=cyan' - - # To disable highlighting of globbing expressions - ZSH_HIGHLIGHT_STYLES[globbing]='none' - -The syntax for declaring styles is [documented here](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135). diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/main/main-highlighter.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/main/main-highlighter.zsh deleted file mode 100755 index 7aede14d..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/main/main-highlighter.zsh +++ /dev/null @@ -1,184 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - - -# Define default styles. -: ${ZSH_HIGHLIGHT_STYLES[default]:=none} -: ${ZSH_HIGHLIGHT_STYLES[unknown-token]:=fg=red,bold} -: ${ZSH_HIGHLIGHT_STYLES[reserved-word]:=fg=yellow} -: ${ZSH_HIGHLIGHT_STYLES[alias]:=fg=green} -: ${ZSH_HIGHLIGHT_STYLES[builtin]:=fg=green} -: ${ZSH_HIGHLIGHT_STYLES[function]:=fg=green} -: ${ZSH_HIGHLIGHT_STYLES[command]:=fg=green} -: ${ZSH_HIGHLIGHT_STYLES[precommand]:=fg=green,underline} -: ${ZSH_HIGHLIGHT_STYLES[commandseparator]:=none} -: ${ZSH_HIGHLIGHT_STYLES[hashed-command]:=fg=green} -: ${ZSH_HIGHLIGHT_STYLES[path]:=underline} -: ${ZSH_HIGHLIGHT_STYLES[globbing]:=fg=blue} -: ${ZSH_HIGHLIGHT_STYLES[history-expansion]:=fg=blue} -: ${ZSH_HIGHLIGHT_STYLES[single-hyphen-option]:=none} -: ${ZSH_HIGHLIGHT_STYLES[double-hyphen-option]:=none} -: ${ZSH_HIGHLIGHT_STYLES[back-quoted-argument]:=none} -: ${ZSH_HIGHLIGHT_STYLES[single-quoted-argument]:=fg=yellow} -: ${ZSH_HIGHLIGHT_STYLES[double-quoted-argument]:=fg=yellow} -: ${ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]:=fg=cyan} -: ${ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]:=fg=cyan} -: ${ZSH_HIGHLIGHT_STYLES[assign]:=none} - -# Whether the highlighter should be called or not. -_zsh_highlight_main_highlighter_predicate() -{ - _zsh_highlight_buffer_modified -} - -# Main syntax highlighting function. -_zsh_highlight_main_highlighter() -{ - setopt localoptions extendedglob bareglobqual - local start_pos=0 end_pos highlight_glob=true new_expression=true arg style - typeset -a ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR - typeset -a ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS - typeset -a ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS - region_highlight=() - - ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=( - '|' '||' ';' '&' '&&' - ) - ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS=( - 'builtin' 'command' 'exec' 'nocorrect' 'noglob' - ) - # Tokens that are always immediately followed by a command. - ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS=( - $ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR $ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS - ) - - for arg in ${(z)BUFFER}; do - local substr_color=0 - [[ $start_pos -eq 0 && $arg = 'noglob' ]] && highlight_glob=false - ((start_pos+=${#BUFFER[$start_pos+1,-1]}-${#${BUFFER[$start_pos+1,-1]##[[:space:]]#}})) - ((end_pos=$start_pos+${#arg})) - if $new_expression; then - new_expression=false - if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]]; then - style=$ZSH_HIGHLIGHT_STYLES[precommand] - else - res=$(LC_ALL=C builtin type -w $arg 2>/dev/null) - case $res in - *': reserved') style=$ZSH_HIGHLIGHT_STYLES[reserved-word];; - *': alias') style=$ZSH_HIGHLIGHT_STYLES[alias] - local aliased_command="${"$(alias $arg)"#*=}" - [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS:#"$aliased_command"} && -z ${(M)ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS:#"$arg"} ]] && ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS+=($arg) - ;; - *': builtin') style=$ZSH_HIGHLIGHT_STYLES[builtin];; - *': function') style=$ZSH_HIGHLIGHT_STYLES[function];; - *': command') style=$ZSH_HIGHLIGHT_STYLES[command];; - *': hashed') style=$ZSH_HIGHLIGHT_STYLES[hashed-command];; - *) if _zsh_highlight_main_highlighter_check_assign; then - style=$ZSH_HIGHLIGHT_STYLES[assign] - new_expression=true - elif _zsh_highlight_main_highlighter_check_path; then - style=$ZSH_HIGHLIGHT_STYLES[path] - elif [[ $arg[0,1] = $histchars[0,1] ]]; then - style=$ZSH_HIGHLIGHT_STYLES[history-expansion] - else - style=$ZSH_HIGHLIGHT_STYLES[unknown-token] - fi - ;; - esac - fi - else - case $arg in - '--'*) style=$ZSH_HIGHLIGHT_STYLES[double-hyphen-option];; - '-'*) style=$ZSH_HIGHLIGHT_STYLES[single-hyphen-option];; - "'"*"'") style=$ZSH_HIGHLIGHT_STYLES[single-quoted-argument];; - '"'*'"') style=$ZSH_HIGHLIGHT_STYLES[double-quoted-argument] - region_highlight+=("$start_pos $end_pos $style") - _zsh_highlight_main_highlighter_highlight_string - substr_color=1 - ;; - '`'*'`') style=$ZSH_HIGHLIGHT_STYLES[back-quoted-argument];; - *"*"*) $highlight_glob && style=$ZSH_HIGHLIGHT_STYLES[globbing] || style=$ZSH_HIGHLIGHT_STYLES[default];; - *) if _zsh_highlight_main_highlighter_check_path; then - style=$ZSH_HIGHLIGHT_STYLES[path] - elif [[ $arg[0,1] = $histchars[0,1] ]]; then - style=$ZSH_HIGHLIGHT_STYLES[history-expansion] - elif [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then - style=$ZSH_HIGHLIGHT_STYLES[commandseparator] - else - style=$ZSH_HIGHLIGHT_STYLES[default] - fi - ;; - esac - fi - [[ $substr_color = 0 ]] && region_highlight+=("$start_pos $end_pos $style") - [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_FOLLOWED_BY_COMMANDS:#"$arg"} ]] && new_expression=true - start_pos=$end_pos - done -} - -# Check if the argument is variable assignment -_zsh_highlight_main_highlighter_check_assign() -{ - setopt localoptions extended_glob - [[ ${(Q)arg} == [[:alpha:]_]([[:alnum:]_])#=* ]] -} - -# Check if the argument is a path. -_zsh_highlight_main_highlighter_check_path() -{ - setopt localoptions nonomatch - local expanded_path; : ${expanded_path:=${(Q)~arg}} - [[ -z $expanded_path ]] && return 1 - [[ -e $expanded_path ]] && return 0 - [[ ! -e ${expanded_path:h} ]] && return 1 - [[ ${BUFFER[1]} != "-" && ${#BUFFER} == $end_pos && -n $(print ${expanded_path}*(N)) ]] && return 0 - return 1 -} - -# Highlight special chars inside double-quoted strings -_zsh_highlight_main_highlighter_highlight_string() -{ - setopt localoptions noksharrays - local i j k style - # Starting quote is at 1, so start parsing at offset 2 in the string. - for (( i = 2 ; i < end_pos - start_pos ; i += 1 )) ; do - (( j = i + start_pos - 1 )) - (( k = j + 1 )) - case "$arg[$i]" in - '$') style=$ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument];; - "\\") style=$ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument] - (( k += 1 )) # Color following char too. - (( i += 1 )) # Skip parsing the escaped char. - ;; - *) continue;; - esac - region_highlight+=("$j $k $style") - done -} diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/assign.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/assign.zsh deleted file mode 100644 index 0401bf4d..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/assign.zsh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - -BUFFER='A=1' - -expected_region_highlight=( - "1 3 $ZSH_HIGHLIGHT_STYLES[assign]" # A=1 -) diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/multiple-redirections.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/multiple-redirections.zsh deleted file mode 100644 index ac0606c9..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/multiple-redirections.zsh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - -BUFFER='ps aux | grep java | sort | uniq | tail | head' - -expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ps - "4 6 $ZSH_HIGHLIGHT_STYLES[default]" # aux - "8 8 $ZSH_HIGHLIGHT_STYLES[default]" # | - "10 13 $ZSH_HIGHLIGHT_STYLES[command]" # grep - "15 18 $ZSH_HIGHLIGHT_STYLES[default]" # java - "20 20 $ZSH_HIGHLIGHT_STYLES[default]" # | - "22 25 $ZSH_HIGHLIGHT_STYLES[command]" # sort - "27 27 $ZSH_HIGHLIGHT_STYLES[default]" # | - "29 32 $ZSH_HIGHLIGHT_STYLES[command]" # uniq - "34 34 $ZSH_HIGHLIGHT_STYLES[default]" # | - "36 39 $ZSH_HIGHLIGHT_STYLES[command]" # tail - "41 41 $ZSH_HIGHLIGHT_STYLES[default]" # | - "43 46 $ZSH_HIGHLIGHT_STYLES[command]" # head -) diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/path-space- .zsh b/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/path-space- .zsh deleted file mode 100644 index 91c38331..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/path-space- .zsh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - -BUFFER='ls highlighters/main/test-data/path-space-\ .zsh' - -expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls - "4 48 $ZSH_HIGHLIGHT_STYLES[path]" # highlighters/main/test-data/path-space-\ .zsh -) diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/path-tilde-home.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/path-tilde-home.zsh deleted file mode 100644 index 14f8e183..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/path-tilde-home.zsh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - -BUFFER='ls ~' - -expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls - "4 4 $ZSH_HIGHLIGHT_STYLES[path]" # ~ -) diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/path-tilde-named.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/path-tilde-named.zsh deleted file mode 100644 index 38b2bb57..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/path-tilde-named.zsh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - -hash -d D=highlighters/main/test-data - -BUFFER='ls ~D/path-tilde-named.zsh' - -expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls - "4 23 $ZSH_HIGHLIGHT_STYLES[path]" # ~D/path-tilde-named.zsh -) diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/path.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/path.zsh deleted file mode 100644 index 52e3af14..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/path.zsh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - -BUFFER='ls highlighters/main/test-data/path.zsh' - -expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls - "4 39 $ZSH_HIGHLIGHT_STYLES[path]" # highlighters/main/test-data/path.zsh -) diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/simple-command.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/simple-command.zsh deleted file mode 100644 index 4227c80e..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/simple-command.zsh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - -BUFFER='ls' - -expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ls -) diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/simple-redirection.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/simple-redirection.zsh deleted file mode 100644 index 055b1cb8..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/simple-redirection.zsh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - -BUFFER='ps aux | grep java' - -expected_region_highlight=( - "1 2 $ZSH_HIGHLIGHT_STYLES[command]" # ps - "4 6 $ZSH_HIGHLIGHT_STYLES[default]" # aux - "8 8 $ZSH_HIGHLIGHT_STYLES[default]" # | - "9 12 $ZSH_HIGHLIGHT_STYLES[command]" # grep - "14 17 $ZSH_HIGHLIGHT_STYLES[default]" # java -) diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/unknown-command.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/unknown-command.zsh deleted file mode 100644 index 74854d42..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/main/test-data/unknown-command.zsh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - -BUFFER='azertyuiop' - -expected_region_highlight=( - "1 10 $ZSH_HIGHLIGHT_STYLES[unknown-token]" # azertyuiop -) diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/pattern/README.md b/shells/zsh/lib/syntax-highlighting/highlighters/pattern/README.md deleted file mode 100644 index 82a7c65f..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/pattern/README.md +++ /dev/null @@ -1,21 +0,0 @@ -zsh-syntax-highlighting / highlighters / pattern -================================================ - -This is the ***pattern*** highlighter, that highlights user defined patterns. - - -How to activate it ------------------- -To activate it, add it to `ZSH_HIGHLIGHT_HIGHLIGHTERS`: - - ZSH_HIGHLIGHT_HIGHLIGHTERS=( [...] pattern) - - -How to tweak it ---------------- -To use this highlighter, associate patterns with styles in the `ZSH_HIGHLIGHT_PATTERNS` array, for example in `~/.zshrc`: - - # To have commands starting with `rm -rf` in red: - ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red') - -The syntax for declaring styles is [documented here](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135). diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/pattern/pattern-highlighter.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/pattern/pattern-highlighter.zsh deleted file mode 100644 index 93041a38..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/pattern/pattern-highlighter.zsh +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - - -# List of keyword and color pairs. -typeset -gA ZSH_HIGHLIGHT_PATTERNS - -# Whether the pattern highlighter should be called or not. -_zsh_highlight_pattern_highlighter_predicate() -{ - _zsh_highlight_buffer_modified -} - -# Pattern syntax highlighting function. -_zsh_highlight_pattern_highlighter() -{ - setopt localoptions extendedglob - for pattern in ${(k)ZSH_HIGHLIGHT_PATTERNS}; do - _zsh_highlight_pattern_highlighter_loop "$BUFFER" "$pattern" - done -} - -_zsh_highlight_pattern_highlighter_loop() -{ - # This does *not* do its job syntactically, sorry. - local buf="$1" pat="$2" - local -a match mbegin mend - if [[ "$buf" == (#b)(*)(${~pat})* ]]; then - region_highlight+=("$((mbegin[2] - 1)) $mend[2] $ZSH_HIGHLIGHT_PATTERNS[$pat]") - "$0" "$match[1]" "$pat"; return $? - fi -} diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/root/README.md b/shells/zsh/lib/syntax-highlighting/highlighters/root/README.md deleted file mode 100644 index 53c871bf..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/root/README.md +++ /dev/null @@ -1,24 +0,0 @@ -zsh-syntax-highlighting / highlighters / root -================================================= - -This is the ***root*** highlighter, that highlights the whole line if the current user is root. - - -How to activate it ------------------- -To activate it, add it to `ZSH_HIGHLIGHT_HIGHLIGHTERS`: - - ZSH_HIGHLIGHT_HIGHLIGHTERS=( [...] root) - - -How to tweak it ---------------- -This highlighter defines the following styles: - -* `root` - the style for the whole line if the current user is root. - -To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`, for example in `~/.zshrc`: - - ZSH_HIGHLIGHT_STYLES[root]='bg=red' - -The syntax for declaring styles is [documented here](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#SEC135). diff --git a/shells/zsh/lib/syntax-highlighting/highlighters/root/root-highlighter.zsh b/shells/zsh/lib/syntax-highlighting/highlighters/root/root-highlighter.zsh deleted file mode 100644 index 4ef87621..00000000 --- a/shells/zsh/lib/syntax-highlighting/highlighters/root/root-highlighter.zsh +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - - -# Define default styles. -: ${ZSH_HIGHLIGHT_STYLES[root]:=standout} - -# Whether the root highlighter should be called or not. -_zsh_highlight_root_highlighter_predicate() -{ - _zsh_highlight_buffer_modified -} - -# root highlighting function. -_zsh_highlight_root_highlighter() -{ - [[ $(command id -u) -eq 0 ]] && region_highlight+=("0 $#BUFFER $ZSH_HIGHLIGHT_STYLES[root]") -} diff --git a/shells/zsh/lib/syntax-highlighting/tests/README.md b/shells/zsh/lib/syntax-highlighting/tests/README.md deleted file mode 100644 index f8cac488..00000000 --- a/shells/zsh/lib/syntax-highlighting/tests/README.md +++ /dev/null @@ -1,20 +0,0 @@ -zsh-syntax-highlighting / tests -=============================== - -Utility scripts for testing zsh-syntax-highlighting highlighters. - -The tests expect the highlighter directory to contain a `test-data` directory with test data files. See the [main highlighter](../highlighters/main/test-data) for examples. - - -highlighting test ------------------ -[`test-highlighting.zsh`](tests/test-highlighting.zsh) tests the correctness of the highlighting. Usage: - - zsh test-highlighting.zsh - - -performance test ----------------- -[`test-perfs.zsh`](tests/test-perfs.zsh) measures the time spent doing the highlighting. Usage: - - zsh test-perfs.zsh diff --git a/shells/zsh/lib/syntax-highlighting/tests/test-highlighting.zsh b/shells/zsh/lib/syntax-highlighting/tests/test-highlighting.zsh deleted file mode 100755 index 2e72b2b1..00000000 --- a/shells/zsh/lib/syntax-highlighting/tests/test-highlighting.zsh +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - - -# Check an highlighter was given as argument. -[[ -n "$1" ]] || { - echo "You must provide the name of a valid highlighter as argument." >&2 - exit 1 -} - -# Check the highlighter is valid. -[[ -f ${0:h:h}/highlighters/$1/$1-highlighter.zsh ]] || { - echo "Could not find highlighter '$1'." >&2 - exit 1 -} - -# Check the highlighter has test data. -[[ -d ${0:h:h}/highlighters/$1/test-data ]] || { - echo "Highlighter '$1' has no test data." >&2 - exit 1 -} - -local -a errors highlight_zone -local -A observed_result - -# Load the main script. -. ${0:h:h}/zsh-syntax-highlighting.zsh - -# Activate the highlighter. -ZSH_HIGHLIGHT_HIGHLIGHTERS=($1) - -# Process each test data file in test data directory. -for data_file in ${0:h:h}/highlighters/$1/test-data/*; do - - # Load the data and prepare checking it. - BUFFER= ; expected_region_highlight=(); errors=() - echo -n "* ${data_file:t:r}: " - . $data_file - - # Check the data declares $BUFFER. - if [[ ${#BUFFER} -eq 0 ]]; then - errors+=("'BUFFER' is not declared or blank.") - else - - # Check the data declares $expected_region_highlight. - if [[ ${#expected_region_highlight} -eq 0 ]]; then - errors+=("'expected_region_highlight' is not declared or empty.") - else - - # Process the data. - region_highlight=() - _zsh_highlight - - # Overlapping regions can be declared in region_highlight, so we first build an array of the - # observed highlighting. - observed_result=() - for i in {1..${#region_highlight}}; do - highlight_zone=${(z)region_highlight[$i]} - for j in {$highlight_zone[1]..$highlight_zone[2]}; do - observed_result[$j]=$highlight_zone[3] - done - done - - # Then we compare the observed result with the expected one. - for i in {1..${#expected_region_highlight}}; do - highlight_zone=${(z)expected_region_highlight[$i]} - for j in {$highlight_zone[1]..$highlight_zone[2]}; do - if [[ "$observed_result[$j]" != "$highlight_zone[3]" ]]; then - errors+=("'$BUFFER[$highlight_zone[1],$highlight_zone[2]]' [$highlight_zone[1],$highlight_zone[2]]: expected '$highlight_zone[3]', observed '$observed_result[$j]'.") - break - fi - done - done - - fi - fi - - # Format result/errors. - if [[ ${#errors} -eq 0 ]]; then - echo "OK" - else - echo "KO" - for error in $errors; do - echo " - $error" - done - fi - -done diff --git a/shells/zsh/lib/syntax-highlighting/tests/test-perfs.zsh b/shells/zsh/lib/syntax-highlighting/tests/test-perfs.zsh deleted file mode 100755 index 0d4adc3e..00000000 --- a/shells/zsh/lib/syntax-highlighting/tests/test-perfs.zsh +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - - -# Check an highlighter was given as argument. -[[ -n "$1" ]] || { - echo "You must provide the name of a valid highlighter as argument." >&2 - exit 1 -} - -# Check the highlighter is valid. -[[ -f ${0:h:h}/highlighters/$1/$1-highlighter.zsh ]] || { - echo "Could not find highlighter '$1'." >&2 - exit 1 -} - -# Check the highlighter has test data. -[[ -d ${0:h:h}/highlighters/$1/test-data ]] || { - echo "Highlighter '$1' has no test data." >&2 - exit 1 -} - -# Load the main script. -. ${0:h:h}/zsh-syntax-highlighting.zsh - -# Activate the highlighter. -ZSH_HIGHLIGHT_HIGHLIGHTERS=($1) - -# Process each test data file in test data directory. -for data_file in ${0:h:h}/highlighters/$1/test-data/*; do - - # Load the data and prepare checking it. - BUFFER= - echo -n "* ${data_file:t:r}: " - . $data_file - - # Check the data declares $BUFFER. - if [[ ${#BUFFER} -eq 0 ]]; then - echo "KO\n - 'BUFFER' is not declared or blank." - else - - # Measure the time taken by _zsh_highlight. - TIMEFMT="%*Es" - time ( BUFFER="$BUFFER" && _zsh_highlight) - - fi - -done diff --git a/shells/zsh/lib/syntax-highlighting/zsh-syntax-highlighting.plugin.zsh b/shells/zsh/lib/syntax-highlighting/zsh-syntax-highlighting.plugin.zsh deleted file mode 120000 index cc95cd49..00000000 --- a/shells/zsh/lib/syntax-highlighting/zsh-syntax-highlighting.plugin.zsh +++ /dev/null @@ -1 +0,0 @@ -zsh-syntax-highlighting.zsh \ No newline at end of file diff --git a/shells/zsh/lib/syntax-highlighting/zsh-syntax-highlighting.zsh b/shells/zsh/lib/syntax-highlighting/zsh-syntax-highlighting.zsh deleted file mode 100644 index 686daa43..00000000 --- a/shells/zsh/lib/syntax-highlighting/zsh-syntax-highlighting.zsh +++ /dev/null @@ -1,218 +0,0 @@ -#!/usr/bin/env zsh -# ------------------------------------------------------------------------------------------------- -# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without modification, are permitted -# provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this list of conditions -# and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, this list of -# conditions and the following disclaimer in the documentation and/or other materials provided -# with the distribution. -# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors -# may be used to endorse or promote products derived from this software without specific prior -# written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ------------------------------------------------------------------------------------------------- -# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- -# vim: ft=zsh sw=2 ts=2 et -# ------------------------------------------------------------------------------------------------- - - -# ------------------------------------------------------------------------------------------------- -# Core highlighting update system -# ------------------------------------------------------------------------------------------------- - -# Array declaring active highlighters names. -typeset -ga ZSH_HIGHLIGHT_HIGHLIGHTERS - -# Update ZLE buffer syntax highlighting. -# -# Invokes each highlighter that needs updating. -# This function is supposed to be called whenever the ZLE state changes. -_zsh_highlight() -{ - setopt localoptions nowarncreateglobal - - # Store the previous command return code to restore it whatever happens. - local ret=$? - - # Do not highlight if there are more than 300 chars in the buffer. It's most - # likely a pasted command or a huge list of files in that case.. - [[ -n ${ZSH_HIGHLIGHT_MAXLENGTH:-} ]] && [[ $#BUFFER -gt $ZSH_HIGHLIGHT_MAXLENGTH ]] && return $ret - - # Do not highlight if there are pending inputs (copy/paste). - [[ $PENDING -gt 0 ]] && return $ret - - { - local -a selected_highlighters - local cache_place - - # Select which highlighters in ZSH_HIGHLIGHT_HIGHLIGHTERS need to be invoked. - local highlighter; for highlighter in $ZSH_HIGHLIGHT_HIGHLIGHTERS; do - - # If highlighter needs to be invoked - if "_zsh_highlight_${highlighter}_highlighter_predicate"; then - - # Mark the highlighter as selected for update. - selected_highlighters+=($highlighter) - - # Remove what was stored in its cache from region_highlight. - cache_place="_zsh_highlight_${highlighter}_highlighter_cache" - typeset -ga ${cache_place} - [[ ${#${(P)cache_place}} -gt 0 ]] && [[ ! -z ${region_highlight-} ]] && region_highlight=(${region_highlight:#(${(P~j.|.)cache_place})}) - - fi - done - - # Invoke each selected highlighter and store the result in its cache. - local -a region_highlight_copy - for highlighter in $selected_highlighters; do - cache_place="_zsh_highlight_${highlighter}_highlighter_cache" - region_highlight_copy=($region_highlight) - { - "_zsh_highlight_${highlighter}_highlighter" - } always { - [[ ! -z ${region_highlight-} ]] && : ${(PA)cache_place::=${region_highlight:#(${(~j.|.)region_highlight_copy})}} - } - done - - } always { - _ZSH_HIGHLIGHT_PRIOR_BUFFER=$BUFFER - _ZSH_HIGHLIGHT_PRIOR_CURSOR=$CURSOR - return $ret - } -} - - -# ------------------------------------------------------------------------------------------------- -# API/utility functions for highlighters -# ------------------------------------------------------------------------------------------------- - -# Array used by highlighters to declare user overridable styles. -typeset -gA ZSH_HIGHLIGHT_STYLES - -# Whether the command line buffer has been modified or not. -# -# Returns 0 if the buffer has changed since _zsh_highlight was last called. -_zsh_highlight_buffer_modified() -{ - [[ ${_ZSH_HIGHLIGHT_PRIOR_BUFFER:-} != $BUFFER ]] -} - -# Whether the cursor has moved or not. -# -# Returns 0 if the cursor has moved since _zsh_highlight was last called. -_zsh_highlight_cursor_moved() -{ - [[ -n $CURSOR ]] && [[ -n ${_ZSH_HIGHLIGHT_PRIOR_CURSOR-} ]] && (($_ZSH_HIGHLIGHT_PRIOR_CURSOR != $CURSOR)) -} - - -# ------------------------------------------------------------------------------------------------- -# Setup functions -# ------------------------------------------------------------------------------------------------- - -# Rebind all ZLE widgets to make them invoke _zsh_highlights. -_zsh_highlight_bind_widgets() -{ - # Load ZSH module zsh/zleparameter, needed to override user defined widgets. - zmodload zsh/zleparameter 2>/dev/null || { - echo 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' >&2 - return 1 - } - - # Override ZLE widgets to make them invoke _zsh_highlight. - local cur_widget - for cur_widget in ${${(f)"$(builtin zle -la)"}:#(.*|_*|orig-*|run-help|which-command|beep)}; do - case $widgets[$cur_widget] in - - # Already rebound event: do nothing. - user:$cur_widget|user:_zsh_highlight_widget_*);; - - # User defined widget: override and rebind old one with prefix "orig-". - user:*) eval "zle -N orig-$cur_widget ${widgets[$cur_widget]#*:}; \ - _zsh_highlight_widget_$cur_widget() { builtin zle orig-$cur_widget \"\$@\" && _zsh_highlight }; \ - zle -N $cur_widget _zsh_highlight_widget_$cur_widget";; - - # Completion widget: override and rebind old one with prefix "orig-". - completion:*) eval "zle -C orig-$cur_widget ${${widgets[$cur_widget]#*:}/:/ }; \ - _zsh_highlight_widget_$cur_widget() { builtin zle orig-$cur_widget \"\$@\" && _zsh_highlight }; \ - zle -N $cur_widget _zsh_highlight_widget_$cur_widget";; - - # Builtin widget: override and make it call the builtin ".widget". - builtin) eval "_zsh_highlight_widget_$cur_widget() { builtin zle .$cur_widget \"\$@\" && _zsh_highlight }; \ - zle -N $cur_widget _zsh_highlight_widget_$cur_widget";; - - # Default: unhandled case. - *) echo "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;; - esac - done -} - -# Load highlighters from directory. -# -# Arguments: -# 1) Path to the highlighters directory. -_zsh_highlight_load_highlighters() -{ - # Check the directory exists. - [[ -d "$1" ]] || { - echo "zsh-syntax-highlighting: highlighters directory '$1' not found." >&2 - return 1 - } - - # Load highlighters from highlighters directory and check they define required functions. - local highlighter highlighter_dir - for highlighter_dir ($1/*/); do - highlighter="${highlighter_dir:t}" - [[ -f "$highlighter_dir/${highlighter}-highlighter.zsh" ]] && { - . "$highlighter_dir/${highlighter}-highlighter.zsh" - type "_zsh_highlight_${highlighter}_highlighter" &> /dev/null && - type "_zsh_highlight_${highlighter}_highlighter_predicate" &> /dev/null || { - echo "zsh-syntax-highlighting: '${highlighter}' highlighter should define both required functions '_zsh_highlight_${highlighter}_highlighter' and '_zsh_highlight_${highlighter}_highlighter_predicate' in '${highlighter_dir}/${highlighter}-highlighter.zsh'." >&2 - } - } - done -} - - -# ------------------------------------------------------------------------------------------------- -# Setup -# ------------------------------------------------------------------------------------------------- - -# Try binding widgets. -_zsh_highlight_bind_widgets || { - echo 'zsh-syntax-highlighting: failed binding ZLE widgets, exiting.' >&2 - return 1 -} - -# Resolve highlighters directory location. -_zsh_highlight_load_highlighters "${ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR:-${0:h}/highlighters}" || { - echo 'zsh-syntax-highlighting: failed loading highlighters, exiting.' >&2 - return 1 -} - -# Reset scratch variables when commandline is done. -_zsh_highlight_preexec_hook() -{ - _ZSH_HIGHLIGHT_PRIOR_BUFFER= - _ZSH_HIGHLIGHT_PRIOR_CURSOR= -} -autoload -U add-zsh-hook -add-zsh-hook preexec _zsh_highlight_preexec_hook 2>/dev/null || { - echo 'zsh-syntax-highlighting: failed loading add-zsh-hook.' >&2 - } - -# Initialize the array of active highlighters if needed. -[[ $#ZSH_HIGHLIGHT_HIGHLIGHTERS -eq 0 ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS=(main) || true diff --git a/shells/zsh/p10k-instant-prompt.zsh b/shells/zsh/p10k-instant-prompt.zsh new file mode 100644 index 00000000..a4db0498 --- /dev/null +++ b/shells/zsh/p10k-instant-prompt.zsh @@ -0,0 +1,6 @@ +# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. +# Initialization code that may require console input (password prompts, [y/n] +# confirmations, etc.) must go above this block; everything else may go below. +if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then + source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" +fi \ No newline at end of file diff --git a/shells/zsh/p10k.zsh b/shells/zsh/p10k.zsh new file mode 100644 index 00000000..5aabdaf0 --- /dev/null +++ b/shells/zsh/p10k.zsh @@ -0,0 +1,1532 @@ +# Generated by Powerlevel10k configuration wizard on 2020-05-25 at 13:46 AEST. +# Based on romkatv/powerlevel10k/config/p10k-lean.zsh, checksum 49145. +# Wizard options: nerdfont-complete + powerline, small icons, unicode, lean, 24h time, +# 2 lines, dotted, no frame, darkest-ornaments, sparse, many icons, fluent, +# transient_prompt, instant_prompt=verbose. +# Type `p10k configure` to generate another config. +# +# Config for Powerlevel10k with lean prompt style. Type `p10k configure` to generate +# your own config based on it. +# +# Tip: Looking for a nice color? Here's a one-liner to print colormap. +# +# for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done + +# Temporarily change options. +'builtin' 'local' '-a' 'p10k_config_opts' +[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' + +() { + emulate -L zsh -o extended_glob + + # Unset all configuration options. This allows you to apply configuration changes without + # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. + unset -m 'POWERLEVEL9K_*|DEFAULT_USER' + + # Zsh >= 5.1 is required. + autoload -Uz is-at-least && is-at-least 5.1 || return + + # The list of segments shown on the left. Fill it with the most important segments. + typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( + # =========================[ Line #1 ]========================= + # os_icon # os identifier + dir # current directory + vcs # git status + # =========================[ Line #2 ]========================= + newline # \n + prompt_char # prompt symbol + ) + + # The list of segments shown on the right. Fill it with less important segments. + # Right prompt on the last prompt line (where you are typing your commands) gets + # automatically hidden when the input line reaches it. Right prompt above the + # last prompt line gets hidden if it would overlap with left prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( + # =========================[ Line #1 ]========================= + status # exit code of the last command + command_execution_time # duration of the last command + background_jobs # presence of background jobs + direnv # direnv status (https://direnv.net/) + virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html) + anaconda # conda environment (https://conda.io/) + # pyenv # python environment (https://github.com/pyenv/pyenv) + # goenv # go environment (https://github.com/syndbg/goenv) + # nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv) + # nvm # node.js version from nvm (https://github.com/nvm-sh/nvm) + # nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) + # node_version # node.js version + go_version # go version (https://golang.org) + rust_version # rustc version (https://www.rust-lang.org) + asdf # asdf version manager (https://github.com/asdf-vm/asdf) + # dotnet_version # .NET version (https://dotnet.microsoft.com) + # php_version # php version (https://www.php.net/) + # laravel_version # laravel php framework version (https://laravel.com/) + # java_version # java version (https://www.java.com/) + # package # name@version from package.json (https://docs.npmjs.com/files/package.json) + #rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) + #rvm # ruby version from rvm (https://rvm.io) + #fvm # flutter version management (https://github.com/leoafarias/fvm) + #luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) + #jenv # java version from jenv (https://github.com/jenv/jenv) + #plenv # perl version from plenv (https://github.com/tokuhirom/plenv) + #phpenv # php version from phpenv (https://github.com/phpenv/phpenv) + #haskell_stack # haskell version from stack (https://haskellstack.org/) + kubecontext # current kubernetes context (https://kubernetes.io/) + terraform # terraform workspace (https://www.terraform.io) + aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) + aws_eb_env # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) + azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) + gcloud # google cloud cli account and project (https://cloud.google.com/) + google_app_cred # google application credentials (https://cloud.google.com/docs/authentication/production) + context # user@hostname + nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) + #ranger # ranger shell (https://github.com/ranger/ranger) + #nnn # nnn shell (https://github.com/jarun/nnn) + #vim_shell # vim shell indicator (:sh) + #midnight_commander # midnight commander shell (https://midnight-commander.org/) + #nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) + # vpn_ip # virtual private network indicator + # load # CPU load + # disk_usage # disk usage + # ram # free RAM + # swap # used swap + # todo # todo items (https://github.com/todotxt/todo.txt-cli) + # timewarrior # timewarrior tracking status (https://timewarrior.net/) + # taskwarrior # taskwarrior task count (https://taskwarrior.org/) + time # current time + # =========================[ Line #2 ]========================= + newline + # ip # ip address and bandwidth usage for a specified network interface + # public_ip # public IP address + # proxy # system-wide http/https/ftp proxy + # battery # internal battery + # wifi # wifi speed + # example # example user-defined segment (see prompt_example function below) + ) + + # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you. + typeset -g POWERLEVEL9K_MODE=nerdfont-complete + # When set to `moderate`, some icons will have an extra space after them. This is meant to avoid + # icon overlap when using non-monospace fonts. When set to `none`, spaces are not added. + typeset -g POWERLEVEL9K_ICON_PADDING=none + + # Basic style options that define the overall look of your prompt. You probably don't want to + # change them. + typeset -g POWERLEVEL9K_BACKGROUND= # transparent background + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space + typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol + + # When set to true, icons appear before content on both sides of the prompt. When set + # to false, icons go after content. If empty or not set, icons go before content in the left + # prompt and after content in the right prompt. + # + # You can also override it for a specific segment: + # + # POWERLEVEL9K_STATUS_ICON_BEFORE_CONTENT=false + # + # Or for a specific segment in specific state: + # + # POWERLEVEL9K_DIR_NOT_WRITABLE_ICON_BEFORE_CONTENT=false + typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT=true + + # Add an empty line before each prompt. + typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true + + # Connect left prompt lines with these symbols. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX= + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX= + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX= + # Connect right prompt lines with these symbols. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX= + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX= + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX= + + # The left end of left prompt. + typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= + # The right end of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL= + + # Ruler, a.k.a. the horizontal line before each prompt. If you set it to true, you'll + # probably want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE=false above and + # POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' below. + typeset -g POWERLEVEL9K_SHOW_RULER=false + typeset -g POWERLEVEL9K_RULER_CHAR='─' # reasonable alternative: '¡' + typeset -g POWERLEVEL9K_RULER_FOREGROUND=238 + + # Filler between left and right prompt on the first prompt line. You can set it to '¡' or '─' + # to make it easier to see the alignment between left and right prompt and to separate prompt + # from command output. It serves the same purpose as ruler (see above) without increasing + # the number of prompt lines. You'll probably want to set POWERLEVEL9K_SHOW_RULER=false + # if using this. You might also like POWERLEVEL9K_PROMPT_ADD_NEWLINE=false for more compact + # prompt. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR='¡' + if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then + # The color of the filler. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=238 + # Add a space between the end of left prompt and the filler. + typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=' ' + # Add a space between the filler and the start of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL=' ' + # Start filler from the edge of the screen if there are no left segments on the first line. + typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}' + # End filler on the edge of the screen if there are no right segments on the first line. + typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}' + fi + + #################################[ os_icon: os identifier ]################################## + # OS identifier color. + typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND= + # Make the icon bold. + typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='${P9K_CONTENT}' + + ################################[ prompt_char: prompt symbol ]################################ + # Green prompt symbol if the last command succeeded. + typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=76 + # Red prompt symbol if the last command failed. + typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=196 + # Default prompt symbol. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='❯' + # Prompt symbol in command vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❎' + # Prompt symbol in visual vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V' + # Prompt symbol in overwrite vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶' + typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true + # No line terminator if prompt_char is the last segment. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='' + # No line introducer if prompt_char is the first segment. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= + + ##################################[ dir: current directory ]################################## + # Default current directory color. + typeset -g POWERLEVEL9K_DIR_FOREGROUND=31 + # If directory is too long, shorten some of its segments to the shortest possible unique + # prefix. The shortened directory can be tab-completed to the original. + typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique + # Replace removed segment suffixes with this symbol. + typeset -g POWERLEVEL9K_SHORTEN_DELIMITER= + # Color of the shortened directory segments. + typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=103 + # Color of the anchor directory segments. Anchor segments are never shortened. The first + # segment is always an anchor. + typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=39 + # Display anchor directory segments in bold. + typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true + # Don't shorten directories that contain any of these files. They are anchors. + local anchor_files=( + .bzr + .citc + .git + .hg + .node-version + .python-version + .go-version + .ruby-version + .lua-version + .java-version + .perl-version + .php-version + .tool-versions + .shorten_folder_marker + .svn + .terraform + CVS + Gemfile.lock + Cargo.toml + composer.json + go.mod + package.json + stack.yaml + shard.yml + ) + typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})" + # If set to "first" ("last"), remove everything before the first (last) subdirectory that contains + # files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is + # /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first) + # or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers + # and other directories don't. + typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false + # Don't shorten this many last directory segments. They are anchors. + typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 + # Shorten directory if it's longer than this even if there is space for it. The value can + # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty, + # directory will be shortened only when prompt doesn't fit or when other parameters demand it + # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below). + # If set to `0`, directory will always be shortened to its minimum length. + typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this + # many columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least + # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50 + # If set to true, embed a hyperlink into the directory. Useful for quickly + # opening a directory in the file manager simply by clicking the link. + # Can also be handy when the directory is shortened, as it allows you to see + # the full directory that was used in previous commands. + typeset -g POWERLEVEL9K_DIR_HYPERLINK=false + + # Enable special styling for non-writable directories. See POWERLEVEL9K_LOCK_ICON and + # POWERLEVEL9K_DIR_CLASSES below. + typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v2 + + # The default icon shown next to non-writable directories when POWERLEVEL9K_DIR_SHOW_WRITABLE is + # set to v2. + # typeset -g POWERLEVEL9K_LOCK_ICON='⭐' + + # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different + # directories. It must be an array with 3 * N elements. Each triplet consists of: + # + # 1. A pattern against which the current directory ($PWD) is matched. Matching is done with + # extended_glob option enabled. + # 2. Directory class for the purpose of styling. + # 3. An empty string. + # + # Triplets are tried in order. The first triplet whose pattern matches $PWD wins. + # + # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v2 and the current directory is not writable, + # its class gets suffix _NOT_WRITABLE. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_DIR_CLASSES=( + # '~/work(|/*)' WORK '' + # '~(|/*)' HOME '' + # '*' DEFAULT '') + # + # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with class + # WORK or WORK_NOT_WRITABLE. + # + # Simply assigning classes to directories don't have any visible effects. It merely gives you an + # option to define custom colors and icons for different directory classes. + # + # # Styling for WORK. + # typeset -g POWERLEVEL9K_DIR_WORK_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=31 + # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=103 + # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=39 + # + # # Styling for WORK_NOT_WRITABLE. + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=31 + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=103 + # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=39 + # + # If a styling parameter isn't explicitly defined for some class, it falls back to the classless + # parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls + # back to POWERLEVEL9K_DIR_FOREGROUND. + # + # typeset -g POWERLEVEL9K_DIR_CLASSES=() + + # Custom prefix. + # typeset -g POWERLEVEL9K_DIR_PREFIX='%fin ' + + #####################################[ vcs: git status ]###################################### + # Branch icon. Set this parameter to '\uF126 ' for the popular Powerline branch icon. + typeset -g POWERLEVEL9K_VCS_BRANCH_ICON='\uF126 ' + + # Untracked files icon. It's really a question mark, your font isn't broken. + # Change the value of this parameter to show a different icon. + typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' + + # Formatter for Git status. + # + # Example output: master ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # + # You can edit the function to customize how Git status looks. + # + # VCS_STATUS_* parameters are set by gitstatus plugin. See reference: + # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. + function my_git_formatter() { + emulate -L zsh + + if [[ -n $P9K_CONTENT ]]; then + # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from + # gitstatus plugin). VCS_STATUS_* parameters are not available in this case. + typeset -g my_git_format=$P9K_CONTENT + return + fi + + if (( $1 )); then + # Styling for up-to-date Git status. + local meta='%f' # default foreground + local clean='%76F' # green foreground + local modified='%178F' # yellow foreground + local untracked='%39F' # blue foreground + local conflicted='%196F' # red foreground + else + # Styling for incomplete and stale Git status. + local meta='%244F' # grey foreground + local clean='%244F' # grey foreground + local modified='%244F' # grey foreground + local untracked='%244F' # grey foreground + local conflicted='%244F' # grey foreground + fi + + local res + local where # branch or tag + if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then + res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}" + where=${(V)VCS_STATUS_LOCAL_BRANCH} + elif [[ -n $VCS_STATUS_TAG ]]; then + res+="${meta}#" + where=${(V)VCS_STATUS_TAG} + fi + + # If local branch name or tag is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + # Tip: To always show local branch name in full without truncation, delete the next line. + (( $#where > 32 )) && where[13,-13]="…" + res+="${clean}${where//\%/%%}" # escape % + + # Display the current Git commit if there is no branch or tag. + # Tip: To always display the current Git commit, remove `[[ -z $where ]] &&` from the next line. + [[ -z $where ]] && res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" + + # Show tracking branch name if it differs from local branch. + if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then + res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape % + fi + + # ⇣42 if behind the remote. + (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" + # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. + (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " + (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" + # ⇠42 if behind the push remote. + (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" + (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " + # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42. + (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}" + # *42 if have stashes. + (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" + # 'merge' if the repo is in an unusual state. + [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" + # ~42 if have merge conflicts. + (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" + # +42 if have staged changes. + (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" + # !42 if have unstaged changes. + (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" + # ?42 if have untracked files. It's really a question mark, your font isn't broken. + # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. + # Remove the next line if you don't want to see untracked files at all. + (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" + # "─" if the number of unstaged files is unknown. This can happen due to + # POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (see below) being set to a non-negative number lower + # than the number of files in the Git index, or due to bash.showDirtyState being set to false + # in the repository config. The number of staged and untracked files may also be unknown + # in this case. + (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}─" + + typeset -g my_git_format=$res + } + functions -M my_git_formatter 2>/dev/null + + # Don't count the number of unstaged, untracked and conflicted files in Git repositories with + # more than this many files in the index. Negative value means infinity. + # + # If you are working in Git repositories with tens of millions of files and seeing performance + # sagging, try setting POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY to a number lower than the output + # of `git ls-files | wc -l`. Alternatively, add `bash.showDirtyState = false` to the repository's + # config: `git config bash.showDirtyState false`. + typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1 + + # Don't show Git status in prompt for repositories whose workdir matches this pattern. + # For example, if set to '~', the Git repository at $HOME/.git will be ignored. + # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'. + typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~' + + # Disable the default Git status formatting. + typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true + # Install our own Git status formatter. + typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}' + typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}' + # Enable counters for staged, unstaged, etc. + typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 + + # Icon color. + typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76 + typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR=244 + # Custom icon. + # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + typeset -g POWERLEVEL9K_VCS_PREFIX='%fon ' + + # Show status of repositories of these types. You can add svn and/or hg if you are + # using them. If you do, your prompt may become slow even when your current directory + # isn't in an svn or hg reposotiry. + typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) + + # These settings are used for respositories other than Git or when gitstatusd fails and + # Powerlevel10k has to fall back to using vcs_info. + typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 + typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76 + typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=178 + + ##########################[ status: exit code of the last command ]########################### + # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and + # style them independently from the regular OK and ERROR state. + typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true + + # Status on success. No content, just an icon. No need to show it if prompt_char is enabled as + # it will signify success by turning green. + typeset -g POWERLEVEL9K_STATUS_OK=false + typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=70 + typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION='✔' + + # Status when some part of a pipe command fails but the overall exit status is zero. It may look + # like this: 1|0. + typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true + typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=70 + typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION='✔' + + # Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as + # it will signify error by turning red. + typeset -g POWERLEVEL9K_STATUS_ERROR=false + typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=160 + typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='✘' + + # Status when the last command was terminated by a signal. + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=160 + # Use terse signal names: "INT" instead of "SIGINT(2)". + typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION='✘' + + # Status when some part of a pipe command fails and the overall exit status is also non-zero. + # It may look like this: 1|0. + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=160 + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='✘' + + ###################[ command_execution_time: duration of the last command ]################### + # Show duration of the last command if takes longer than this many seconds. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3 + # Show this many fractional digits. Zero means round to seconds. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 + # Execution time color. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=101 + # Duration format: 1d 2h 3m 4s. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s' + # Custom icon. + # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX='%ftook ' + + #######################[ background_jobs: presence of background jobs ]####################### + # Don't show the number of background jobs. + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false + # Background jobs color. + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=70 + # Custom icon. + # typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ direnv: direnv status (https://direnv.net/) ]######################## + # Direnv color. + typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=178 + # Custom icon. + # typeset -g POWERLEVEL9K_DIRENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ asdf: asdf version manager (https://github.com/asdf-vm/asdf) ]############### + # Default asdf color. Only used to display tools for which there is no color override (see below). + typeset -g POWERLEVEL9K_ASDF_FOREGROUND=66 + + # There are four parameters that can be used to hide asdf tools. Each parameter describes + # conditions under which a tool gets hidden. Parameters can hide tools but not unhide them. If at + # least one parameter decides to hide a tool, that tool gets hidden. If no parameter decides to + # hide a tool, it gets shown. + # + # Special note on the difference between POWERLEVEL9K_ASDF_SOURCES and + # POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW. Consider the effect of the following commands: + # + # asdf local python 3.8.1 + # asdf global python 3.8.1 + # + # After running both commands the current python version is 3.8.1 and its source is "local" as + # it takes precedence over "global". If POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW is set to false, + # it'll hide python version in this case because 3.8.1 is the same as the global version. + # POWERLEVEL9K_ASDF_SOURCES will hide python version only if the value of this parameter doesn't + # contain "local". + + # Hide tool versions that don't come from one of these sources. + # + # Available sources: + # + # - shell `asdf current` says "set by ASDF_${TOOL}_VERSION environment variable" + # - local `asdf current` says "set by /some/not/home/directory/file" + # - global `asdf current` says "set by /home/username/file" + # + # Note: If this parameter is set to (shell local global), it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SOURCES. + typeset -g POWERLEVEL9K_ASDF_SOURCES=(shell local global) + + # If set to false, hide tool versions that are the same as global. + # + # Note: The name of this parameter doesn't reflect its meaning at all. + # Note: If this parameter is set to true, it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_PROMPT_ALWAYS_SHOW. + typeset -g POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW=true + + # If set to false, hide tool versions that are equal to "system". + # + # Note: If this parameter is set to true, it won't hide tools. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_SYSTEM. + typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true + + # If set to non-empty value, hide tools unless there is a file matching the specified file pattern + # in the current directory, or its parent diretory, or its grandparent directory, and so on. + # + # Note: If this parameter is set to empty value, it won't hide tools. + # Note: SHOW_ON_UPGLOB isn't specific to asdf. It works with all prompt segments. + # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_ON_UPGLOB. + # + # Example: Hide nodejs version when there is no package.json and no *.js files in the current + # directory, in `..`, in `../..` and so on. + # + # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.js|package.json' + typeset -g POWERLEVEL9K_ASDF_SHOW_ON_UPGLOB= + + # Ruby version from asdf. + typeset -g POWERLEVEL9K_ASDF_RUBY_FOREGROUND=168 + # typeset -g POWERLEVEL9K_ASDF_RUBY_VISUAL_IDENTIFIER_EXPANSION='⭐' + typeset -g POWERLEVEL9K_ASDF_RUBY_SHOW_ON_UPGLOB='*.rb|Gemfile*|*.rake|.ruby-version|*.erb' + + typeset -g POWERLEVEL9K_ASDF_CRYSTAL_FOREGROUND=37 + typeset -g POWERLEVEL9K_ASDF_CRYSTAL_SHOW_ON_UPGLOB='*.cr|shard.yml|shard.lock' + + # Python version from asdf. + typeset -g POWERLEVEL9K_ASDF_PYTHON_FOREGROUND=76 + # typeset -g POWERLEVEL9K_ASDF_PYTHON_VISUAL_IDENTIFIER_EXPANSION='⭐' + typeset -g POWERLEVEL9K_ASDF_PYTHON_SHOW_ON_UPGLOB='*.py|*.pyc|requirements.txt' + + # Go version from asdf. + typeset -g POWERLEVEL9K_ASDF_GOLANG_FOREGROUND=37 + # typeset -g POWERLEVEL9K_ASDF_GOLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' +# typeset -g POWERLEVEL9K_ASDF_GOLANG_SHOW_ON_UPGLOB='*.go' + # use explicit go_version component in p10k + typeset -g POWERLEVEL9K_ASDF_GOLANG_SHOW_ON_UPGLOB=--disabled-- + + # Node.js version from asdf. + typeset -g POWERLEVEL9K_ASDF_NODEJS_FOREGROUND=70 + # typeset -g POWERLEVEL9K_ASDF_NODEJS_VISUAL_IDENTIFIER_EXPANSION='⭐' + typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='package.json|yarn.lock|*.js|*.es6|*.jsx|*.ts|*.tsx' + + typeset -g POWERLEVEL9K_ASDF_YARN_FOREGROUND=70 + typeset -g POWERLEVEL9K_ASDF_YARN_SHOW_ON_UPGLOB='yarn.lock' + + # Rust version from asdf. + typeset -g POWERLEVEL9K_ASDF_RUST_FOREGROUND=37 + # typeset -g POWERLEVEL9K_ASDF_RUST_VISUAL_IDENTIFIER_EXPANSION='⭐' +# typeset -g POWERLEVEL9K_ASDF_RUST_SHOW_ON_UPGLOB='*.rs|Cargo.toml|Cargo.lock' + # use explixit rust_version component in p10k + typeset -g POWERLEVEL9K_ASDF_RUST_SHOW_ON_UPGLOB=--disabled-- + + # .NET Core version from asdf. + typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_FOREGROUND=134 + # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_DOTNET_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Flutter version from asdf. + typeset -g POWERLEVEL9K_ASDF_FLUTTER_FOREGROUND=38 + # typeset -g POWERLEVEL9K_ASDF_FLUTTER_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_FLUTTER_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Lua version from asdf. + typeset -g POWERLEVEL9K_ASDF_LUA_FOREGROUND=32 + # typeset -g POWERLEVEL9K_ASDF_LUA_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_LUA_SHOW_ON_UPGLOB='*.foo|*.bar' + + typeset -g POWERLEVEL9K_ASDF_CLOJURE_FOREGROUND=32 + typeset -g POWERLEVEL9K_ASDF_CLOJURE_SHOW_ON_UPGLOB='*.clj|*.cljs|*.cljx' + + # Java version from asdf. + typeset -g POWERLEVEL9K_ASDF_JAVA_FOREGROUND=32 + # typeset -g POWERLEVEL9K_ASDF_JAVA_VISUAL_IDENTIFIER_EXPANSION='⭐' + typeset -g POWERLEVEL9K_ASDF_JAVA_SHOW_ON_UPGLOB='pom.xml|*.java|*.class|*.jar|'$POWERLEVEL9K_ASDF_CLOJURE_SHOW_ON_UPGLOB + + # Perl version from asdf. + typeset -g POWERLEVEL9K_ASDF_PERL_FOREGROUND=67 + # typeset -g POWERLEVEL9K_ASDF_PERL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PERL_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Elixir version from asdf. + typeset -g POWERLEVEL9K_ASDF_ELIXIR_FOREGROUND=129 + # typeset -g POWERLEVEL9K_ASDF_ELIXIR_VISUAL_IDENTIFIER_EXPANSION='⭐' + typeset -g POWERLEVEL9K_ASDF_ELIXIR_SHOW_ON_UPGLOB='*.ex|*.exs|mix.lock' + + # Erlang version from asdf. + typeset -g POWERLEVEL9K_ASDF_ERLANG_FOREGROUND=125 + # typeset -g POWERLEVEL9K_ASDF_ERLANG_VISUAL_IDENTIFIER_EXPANSION='⭐' + typeset -g POWERLEVEL9K_ASDF_ERLANG_SHOW_ON_UPGLOB='*.erl|'$POWERLEVEL9K_ASDF_ELIXIR_SHOW_ON_UPGLOB + + # Postgres version from asdf. + typeset -g POWERLEVEL9K_ASDF_POSTGRES_FOREGROUND=31 + # typeset -g POWERLEVEL9K_ASDF_POSTGRES_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_POSTGRES_SHOW_ON_UPGLOB='*.foo|*.bar' + + # PHP version from asdf. + typeset -g POWERLEVEL9K_ASDF_PHP_FOREGROUND=99 + # typeset -g POWERLEVEL9K_ASDF_PHP_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PHP_SHOW_ON_UPGLOB='*.foo|*.bar' + + # Haskell version from asdf. + typeset -g POWERLEVEL9K_ASDF_HASKELL_FOREGROUND=172 + # typeset -g POWERLEVEL9K_ASDF_HASKELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_HASKELL_SHOW_ON_UPGLOB='*.foo|*.bar' + + ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### + # NordVPN connection indicator color. + typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=39 + # Hide NordVPN connection indicator when not connected. + typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_CONTENT_EXPANSION= + typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_VISUAL_IDENTIFIER_EXPANSION= + # Custom icon. + # typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## + # Ranger shell color. + typeset -g POWERLEVEL9K_RANGER_FOREGROUND=178 + # Custom icon. + # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################[ nnn: nnn shell (https://github.com/jarun/nnn) ]####################### + # Nnn shell color. + typeset -g POWERLEVEL9K_NNN_FOREGROUND=72 + # Custom icon. + # typeset -g POWERLEVEL9K_NNN_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########################[ vim_shell: vim shell indicator (:sh) ]########################### + # Vim shell indicator color. + typeset -g POWERLEVEL9K_VIM_SHELL_FOREGROUND=34 + # Custom icon. + # typeset -g POWERLEVEL9K_VIM_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######[ midnight_commander: midnight commander shell (https://midnight-commander.org/) ]###### + # Midnight Commander shell color. + typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_FOREGROUND=178 + # Custom icon. + # typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ nix_shell: nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) ]## + # Nix shell color. + typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=74 + + # Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line. + # typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION= + + # Custom icon. + # typeset -g POWERLEVEL9K_NIX_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################################[ disk_usage: disk usage ]################################## + # Colors for different levels of disk usage. + typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_FOREGROUND=35 + typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_FOREGROUND=220 + typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_FOREGROUND=160 + # Thresholds for different levels of disk usage (percentage points). + typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=90 + typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=95 + # If set to true, hide disk usage when below $POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL percent. + typeset -g POWERLEVEL9K_DISK_USAGE_ONLY_WARNING=false + # Custom icon. + # typeset -g POWERLEVEL9K_DISK_USAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################################[ ram: free RAM ]####################################### + # RAM color. + typeset -g POWERLEVEL9K_RAM_FOREGROUND=66 + # Custom icon. + # typeset -g POWERLEVEL9K_RAM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################################[ swap: used swap ]###################################### + # Swap color. + typeset -g POWERLEVEL9K_SWAP_FOREGROUND=96 + # Custom icon. + # typeset -g POWERLEVEL9K_SWAP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################################[ load: CPU load ]###################################### + # Show average CPU load over this many last minutes. Valid values are 1, 5 and 15. + typeset -g POWERLEVEL9K_LOAD_WHICH=5 + # Load color when load is under 50%. + typeset -g POWERLEVEL9K_LOAD_NORMAL_FOREGROUND=66 + # Load color when load is between 50% and 70%. + typeset -g POWERLEVEL9K_LOAD_WARNING_FOREGROUND=178 + # Load color when load is over 70%. + typeset -g POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND=166 + # Custom icon. + # typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ todo: todo items (https://github.com/todotxt/todo.txt-cli) ]################ + # Todo color. + typeset -g POWERLEVEL9K_TODO_FOREGROUND=110 + # Hide todo when the total number of tasks is zero. + typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_TOTAL=true + # Hide todo when the number of tasks after filtering is zero. + typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_FILTERED=false + + # Todo format. The following parameters are available within the expansion. + # + # - P9K_TODO_TOTAL_TASK_COUNT The total number of tasks. + # - P9K_TODO_FILTERED_TASK_COUNT The number of tasks after filtering. + # + # These variables correspond to the last line of the output of `todo.sh -p ls`: + # + # TODO: 24 of 42 tasks shown + # + # Here 24 is P9K_TODO_FILTERED_TASK_COUNT and 42 is P9K_TODO_TOTAL_TASK_COUNT. + # + # typeset -g POWERLEVEL9K_TODO_CONTENT_EXPANSION='$P9K_TODO_FILTERED_TASK_COUNT' + + # Custom icon. + # typeset -g POWERLEVEL9K_TODO_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ timewarrior: timewarrior tracking status (https://timewarrior.net/) ]############ + # Timewarrior color. + typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=110 + # If the tracked task is longer than 24 characters, truncate and append "…". + # Tip: To always display tasks without truncation, delete the following parameter. + # Tip: To hide task names and display just the icon when time tracking is enabled, set the + # value of the following parameter to "". + typeset -g POWERLEVEL9K_TIMEWARRIOR_CONTENT_EXPANSION='${P9K_CONTENT:0:24}${${P9K_CONTENT:24}:+…}' + + # Custom icon. + # typeset -g POWERLEVEL9K_TIMEWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############[ taskwarrior: taskwarrior task count (https://taskwarrior.org/) ]############## + # Taskwarrior color. + typeset -g POWERLEVEL9K_TASKWARRIOR_FOREGROUND=74 + + # Taskwarrior segment format. The following parameters are available within the expansion. + # + # - P9K_TASKWARRIOR_PENDING_COUNT The number of pending tasks: `task +PENDING count`. + # - P9K_TASKWARRIOR_OVERDUE_COUNT The number of overdue tasks: `task +OVERDUE count`. + # + # Zero values are represented as empty parameters. + # + # The default format: + # + # '${P9K_TASKWARRIOR_OVERDUE_COUNT:+"!$P9K_TASKWARRIOR_OVERDUE_COUNT/"}$P9K_TASKWARRIOR_PENDING_COUNT' + # + # typeset -g POWERLEVEL9K_TASKWARRIOR_CONTENT_EXPANSION='$P9K_TASKWARRIOR_PENDING_COUNT' + + # Custom icon. + # typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################################[ context: user@hostname ]################################## + # Context color when running with privileges. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178 + # Context color in SSH without privileges. + typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_FOREGROUND=180 + # Default context color (no privileges, no SSH). + typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180 + + # Context format when running with privileges: bold user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%B%n@%m' + # Context format when in SSH without privileges: user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_TEMPLATE='%n@%m' + # Default context format (no privileges, no SSH): user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m' + + # Don't show context unless running with privileges or in SSH. + # Tip: Remove the next line to always show context. + typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= + + # Custom icon. + # typeset -g POWERLEVEL9K_CONTEXT_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + typeset -g POWERLEVEL9K_CONTEXT_PREFIX='%fwith ' + + ###[ virtualenv: python virtual environment (https://docs.python.org/3/library/venv.html) ]### + # Python virtual environment color. + typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=37 + # Don't show Python version next to the virtual environment name. + typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false + # Don't show virtualenv if pyenv is already shown. + typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false + # Separate environment name from Python version only with a space. + typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################[ anaconda: conda environment (https://conda.io/) ]###################### + # Anaconda environment color. + typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=37 + # Don't show Python version next to the anaconda environment name. + typeset -g POWERLEVEL9K_ANACONDA_SHOW_PYTHON_VERSION=false + # Separate environment name from Python version only with a space. + typeset -g POWERLEVEL9K_ANACONDA_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ pyenv: python environment (https://github.com/pyenv/pyenv) ]################ + # Pyenv color. + typeset -g POWERLEVEL9K_PYENV_FOREGROUND=37 + # Hide python version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PYENV_SOURCES=(shell local global) + # If set to false, hide python version if it's the same as global: + # $(pyenv version-name) == $(pyenv global). + typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide python version if it's equal to "system". + typeset -g POWERLEVEL9K_PYENV_SHOW_SYSTEM=true + + # Pyenv segment format. The following parameters are available within the expansion. + # + # - P9K_CONTENT Current pyenv environment (pyenv version-name). + # - P9K_PYENV_PYTHON_VERSION Current python version (python --version). + # + # The default format has the following logic: + # + # 1. Display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION" if $P9K_PYENV_PYTHON_VERSION is not + # empty and unequal to $P9K_CONTENT. + # 2. Otherwise display just "$P9K_CONTENT". + typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_PYENV_PYTHON_VERSION:#$P9K_CONTENT}:+ $P9K_PYENV_PYTHON_VERSION}' + + # Custom icon. + # typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ goenv: go environment (https://github.com/syndbg/goenv) ]################ + # Goenv color. + typeset -g POWERLEVEL9K_GOENV_FOREGROUND=37 + # Hide go version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_GOENV_SOURCES=(shell local global) + # If set to false, hide go version if it's the same as global: + # $(goenv version-name) == $(goenv global). + typeset -g POWERLEVEL9K_GOENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide go version if it's equal to "system". + typeset -g POWERLEVEL9K_GOENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_GOENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ nodenv: node.js version from nodenv (https://github.com/nodenv/nodenv) ]########## + # Nodenv color. + typeset -g POWERLEVEL9K_NODENV_FOREGROUND=70 + # Hide node version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_NODENV_SOURCES=(shell local global) + # If set to false, hide node version if it's the same as global: + # $(nodenv version-name) == $(nodenv global). + typeset -g POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide node version if it's equal to "system". + typeset -g POWERLEVEL9K_NODENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_NODENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### + # Nvm color. + typeset -g POWERLEVEL9K_NVM_FOREGROUND=70 + # Custom icon. + # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ############[ nodeenv: node.js environment (https://github.com/ekalinin/nodeenv) ]############ + # Nodeenv color. + typeset -g POWERLEVEL9K_NODEENV_FOREGROUND=70 + # Don't show Node version next to the environment name. + typeset -g POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION=false + # Separate environment name from Node version only with a space. + typeset -g POWERLEVEL9K_NODEENV_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_NODEENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############################[ node_version: node.js version ]############################### + # Node version color. + typeset -g POWERLEVEL9K_NODE_VERSION_FOREGROUND=70 + # Show node version only when in a directory tree containing package.json. + typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=false + # Custom icon. + # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ go_version: go version (https://golang.org) ]######################## + # Go version color. + typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=37 + # Show go version only when in a go project subdirectory. + typeset -g POWERLEVEL9K_GO_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #################[ rust_version: rustc version (https://www.rust-lang.org) ]################## + # Rust version color. + typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=37 + # Show rust version only when in a rust project subdirectory. + typeset -g POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################ + # .NET version color. + typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=134 + # Show .NET version only when in a .NET project subdirectory. + typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################[ php_version: php version (https://www.php.net/) ]###################### + # PHP version color. + typeset -g POWERLEVEL9K_PHP_VERSION_FOREGROUND=99 + # Show PHP version only when in a PHP project subdirectory. + typeset -g POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHP_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ laravel_version: laravel php framework version (https://laravel.com/) ]########### + # Laravel version color. + typeset -g POWERLEVEL9K_LARAVEL_VERSION_FOREGROUND=161 + # Custom icon. + # typeset -g POWERLEVEL9K_LARAVEL_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ####################[ java_version: java version (https://www.java.com/) ]#################### + # Java version color. + typeset -g POWERLEVEL9K_JAVA_VERSION_FOREGROUND=32 + # Show java version only when in a java project subdirectory. + typeset -g POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY=true + # Show brief version. + typeset -g POWERLEVEL9K_JAVA_VERSION_FULL=false + # Custom icon. + # typeset -g POWERLEVEL9K_JAVA_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###[ package: name@version from package.json (https://docs.npmjs.com/files/package.json) ]#### + # Package color. + typeset -g POWERLEVEL9K_PACKAGE_FOREGROUND=117 + # Package format. The following parameters are available within the expansion. + # + # - P9K_PACKAGE_NAME The value of `name` field in package.json. + # - P9K_PACKAGE_VERSION The value of `version` field in package.json. + # + # typeset -g POWERLEVEL9K_PACKAGE_CONTENT_EXPANSION='${P9K_PACKAGE_NAME//\%/%%}@${P9K_PACKAGE_VERSION//\%/%%}' + # Custom icon. + # typeset -g POWERLEVEL9K_PACKAGE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## + # Rbenv color. + typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 + # Hide ruby version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_RBENV_SOURCES=(shell local global) + # If set to false, hide ruby version if it's the same as global: + # $(rbenv version-name) == $(rbenv global). + typeset -g POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide ruby version if it's equal to "system". + typeset -g POWERLEVEL9K_RBENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ rvm: ruby version from rvm (https://rvm.io) ]######################## + # Rvm color. + typeset -g POWERLEVEL9K_RVM_FOREGROUND=168 + # Don't show @gemset at the end. + typeset -g POWERLEVEL9K_RVM_SHOW_GEMSET=false + # Don't show ruby- at the front. + typeset -g POWERLEVEL9K_RVM_SHOW_PREFIX=false + # Custom icon. + # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ fvm: flutter version management (https://github.com/leoafarias/fvm) ]############ + # Fvm color. + typeset -g POWERLEVEL9K_FVM_FOREGROUND=38 + # Custom icon. + # typeset -g POWERLEVEL9K_FVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ luaenv: lua version from luaenv (https://github.com/cehoffman/luaenv) ]########### + # Lua color. + typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=32 + # Hide lua version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_LUAENV_SOURCES=(shell local global) + # If set to false, hide lua version if it's the same as global: + # $(luaenv version-name) == $(luaenv global). + typeset -g POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide lua version if it's equal to "system". + typeset -g POWERLEVEL9K_LUAENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_LUAENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ jenv: java version from jenv (https://github.com/jenv/jenv) ]################ + # Java color. + typeset -g POWERLEVEL9K_JENV_FOREGROUND=32 + # Hide java version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_JENV_SOURCES=(shell local global) + # If set to false, hide java version if it's the same as global: + # $(jenv version-name) == $(jenv global). + typeset -g POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide java version if it's equal to "system". + typeset -g POWERLEVEL9K_JENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_JENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ plenv: perl version from plenv (https://github.com/tokuhirom/plenv) ]############ + # Perl color. + typeset -g POWERLEVEL9K_PLENV_FOREGROUND=67 + # Hide perl version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PLENV_SOURCES=(shell local global) + # If set to false, hide perl version if it's the same as global: + # $(plenv version-name) == $(plenv global). + typeset -g POWERLEVEL9K_PLENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide perl version if it's equal to "system". + typeset -g POWERLEVEL9K_PLENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ + # PHP color. + typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=99 + # Hide php version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global) + # If set to false, hide php version if it's the same as global: + # $(phpenv version-name) == $(phpenv global). + typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false + # If set to false, hide php version if it's equal to "system". + typeset -g POWERLEVEL9K_PHPENV_SHOW_SYSTEM=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]########### + # Haskell color. + typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=172 + # Hide haskell version if it doesn't come from one of these sources. + # + # shell: version is set by STACK_YAML + # local: version is set by stack.yaml up the directory tree + # global: version is set by the implicit global project (~/.stack/global-project/stack.yaml) + typeset -g POWERLEVEL9K_HASKELL_STACK_SOURCES=(shell local) + # If set to false, hide haskell version if it's the same as in the implicit global project. + typeset -g POWERLEVEL9K_HASKELL_STACK_ALWAYS_SHOW=true + # Custom icon. + # typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# + # Show kubecontext only when the the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show kubecontext. + typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito' + + # Kubernetes context classes for the purpose of using different colors, icons and expansions with + # different contexts. + # + # POWERLEVEL9K_KUBECONTEXT_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current kubernetes context gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_KUBECONTEXT_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_KUBECONTEXT_CLASSES defines the context class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' DEFAULT) + # + # If your current kubernetes context is "deathray-testing/default", its class is TEST + # because "deathray-testing/default" doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_FOREGROUND=134 + # typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use POWERLEVEL9K_KUBECONTEXT_CONTENT_EXPANSION to specify the content displayed by kubecontext + # segment. Parameter expansions are very flexible and fast, too. See reference: + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. + # + # Within the expansion the following parameters are always available: + # + # - P9K_CONTENT The content that would've been displayed if there was no content + # expansion defined. + # - P9K_KUBECONTEXT_NAME The current context's name. Corresponds to column NAME in the + # output of `kubectl config get-contexts`. + # - P9K_KUBECONTEXT_CLUSTER The current context's cluster. Corresponds to column CLUSTER in the + # output of `kubectl config get-contexts`. + # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE + # in the output of `kubectl config get-contexts`. If there is no + # namespace, the parameter is set to "default". + # - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the + # output of `kubectl config get-contexts`. + # + # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), + # the following extra parameters are available: + # + # - P9K_KUBECONTEXT_CLOUD_NAME Either "gke" or "eks". + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT Account/project ID. + # - P9K_KUBECONTEXT_CLOUD_ZONE Availability zone. + # - P9K_KUBECONTEXT_CLOUD_CLUSTER Cluster. + # + # P9K_KUBECONTEXT_CLOUD_* parameters are derived from P9K_KUBECONTEXT_CLUSTER. For example, + # if P9K_KUBECONTEXT_CLUSTER is "gke_my-account_us-east1-a_my-cluster-01": + # + # - P9K_KUBECONTEXT_CLOUD_NAME=gke + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=my-account + # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east1-a + # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 + # + # If P9K_KUBECONTEXT_CLUSTER is "arn:aws:eks:us-east-1:123456789012:cluster/my-cluster-01": + # + # - P9K_KUBECONTEXT_CLOUD_NAME=eks + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=123456789012 + # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east-1 + # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION= + # Show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back to P9K_KUBECONTEXT_NAME. + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}' + # Append the current context's namespace if it's not "default". + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${${:-/$P9K_KUBECONTEXT_NAMESPACE}:#/default}' + + # Custom prefix. + typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%fat ' + + ################[ terraform: terraform workspace (https://www.terraform.io) ]################# + # POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current terraform workspace gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_TERRAFORM_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_TERRAFORM_CLASSES defines the workspace class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' DEFAULT) + # + # If your current terraform workspace is "project_test", its class is TEST because "project_test" + # doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_TERRAFORM_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_TERRAFORM_DEFAULT_FOREGROUND=38 + # typeset -g POWERLEVEL9K_TERRAFORM_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# + # Show aws only when the the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show aws. + typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|terraform|pulumi' + + # POWERLEVEL9K_AWS_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current AWS profile gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_AWS_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_AWS_CLASSES defines the profile class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_AWS_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' DEFAULT) + # + # If your current AWS profile is "company_test", its class is TEST + # because "company_test" doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_AWS_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_AWS_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_AWS_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_AWS_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=208 + # typeset -g POWERLEVEL9K_AWS_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ aws_eb_env: aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) ]# + # AWS Elastic Beanstalk environment color. + typeset -g POWERLEVEL9K_AWS_EB_ENV_FOREGROUND=70 + # Custom icon. + # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## + # Show azure only when the the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show azure. + typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi' + # Azure account name color. + typeset -g POWERLEVEL9K_AZURE_FOREGROUND=32 + # Custom icon. + # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### + # Show gcloud only when the the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show gcloud. + typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs' + # Google cloud color. + typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=32 + + # Google cloud format. Change the value of POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION and/or + # POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION if the default is too verbose or not informative + # enough. You can use the following parameters in the expansions. Each of them corresponds to the + # output of `gcloud` tool. + # + # Parameter | Source + # -------------------------|-------------------------------------------------------------------- + # P9K_GCLOUD_CONFIGURATION | gcloud config configurations list --format='value(name)' + # P9K_GCLOUD_ACCOUNT | gcloud config get-value account + # P9K_GCLOUD_PROJECT_ID | gcloud config get-value project + # P9K_GCLOUD_PROJECT_NAME | gcloud projects describe $P9K_GCLOUD_PROJECT_ID --format='value(name)' + # + # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurences of '%' replaced with '%%'. + # + # Obtaining project name requires sending a request to Google servers. This can take a long time + # and even fail. When project name is unknown, P9K_GCLOUD_PROJECT_NAME is not set and gcloud + # prompt segment is in state PARTIAL. When project name gets known, P9K_GCLOUD_PROJECT_NAME gets + # set and gcloud prompt segment transitions to state COMPLETE. + # + # You can customize the format, icon and colors of gcloud segment separately for states PARTIAL + # and COMPLETE. You can also hide gcloud in state PARTIAL by setting + # POWERLEVEL9K_GCLOUD_PARTIAL_VISUAL_IDENTIFIER_EXPANSION and + # POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION to empty. + typeset -g POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_ID//\%/%%}' + typeset -g POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_NAME//\%/%%}' + + # Send a request to Google (by means of `gcloud projects describe ...`) to obtain project name + # this often. Negative value disables periodic polling. In this mode project name is retrieved + # only when the current configuration, account or project id changes. + typeset -g POWERLEVEL9K_GCLOUD_REFRESH_PROJECT_NAME_SECONDS=60 + + # Custom icon. + # typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]# + # Show google_app_cred only when the the command you are typing invokes one of these tools. + # Tip: Remove the next line to always show google_app_cred. + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi' + + # Google application credentials classes for the purpose of using different colors, icons and + # expansions with different credentials. + # + # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES is an array with even number of elements. The first + # element in each pair defines a pattern against which the current kubernetes context gets + # matched. More specifically, it's P9K_CONTENT prior to the application of context expansion + # (see below) that gets matched. If you unset all POWERLEVEL9K_GOOGLE_APP_CRED_*CONTENT_EXPANSION + # parameters, you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES defines the context class. Patterns are tried in order. + # The first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( + # '*:*prod*:*' PROD + # '*:*test*:*' TEST + # '*' DEFAULT) + # + # If your current Google application credentials is "service_account deathray-testing x@y.com", + # its class is TEST because it doesn't match the pattern '* *prod* *' but does match '* *test* *'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_FOREGROUND=28 + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_CONTENT_EXPANSION='$P9K_GOOGLE_APP_CRED_PROJECT_ID' + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=( + # '*:*prod*:*' PROD # These values are examples that are unlikely + # '*:*test*:*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_FOREGROUND=32 + # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION to specify the content displayed by + # google_app_cred segment. Parameter expansions are very flexible and fast, too. See reference: + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. + # + # You can use the following parameters in the expansion. Each of them corresponds to one of the + # fields in the JSON file pointed to by GOOGLE_APPLICATION_CREDENTIALS. + # + # Parameter | JSON key file field + # ---------------------------------+--------------- + # P9K_GOOGLE_APP_CRED_TYPE | type + # P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id + # P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email + # + # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurences of '%' replaced by '%%'. + typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}' + + ###############################[ public_ip: public IP address ]############################### + # Public IP color. + typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=94 + # Custom icon. + # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ########################[ vpn_ip: virtual private network indicator ]######################### + # VPN IP color. + typeset -g POWERLEVEL9K_VPN_IP_FOREGROUND=81 + # When on VPN, show just an icon without the IP address. + # Tip: To display the private IP address when on VPN, remove the next line. + typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= + # Regular expression for the VPN network interface. Run `ifconfig` or `ip -4 a show` while on VPN + # to see the name of the interface. + typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(wg|(.*tun))[0-9]*' + # If set to true, show one segment per matching network interface. If set to false, show only + # one segment corresponding to the first matching network interface. + # Tip: If you set it to true, you'll probably want to unset POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION. + typeset -g POWERLEVEL9K_VPN_IP_SHOW_ALL=false + # Custom icon. + # typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###########[ ip: ip address and bandwidth usage for a specified network interface ]########### + # IP color. + typeset -g POWERLEVEL9K_IP_FOREGROUND=38 + # The following parameters are accessible within the expansion: + # + # Parameter | Meaning + # ----------------------+--------------- + # P9K_IP_IP | IP address + # P9K_IP_INTERFACE | network interface + # P9K_IP_RX_BYTES | total number of bytes received + # P9K_IP_TX_BYTES | total number of bytes sent + # P9K_IP_RX_RATE | receive rate (since last prompt) + # P9K_IP_TX_RATE | send rate (since last prompt) + typeset -g POWERLEVEL9K_IP_CONTENT_EXPANSION='$P9K_IP_IP${P9K_IP_RX_RATE:+ %70F⇣$P9K_IP_RX_RATE}${P9K_IP_TX_RATE:+ %215F⇡$P9K_IP_TX_RATE}' + # Show information for the first network interface whose name matches this regular expression. + # Run `ifconfig` or `ip -4 a show` to see the names of all network interfaces. + typeset -g POWERLEVEL9K_IP_INTERFACE='e.*' + # Custom icon. + # typeset -g POWERLEVEL9K_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #########################[ proxy: system-wide http/https/ftp proxy ]########################## + # Proxy color. + typeset -g POWERLEVEL9K_PROXY_FOREGROUND=68 + # Custom icon. + # typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################################[ battery: internal battery ]################################# + # Show battery in red when it's below this level and not connected to power supply. + typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 + typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=160 + # Show battery in green when it's charging or fully charged. + typeset -g POWERLEVEL9K_BATTERY_{CHARGING,CHARGED}_FOREGROUND=70 + # Show battery in yellow when it's discharging. + typeset -g POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND=178 + # Battery pictograms going from low to high level of charge. + typeset -g POWERLEVEL9K_BATTERY_STAGES='\uf58d\uf579\uf57a\uf57b\uf57c\uf57d\uf57e\uf57f\uf580\uf581\uf578' + # Don't show the remaining time to charge/discharge. + typeset -g POWERLEVEL9K_BATTERY_VERBOSE=false + + #####################################[ wifi: wifi speed ]##################################### + # WiFi color. + typeset -g POWERLEVEL9K_WIFI_FOREGROUND=68 + # Custom icon. + # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use different colors and icons depending on signal strength ($P9K_WIFI_BARS). + # + # # Wifi colors and icons for different signal strength levels (low to high). + # typeset -g my_wifi_fg=(68 68 68 68 68) # <-- change these values + # typeset -g my_wifi_icon=('WiFi' 'WiFi' 'WiFi' 'WiFi' 'WiFi') # <-- change these values + # + # typeset -g POWERLEVEL9K_WIFI_CONTENT_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}$P9K_WIFI_LAST_TX_RATE Mbps' + # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}${my_wifi_icon[P9K_WIFI_BARS+1]}' + # + # The following parameters are accessible within the expansions: + # + # Parameter | Meaning + # ----------------------+--------------- + # P9K_WIFI_SSID | service set identifier, a.k.a. network name + # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none" + # P9K_WIFI_LAST_TX_RATE | wireless transmit rate in megabits per second + # P9K_WIFI_RSSI | signal strength in dBm, from -120 to 0 + # P9K_WIFI_NOISE | noise in dBm, from -120 to 0 + # P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE) + # + # All parameters except P9K_WIFI_BARS are extracted from the output of the following command: + # + # /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I + + ####################################[ time: current time ]#################################### + # Current time color. + typeset -g POWERLEVEL9K_TIME_FOREGROUND=66 + # Format for the current time: 09:51:02. See `man 3 strftime`. + typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}' + # If set to true, time will update when you hit enter. This way prompts for the past + # commands will contain the start times of their commands as opposed to the default + # behavior where they contain the end times of their preceding commands. + typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=false + # Custom icon. + # typeset -g POWERLEVEL9K_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + typeset -g POWERLEVEL9K_TIME_PREFIX='%fat ' + + # Example of a user-defined prompt segment. Function prompt_example will be called on every + # prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or + # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and orange text greeting the user. + # + # Type `p10k help segment` for documentation and a more sophisticated example. + function prompt_example() { + p10k segment -f 208 -i '⭐' -t 'hello, %n' + } + + # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job + # is to generate the prompt segment for display in instant prompt. See + # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. + # + # Powerlevel10k will call instant_prompt_* at the same time as the regular prompt_* function + # and will record all `p10k segment` calls it makes. When displaying instant prompt, Powerlevel10k + # will replay these calls without actually calling instant_prompt_*. It is imperative that + # instant_prompt_* always makes the same `p10k segment` calls regardless of environment. If this + # rule is not observed, the content of instant prompt will be incorrect. + # + # Usually, you should either not define instant_prompt_* or simply call prompt_* from it. If + # instant_prompt_* is not defined for a segment, the segment won't be shown in instant prompt. + function instant_prompt_example() { + # Since prompt_example always makes the same `p10k segment` calls, we can call it from + # instant_prompt_example. This will give us the same `example` prompt segment in the instant + # and regular prompts. + prompt_example + } + + # User-defined prompt segments can be customized the same way as built-in segments. + # typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=208 + # typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt + # when accepting a command line. Supported values: + # + # - off: Don't change prompt when accepting a command line. + # - always: Trim down prompt when accepting a command line. + # - same-dir: Trim down prompt when accepting a command line unless this is the first command + # typed after changing current working directory. + typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=same-dir + + # Instant prompt mode. + # + # - off: Disable instant prompt. Choose this if you've tried instant prompt and found + # it incompatible with your zsh configuration files. + # - quiet: Enable instant prompt and don't print warnings when detecting console output + # during zsh initialization. Choose this if you've read and understood + # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. + # - verbose: Enable instant prompt and print a warning when detecting console output during + # zsh initialization. Choose this if you've never tried instant prompt, haven't + # seen the warning, or if you are unsure what this all means. + typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose + + # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized. + # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload + # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you + # really need it. + typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true + + # If p10k is already loaded, reload configuration. + # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true. + (( ! $+functions[p10k] )) || p10k reload +} + +# Tell `p10k configure` which file it should overwrite. +typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a} + +(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} +'builtin' 'unset' 'p10k_config_opts' diff --git a/shells/zsh/zshenv b/shells/zsh/zshenv deleted file mode 100644 index bdd25030..00000000 --- a/shells/zsh/zshenv +++ /dev/null @@ -1,2 +0,0 @@ -which rbenv &>/dev/null || return -eval "$(rbenv init - zsh)" diff --git a/shells/zsh/zshrc b/shells/zsh/zshrc deleted file mode 100644 index 1436a1ab..00000000 --- a/shells/zsh/zshrc +++ /dev/null @@ -1,5 +0,0 @@ -CURRENT_SHELL="zsh" -SHELL_FILES="${$(readlink $HOME/.zshrc):h}" -DOT_FILES="${SHELL_FILES:h:h}" - -source $DOT_FILES/shells/bootstrap.sh diff --git a/vcs/git/git_template/hooks/ctags b/vcs/git/git_template/hooks/ctags index a6aefef0..4dd6a62c 100755 --- a/vcs/git/git_template/hooks/ctags +++ b/vcs/git/git_template/hooks/ctags @@ -1,8 +1,14 @@ #!/bin/sh - # See http://tbaggery.com/2011/08/08/effortless-ctags-with-git.html -new_tags_file="`mktemp -t ctags`" -ctags --tag-relative -Rf "${new_tags_file}" --exclude=.git --languages=-javascript,sql -mv "$new_tags_file" ".git/tags" - +set -e +PATH="/usr/local/bin:$PATH" +dir="`git rev-parse --git-dir`" +trap 'rm -f "$dir/$$.tags"' EXIT +git ls-files | \ + ctags --tag-relative -L - \ + -f"$dir/$$.tags" \ + --exclude=.git \ + # customize options per repo here: + --languages=-sql +mv "$dir/$$.tags" "$dir/tags" diff --git a/vcs/git/git_template/hooks/foo b/vcs/git/git_template/hooks/foo deleted file mode 100644 index e69de29b..00000000 diff --git a/vcs/git/gitattributes b/vcs/git/gitattributes index 172c4cd7..6d6c81d2 100644 --- a/vcs/git/gitattributes +++ b/vcs/git/gitattributes @@ -1,3 +1,5 @@ *.rb diff=ruby +*.ex diff=elixir +*.exs diff=elixir db/schema.rb merge=railsschema Gemfile.lock merge=gemfilelock diff --git a/vcs/git/gitconfig b/vcs/git/gitconfig index 68c0321a..cf31cc82 100644 --- a/vcs/git/gitconfig +++ b/vcs/git/gitconfig @@ -1,20 +1,62 @@ [alias] + st = status co = checkout - put = push origin HEAD - push-all = "!for i in $(git config --list | grep -E ^remote\\..+\\.url | sed -E 's/^remote\\.(.*)\\.url=.*/\\1/'); do git push $i master; done" + commit = commit -v + c = commit -v + ca = commit -v -a + diff = diff --word-diff + dc = diff --cached + lp = log --patch + lg = log --decorate --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative + shas = log --reverse --pretty=format:'%h' --abbrev-commit + me = !sh -c 'echo `git config user.name` \\<`git config user.email`\\>' + mine = !sh -c 'git lg --author=\"`git me`\"' + br = branch + + fixup = "!f() { TARGET=$(git rev-parse "$1"); git commit --fixup=$TARGET ${@:2} && EDITOR=true git rebase -i --autostash --autosquash $TARGET^; }; f" + + # Add file excluding whitespace changes (http://stackoverflow.com/a/7149602/56690) + addnw = !sh -c 'git diff -U0 -w --no-color "$@" | git apply --cached --ignore-whitespace --unidiff-zero -' + unadd = reset HEAD - ctags = !.git/hooks/ctags + ctags = "!$(git rev-parse --show-toplevel)/.git/hooks/ctags" + latest = for-each-ref --sort=-committerdate --format='%(committerdate:relative) -> %(refname:short)' + branch-name = !git for-each-ref --format='%(refname:short)' `git symbolic-ref HEAD` + assume = update-index --assume-unchanged + unassume = update-index --no-assume-unchanged + assumed = "!git ls-files -v | grep ^h | cut -c 3-" + unassumeall = "!git assumed | xargs git update-index --no-assume-unchanged" + assumeall = "!git st -s | awk {'print $2'} | xargs git assume" + + # From https://github.com/garybernhardt/dotfiles/blob/master/bin/git-churn + churn = "!git log --all -M -C --name-only --format='format:' \"$@\" | sort | grep -v '^$' | uniq -c | sort | awk 'BEGIN {print \"count\tfile\"} {print $1 \"\t\" $2}' | sort -g" + + # Write directly to versioned file (as `fresh`-managed one will be read-only) + config = config --file ~/.dotfiles/vcs/git/gitconfig [apply] - whitespace = nowarn + whitespace = fix [color] branch = auto diff = auto status = auto ui = auto +[log] + follow = true [core] attributesfile = ~/.gitattributes excludesfile = ~/.gitignore - whitespace = fix + whitespace = trailing-space,space-before-tab + precomposeunicode = true + #editor = vim -u NONE +0 -c 'syntax on' + editor = vim +0 -c 'syntax on' + + # # https://github.com/mookid/diffr + # pager = diffr | less -R + + # https://github.com/dandavison/delta + pager = delta --theme='Monokai Extended Bright' +[interactive] + diffFilter = delta --color-only [branch] autosetupmerge = always autosetuprebase = local @@ -24,12 +66,38 @@ user = bjeanes [init] templatedir = ~/.git_template -[rerere] - enabled = 1 + defaultBranch = main [include] path = .gitconfig.github path = .gitconfig.pushurls path = .gitconfig.merge path = .gitconfig.local [credential] - helper = osxkeychain + username = bjeanes +[diff] + algorithm = minimal + mnemonicprefix = true + renames = copies + tool = ksdiff +[difftool] + prompt = false +[difftool "ksdiff"] + cmd = "ksdiff $LOCAL $REMOTE" +[pull] + rebase = true +[push] + default = current +[advice] + statusHints = false +[remote] + pushdefault = origin +[status] + short = true + branch = true + showUntrackedFiles = all + submoduleSummary = 1 +[versionsort] + prereleaseSuffix = -rc + prereleaseSuffix = -pre + prereleaseSuffix = -alpha + prereleaseSuffix = -beta diff --git a/vcs/git/gitconfig.merge b/vcs/git/gitconfig.merge index 51c153aa..4ed14f8e 100644 --- a/vcs/git/gitconfig.merge +++ b/vcs/git/gitconfig.merge @@ -2,7 +2,14 @@ [merge] summary = true - tool = opendiff + conflictstyle = diff3 + tool = Kaleidoscope + +[mergetool "Kaleidoscope"] + cmd = ksdiff --merge --output \"$MERGED\" --base \"$BASE\" -- \"$LOCAL\" --snapshot \"$REMOTE\" --snapshot + trustExitCode = true +[mergetool] + prompt = false # http://bitfission.com/blog/2010/07/auto-merge-gemfile-lock.html [merge "bundlelock"] diff --git a/vcs/git/gitignore b/vcs/git/gitignore index 08b6f048..53c8ea15 100755 --- a/vcs/git/gitignore +++ b/vcs/git/gitignore @@ -49,7 +49,34 @@ doc/tags .bundle/* .rbx/ .netrwhist +jard_errors.txt # emacs .#* \#*# +*.pyc +.node_modules +./node_modules +node_modules +TAGS +.nrepl-port +pom.xml +pom.xml.asc +*jar +/classes/ +/target/ +/checkouts/ +.lein-* +vendor/gems +.gem +.gem/ +.yardoc/ +.terraform/ +.local/ +*.log +.bash_history +Session.vim +.vscode/ +SCRATCH +/.env +.tool-versions