1
0
Fork 0
mirror of synced 2024-09-16 02:22:54 -04:00

Merge branch 'develop'

This commit is contained in:
Eric Nielsen 2020-01-02 13:01:26 -05:00
commit edee218bb6
No known key found for this signature in database
GPG key ID: 47D1DBFA0765A1FB
116 changed files with 1032 additions and 3667 deletions

7
.gitignore vendored
View file

@ -1,4 +1,9 @@
*.swp
*.zwc
*.zwc.old
custom/
/modules/
/init.zsh
/init.zsh.old
/login_init.zsh
/login_init.zsh.old
/zimfw.zsh.old

28
.gitmodules vendored
View file

@ -1,28 +0,0 @@
[submodule "modules/history-substring-search/external"]
path = modules/history-substring-search/external
url = https://github.com/zsh-users/zsh-history-substring-search.git
ignore = untracked
[submodule "modules/completion/external"]
path = modules/completion/external
url = https://github.com/zsh-users/zsh-completions.git
ignore = untracked
[submodule "modules/syntax-highlighting/external"]
path = modules/syntax-highlighting/external
url = https://github.com/zsh-users/zsh-syntax-highlighting.git
ignore = untracked
[submodule "modules/prompt/external-themes/pure"]
path = modules/prompt/external-themes/pure
url = https://github.com/sindresorhus/pure.git
ignore = untracked
[submodule "modules/prompt/external-themes/liquidprompt"]
path = modules/prompt/external-themes/liquidprompt
url = https://github.com/nojhan/liquidprompt.git
ignore = untracked
[submodule "modules/prompt/external-themes/lean"]
path = modules/prompt/external-themes/lean
url = https://github.com/miekg/lean
ignore = untracked
[submodule "modules/autosuggestions/external"]
path = modules/autosuggestions/external
url = https://github.com/zsh-users/zsh-autosuggestions.git
ignore = untracked

22
LICENSE Normal file
View file

@ -0,0 +1,22 @@
MIT License
Copyright (c) 2015-2016 Matt Hamilton and contributors
Copyright (c) 2016-2019 Eric Nielsen, Matt Hamilton and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,26 +0,0 @@
MIT License
===========
Copyright (c) 2015-2016 Matt Hamilton and contributors
Copyright (c) 2016-2019 Eric Nielsen, Matt Hamilton and contributors
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the “Software”), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

4
Makefile Normal file
View file

@ -0,0 +1,4 @@
srcfiles := src/zimfw.zsh.erb $(wildcard src/*/*.erb)
zimfw.zsh: $(srcfiles)
erb $< >| $@

140
README.md
View file

@ -3,96 +3,142 @@ Zsh IMproved FrameWork
<div align="center">
<a href="https://github.com/zimfw/zimfw">
<img width=650px src="https://zimfw-static.s3.wasabisys.com/zimfw_banner.png">
<img width=650px src="https://zimfw.github.io/images/zim_banner.png">
</a>
</div>
What is Zim?
------------
Zim is a Zsh configuration framework with [blazing speed][speed] and modular extensions.
Zim is a Zsh configuration framework with [blazing speed] and modular extensions.
Zim is very easy to customize, and comes with a rich set of modules and features without compromising on speed or functionality!
What does Zim offer?
-----------------
If you're here, it means you want to see the cool shit Zim can do. Check out the [available modules][modules]!
If you're here, it means you want to see the cool shit Zim can do. Check out the [available modules]!
Below is a brief showcase of Zim's features.
### Speed
For a speed comparison between Zim and other frameworks, see [this wiki entry][speed].
For a speed comparison between Zim and other frameworks, see [this wiki entry][blazing speed].
### Themes
To preview some of the available themes, check the [themes wiki page][themes].
To preview some of the available themes, check the [themes wiki page].
### Fish-shell history navigation
![history-substring-search][fish_shell]
![history-substring-search]
### Syntax highlighting
![syntax-highlighting][syntax_highlighting]
![syntax-highlighting]
### And much more!
Zim has many modules! Enable as many or as few as you'd like.
Installation
------------
Installing Zim is easy. If you have a different shell framework installed (like oh-my-zsh or prezto),
*uninstall those first to prevent conflicts*. It can be installed manually by following the instructions below:
Installing Zim is easy:
1. Start a Zsh shell:
* With curl:
curl -fsSL https://raw.githubusercontent.com/zimfw/install/develop/install.zsh | zsh
* With wget:
wget -nv -O - https://raw.githubusercontent.com/zimfw/install/develop/install.zsh | zsh
Open a new terminal and you're done! Enjoy your Zsh IMproved! Take some time to
read about the [available modules] and tweak your `.zshrc` file.
If you have a different shell framework installed (like oh-my-zsh or prezto),
*uninstall those first to prevent conflicts*.
### Manual installation
1. Start a Zsh shell
zsh
2. Clone the repository:
git clone --recursive https://github.com/zimfw/zimfw.git ${ZDOTDIR:-${HOME}}/.zim
3. Paste this into your terminal to prepend the initialization templates to your configs:
for template_file in ${ZDOTDIR:-${HOME}}/.zim/templates/*; do
user_file="${ZDOTDIR:-${HOME}}/.${template_file:t}"
cat ${template_file} ${user_file}(.N) > ${user_file}.tmp && mv ${user_file}{.tmp,}
done
4. Set Zsh as the default shell:
2. Set Zsh as the default shell:
chsh -s =zsh
5. Open a new terminal and finish optimization (this is only needed once, hereafter it will happen upon desktop/tty login):
3. Copy https://raw.githubusercontent.com/zimfw/zimfw/develop/zimfw.zsh to
`~/.zim/zimfw.zsh`.
source ${ZDOTDIR:-${HOME}}/.zlogin
4. Add the lines in the following templates to the respective dot files:
* [~/.zshenv](https://github.com/zimfw/install/blob/develop/src/templates/zshenv)
* [~/.zshrc](https://github.com/zimfw/install/blob/develop/src/templates/zshrc)
* [~/.zlogin](https://github.com/zimfw/install/blob/develop/src/templates/zlogin)
* [~/.zimrc](https://github.com/zimfw/install/blob/develop/src/templates/zimrc)
6. You're done! Enjoy your Zsh IMproved! Take some time to read about the [available modules][modules] and tweak your `.zshrc` file.
5. Install the modules defined in `~/.zimrc` and build the initialization scripts:
Updating
--------
source ~/.zim/zimfw.zsh install
To update Zim, run:
Usage
-----
zmanage update
### zmodule
For more information about the `zmanage` tool, run `zmanage help`.
Add `zmodule` calls to your `~/.zimrc` file to define the modules to be initialized.
The modules are initialized in the same order they are defined. Add:
zmodule <url> [-n|--name <module_name>] [options]
where `<url>` is the required repository URL or path. The following formats
are equivalent: `name`, `zimfw/name`, `https://github.com/zimfw/name.git`.
By default, the module name is the last component in the `<url>`. Use the
`-n|--name <module_name>` option to set a custom module name.
#### Repository options
* `-b|--branch <branch_name>`: Use specified branch when installing and
updating the module. Overrides the tag option. Default: `master`.
* `-t|--tag <tag_name>`: Use specified tag when installing and updating the
module. Overrides the branch option.
* `-z|--frozen`: Don't install or update the module.
#### Initialization options
* `-f|--fpath <path>`: Add specified path to `fpath`. The path is relative to
the module root directory. Default: `functions`, if the subdirectory exists.
* `-a|--autoload <function_name>`: Autoload specified function. Default: all
valid names inside the module's specified `fpath` paths.
* `-s|--source <file_path>`: Source specified file. The file path is relative
to the module root directory. Default: the file with largest size matching
`{init.zsh|module_name.{zsh|plugin.zsh|zsh-theme|sh}}`, if any exists.
* `-d|--disabled`: Don't use or uninstall the module.
### zimfw
Added new modules to `~/.zimrc`? Run:
zimfw install
Removed modules from `~/.zimrc`? Run:
zimfw uninstall
Want to update your modules to their latest revisions? Run:
zimfw update
Want to upgrade `~/.zim/zimfw.zsh` to the latest version? Run:
zimfw upgrade
For more information about the `zimfw` tool, run `zimfw` with no parameters.
Uninstalling
------------
The best way to remove Zim is to manually delete `~/.zim`, `~/.zimrc`, and
remove the initialization lines from your `~/.zshrc` and `~/.zlogin`.
remove the initialization lines from your `~/.zshenv`, `~/.zshrc` and `~/.zlogin`.
However, there are some **experimental** convenience functions to remove Zim:
**NOTE: This functionality is experimental!**
To remove Zim, run:
zmanage remove
**NOTE: This functionality is experimental!**
[fish_shell]: https://zimfw-static.s3.wasabisys.com/zimfw_history-substring-search.gif
[syntax_highlighting]: https://zimfw-static.s3.wasabisys.com/zimfw_syntax-highlighting.gif
[speed]: https://github.com/zimfw/zimfw/wiki/Speed
[modules]: https://github.com/zimfw/zimfw/wiki/Modules
[themes]: https://github.com/zimfw/zimfw/wiki/Themes
[history-substring-search]: https://zimfw.github.io/images/zim_history-substring-search.gif
[syntax-highlighting]: https://zimfw.github.io/images/zim_syntax-highlighting.gif
[blazing speed]: https://github.com/zimfw/zimfw/wiki/Speed
[available modules]: https://github.com/zimfw/zimfw/wiki/Modules
[themes wiki page]: https://github.com/zimfw/zimfw/wiki/Themes

View file

@ -1,94 +0,0 @@
#
# Zim initializition
#
autoload -Uz is-at-least && if ! is-at-least 5.2; then
print "ERROR: Zim didn't start. You're using zsh version ${ZSH_VERSION}, and versions < 5.2 are not supported. Update your zsh." >&2
return 1
fi
# Define zim location
(( ! ${+ZIM_HOME} )) && export ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim
# Source user configuration
[[ -s ${ZDOTDIR:-${HOME}}/.zimrc ]] && source ${ZDOTDIR:-${HOME}}/.zimrc
# Set input mode before loading modules
if [[ ${zinput_mode} == 'vi' ]]; then
bindkey -v
else
bindkey -e
fi
# Autoload module functions
() {
local mod_function
setopt LOCAL_OPTIONS EXTENDED_GLOB
# autoload searches fpath for function locations; add enabled module function paths
fpath=(${ZIM_HOME}/modules/${^zmodules}/functions(/FN) ${fpath})
for mod_function in ${ZIM_HOME}/modules/${^zmodules}/functions/^(_*|prompt_*_setup|*.*)(-.N:t); do
autoload -Uz ${mod_function}
done
}
# Initialize modules
() {
local zmodule zmodule_dir zmodule_file
for zmodule in ${zmodules}; do
zmodule_dir=${ZIM_HOME}/modules/${zmodule}
if [[ ! -d ${zmodule_dir} ]]; then
print "No such module \"${zmodule}\"." >&2
else
for zmodule_file in ${zmodule_dir}/init.zsh \
${zmodule_dir}/{,zsh-}${zmodule}.{zsh,plugin.zsh,zsh-theme,sh}; do
if [[ -f ${zmodule_file} ]]; then
source ${zmodule_file}
break
fi
done
fi
done
}
zmanage() {
local usage="zmanage [action]
Actions:
update Fetch and merge upstream zim commits if possible
info Print zim and system info
issue Create a template for reporting an issue
clean-cache Clean the zim cache
build-cache Rebuild the zim cache
remove *experimental* Remove zim as best we can
reset Reset zim to the latest commit
debug Invoke the trace-zim script which produces logs
help Print this usage message"
if (( ${#} != 1 )); then
print ${usage}
return 1
fi
case ${1} in
update) zsh ${ZIM_HOME}/tools/zim_update
;;
info) zsh ${ZIM_HOME}/tools/zim_info
;;
issue) zsh ${ZIM_HOME}/tools/zim_issue
;;
clean-cache) source ${ZIM_HOME}/tools/zim_clean_cache && print 'Cache cleaned'
;;
build-cache) source ${ZIM_HOME}/tools/zim_build_cache && print 'Cache rebuilt'
;;
remove) zsh ${ZIM_HOME}/tools/zim_remove
;;
reset) zsh ${ZIM_HOME}/tools/zim_reset
;;
debug) zsh ${ZIM_HOME}/modules/debug/functions/trace-zim
;;
*) print ${usage}; return 1
;;
esac
}

View file

@ -1,33 +0,0 @@
#
# startup file read in interactive login shells
#
# The following code helps us by optimizing the existing framework.
# This includes zcompile, zcompdump, etc.
#
(
local dir file
setopt LOCAL_OPTIONS EXTENDED_GLOB
autoload -U zrecompile
# zcompile the completion cache; siginificant speedup
zrecompile -pq ${ZDOTDIR:-${HOME}}/${zcompdump_file:-.zcompdump}
# zcompile .zshrc
zrecompile -pq ${ZDOTDIR:-${HOME}}/.zshrc
# zcompile enabled module autoloaded functions
for dir in ${ZIM_HOME}/modules/${^zmodules}/functions(/FN); do
zrecompile -pq ${dir}.zwc ${dir}/^(_*|prompt_*_setup|*.*)(-.N)
done
# zcompile enabled module scripts
for file in ${ZIM_HOME}/modules/${^zmodules}/(^*test*/)#*.zsh{,-theme}(.NLk+1); do
zrecompile -pq ${file}
done
# zcompile all prompt setup scripts
for file in ${ZIM_HOME}/modules/prompt/functions/prompt_*_setup; do
zrecompile -pq ${file}
done
) &!

View file

@ -1,31 +0,0 @@
archive
=======
Provides `archive` and `unarchive` functions for easy archive manipulation.
This module will make use of `pigz` and `pbzip2` if available to make use of all available CPU cores.
Functions
---------
* `archive` generates an archive based on file extension. Syntax is `archive myarchive.tar.gz /path/to/archive`
* `unarchive` unarchives files based on the extensions. Syntax is `unarchive myarchive.7z`
Archive formats
---------------
| Format | Requirements |
| ------ | ------------ |
| .tar | `tar` |
| .tar.gz, .tgz | `tar` or `pigz` |
| .tar.bz, .tar.bz2, .tbz, .tbz2 | `tar` or `pbzip2` |
| .tar.xz, .txz | `tar` with xz support |
| .tar.zma, .tlz | `tar` with lzma support |
| .gz | `gunzip` or `pigz` |
| .bz, .bz2 | `bunzip2` or `pbzip2` |
| .xz | `unxz` |
| .lzma | `unzlma` |
| .Z | `uncompress` |
| .zip | `unzip` |
| .rar | `unrar` or `rar` |
| .7z | `7za` |

View file

@ -1,4 +0,0 @@
#compdef unarchive
_arguments \
"*:archive:_files -g '(#i)*.(tar|gz|tgz|bz|bz2|tbz|tbz2|xz|txz|tlz|lzma|Z|zip|rar|7z|001)(-.)'"

View file

@ -1,34 +0,0 @@
# vim:et sts=2 sw=2 ft=zsh
#
# Creates archive files
#
if (( # < 2 )); then
print "usage: ${0} <archive_name.ext> <file>..." >&2
return 1
fi
# we are quitting (above) if there are less than 2 vars,
# so we don't need any argc check here.
local archive_name="${1}"
shift
# pigz and pbzip2 are aliased in the init.zsh file. This provides a significant speedup, resulting in a
# near-liner decrease in compression time based on on the number of available cores.
case "${archive_name}" in
(*.tar.gz|*.tgz) tar -cvzf "${archive_name}" "${@}" ;;
(*.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar -cvjf "${archive_name}" "${@}" ;;
(*.tar.xz|*.txz) tar -J --help &>/dev/null && tar -cvJf "${archive_name}" "${@}" ;;
(*.tar.lzma|*.tlz) tar --lzma --help &>/dev/null && tar --lzma -cvf "${archive_name}" "${@}" ;;
(*.tar) tar -cvf "${archive_name}" "${@}" ;;
(*.zip) zip -r "${archive_name}" "${@}" ;;
(*.rar) rar a "${archive_name}" "${@}" ;;
(*.7z) 7za a "${archive_name}" "${@}" ;;
(*.gz) print "${0}: .gz is only useful for single files, and does not capture permissions. Use .tar.gz" ;;
(*.bz|*.bz2) print "${0}: .bzip2 is only useful for single files, and does not capture permissions. Use .tar.bz2" ;;
(*.xz) print "${0}: .xz is only useful for single files, and does not capture permissions. Use .tar.xz" ;;
(*.lzma) print "${0}: .lzma is only useful for single files, and does not capture permissions. Use .tar.lzma" ;;
(*) print "${0}: unknown archive type: ${archive_name}" ;;
esac

View file

@ -1,41 +0,0 @@
# vim:et sts=2 sw=2 ft=zsh
#
# Unarchives files
#
if (( # < 1 )); then
print "usage: ${0} <archive_name.ext>..." >&2
return 1
fi
setopt LOCAL_OPTIONS ERR_RETURN
# using unpigz/pbunzip2 provides little to decompression time; the benefit is mainly in compression time.
# setting it as an alias in the init.zsh file should be sufficient here.
while (( # > 0 )); do
local archive_name="${1}"
case "${archive_name}" in
(*.tar.gz|*.tgz) tar -xvzf "${archive_name}" ;;
(*.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar -xvjf "${archive_name}" ;;
(*.tar.xz|*.txz) tar -J --help &>/dev/null && tar -xvJf "${archive_name}" \
|| xzcat "${archive_name}" | tar xvf - ;;
(*.tar.lzma|*.tlz) tar --lzma --help &>/dev/null && tar --lzma -xvf "${archive_name}" \
|| lzcat "${archive_name}" | tar xvf - ;;
(*.tar) tar xvf "${archive_name}" ;;
(*.gz) gunzip "${archive_name}" ;;
(*.bz|*.bz2) bunzip2 "${archive_name}" ;;
(*.xz) unxz "${archive_name}" ;;
(*.lzma) unlzma "${archive_name}" ;;
(*.Z) uncompress "${archive_name}" ;;
(*.zip) unzip "${archive_name}";;
(*.rar) (( $+{commands[unrar]} )) && unrar x -ad "${archive_name}" \
|| rar x -ad "${archive_name}" ;;
(*.7z|*.001) 7za x "${archive_name}" ;;
(*)
print "${0}: unknown archive type: ${archive_name}"
return 1
;;
esac
shift
done

View file

@ -1,17 +0,0 @@
#
# Archive aliases
#
# if pigz/pbzip2 are available, alias them as they are drop-in replacements for gzip and bzip2, respectively.
#
# pigz
#
(( ${+commands[pigz]} )) && alias gzip='pigz'
(( ${+commands[unpigz]} )) && alias gunzip='unpigz'
#
# pbzip2
#
(( ${+commands[pbzip2]} )) && alias bzip2='pbzip2'
(( ${+commands[pbunzip2]} )) && alias bunzip2='pbunzip2'

View file

@ -1,13 +0,0 @@
zsh-autosuggestions
===================
_[Fish](http://fishshell.com/)-like fast/unobtrusive autosuggestions for Zsh._
It suggests commands as you type, based on command history.
<a href="https://asciinema.org/a/37390" target="_blank"><img src="https://asciinema.org/a/37390.png" width="400" /></a>
Contributing
------------
Contributions should be submitted [upstream to zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions)

@ -1 +0,0 @@
Subproject commit 146020d9b28c70a5edd93d19bbef9c5cb05d4b62

View file

@ -1,9 +0,0 @@
#
# Fish-like fast/unobtrusive autosuggestions for zsh.
#
# It suggests commands as you type, based on command history.
#
# source script
source ${0:h}/external/zsh-autosuggestions.zsh || return 1

View file

@ -1,21 +0,0 @@
completion
==========
Enables and configures smart and extensive tab completion.
Completions are sourced from [zsh-completions][zsh-completions].
Zsh options
-----------
* `ALWAYS_TO_END` moves cursor to end of word if a full completion is inserted.
* `PATH_DIRS` performs path search even on command names with slashes in them.
* `NO_CASE_GLOB` makes globbing case insensitive.
* `NO_LIST_BEEP` doesn't beep on ambiguous completions.
Contributing
------------
Command completions should be submitted [upstream to zsh-completions][zsh-completions].
[zsh-completions]: https://github.com/zsh-users/zsh-completions

@ -1 +0,0 @@
Subproject commit cf565254e26bb7ce03f51889e9a29953b955b1fb

View file

@ -1,96 +0,0 @@
#
# Completion enhancements
#
#
# initialization
#
# if it's a dumb terminal, return.
if [[ ${TERM} == 'dumb' ]]; then
return 1
fi
# add the completions to the fpath
fpath=(${0:h}/external/src ${fpath})
# load and initialize the completion system
autoload -Uz compinit && compinit -C -d "${ZDOTDIR:-${HOME}}/${zcompdump_file:-.zcompdump}"
#
# zsh options
#
# If a completion is performed with the cursor within a word, and a full
# completion is inserted, the cursor is moved to the end of the word.
setopt ALWAYS_TO_END
# Perform a path search even on command names with slashes in them.
setopt PATH_DIRS
# Make globbing (filename generation) not sensitive to case.
setopt NO_CASE_GLOB
# Don't beep on an ambiguous completion.
setopt NO_LIST_BEEP
#
# completion module options
#
# group matches and describe.
zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*:matches' group yes
zstyle ':completion:*:options' description yes
zstyle ':completion:*:options' auto-description '%d'
zstyle ':completion:*:corrections' format '%F{green}-- %d (errors: %e) --%f'
zstyle ':completion:*:descriptions' format '%F{yellow}-- %d --%f'
zstyle ':completion:*:messages' format '%F{purple}-- %d --%f'
zstyle ':completion:*:warnings' format '%F{red}-- no matches found --%f'
zstyle ':completion:*' format '%F{yellow}-- %d --%f'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' verbose yes
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' '+r:|?=**'
# directories
if (( ! ${+LS_COLORS} )); then
# Locally use same LS_COLORS definition from utility module, in case it was not set
local LS_COLORS='di=1;34:ln=35:so=32:pi=33:ex=31:bd=1;36:cd=1;33:su=30;41:sg=30;46:tw=30;42:ow=30;43'
fi
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*:*:cd:*' tag-order local-directories directory-stack path-directories
zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
zstyle ':completion:*:-tilde-:*' group-order 'named-directories' 'path-directories' 'expand'
zstyle ':completion:*' squeeze-slashes true
# enable caching
zstyle ':completion::complete:*' use-cache on
zstyle ':completion::complete:*' cache-path "${ZDOTDIR:-${HOME}}/.zcompcache"
# ignore useless commands and functions
zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec)|prompt_*)'
# completion sorting
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
# Man
zstyle ':completion:*:manuals' separate-sections true
zstyle ':completion:*:manuals.(^1*)' insert-sections true
# history
zstyle ':completion:*:history-words' stop yes
zstyle ':completion:*:history-words' remove-all-dups yes
zstyle ':completion:*:history-words' list false
zstyle ':completion:*:history-words' menu yes
# ignore multiple entries.
zstyle ':completion:*:(rm|kill|diff):*' ignore-line other
zstyle ':completion:*:rm:*' file-patterns '*:all-files'
# If the _my_hosts function is defined, it will be called to add the ssh hosts
# completion, otherwise _ssh_hosts will fall through and read the ~/.ssh/config
zstyle -e ':completion:*:*:ssh:*:my-accounts' users-hosts \
'[[ -f ${HOME}/.ssh/config && ${key} == hosts ]] && key=my_hosts reply=()'

View file

@ -1,19 +0,0 @@
custom
======
Add any custom aliases/settings to the `init.zsh` file.
Any functions should go in the `functions` subdirectory, where the name of the
file is the name of the function.
For example, this function from your `.zshrc`:
```zsh
foo() {
print 'bar'
}
```
becomes a file named `foo` in the `functions` subdirectory containing:
```zsh
print 'bar'
```

View file

@ -1,4 +0,0 @@
# this is an example function
# running 'example_function' in a zsh session will execute the code below
print "executed example function: ${ZIM_HOME}/modules/custom/functions/example_function!"

View file

@ -1,8 +0,0 @@
#
# Custom aliases/settings
#
# any custom stuff should go here.
# ensure that 'custom' exists in the zmodules array in your .zimrc

View file

@ -1,18 +0,0 @@
debug
=====
Provides a function to debug Zim.
Functions
---------
* `trace-zim` provides a trace of Zsh/Zim startup
Notes
-----
`trace-zim` will not alter your current dotfiles. It will copy your environment
to a temporary directory, launch Zsh within that environment, and output logs.
This will provide a `ztrace.tar.gz` archive, which should be attached to any bug
reports if you need help with an issue that you don't understand.

View file

@ -1,105 +0,0 @@
#!/usr/bin/env zsh
#
# Generates trace log to debug zim and zsh issues
#
print "This function creates a trace log to debug
Zsh and Zim functionality.
It will copy your .zshrc to /tmp/ztrace/, ammend profiling
code, launch a new shell, log the trace, close the shell,
archive the logs, and finally print the path to the archive."
read \?"Press [Enter] to begin trace."
mkdir -p /tmp/ztrace
# make sure that we were able to create the directory
if [[ ! -d /tmp/ztrace ]]; then
print 'failed to create /tmp/ztrace directory. Aborting.'
return 1
else
# check if known output file, if exists
# rm all directory contents
if [[ -e /tmp/ztrace/ztrace.log ]]; then
print "\nLogs from previous run of trace-zim are present
Deleting old logs now..."
# use of anonymous function for dotglob opt
() {
setopt dotglob
rm -rf /tmp/ztrace/*
}
fi
fi
# get some basic system information (kernel and zsh version)
print "Zsh version:
$(zsh --version)
Kernel information:
$(uname -a)
fpath info:
${fpath}" >! /tmp/ztrace/sysinfo
cp ${ZDOTDIR:-${HOME}}/.zshrc /tmp/ztrace/.zshrc.orig
cp ${ZDOTDIR:-${HOME}}/.zimrc /tmp/ztrace/.zimrc
# rsync will allow us to not have to copy the .git folder; use if available
if (( ${+commands[rsync]} )); then
rsync -az --exclude .git ${ZIM_HOME} /tmp/ztrace/
else
cp -R ${ZIM_HOME} /tmp/ztrace/
fi
# create a modified .zshrc to produce a trace log
cat <<EOF >! /tmp/ztrace/.zshrc
###################
# zim trace start #
###################
PS4=$'%D{%s%6.}-_-'
exec 3>&2 2>/tmp/ztrace/sample-time.$$.log
zmodload zsh/zprof
setopt xtrace prompt_subst
EOF
cat /tmp/ztrace/.zshrc.orig >>! /tmp/ztrace/.zshrc
cat <<EOF >>! /tmp/ztrace/.zshrc
#################
# zim trace end #
#################
unsetopt xtrace
zprof >! /tmp/ztrace/zprof
#non-linux systems have weird fd; also, no real need to redirect back
#prompt is (practically speaking) non-interactive, fd exists only for that process
#which is closed (by typing exit)
#exec 2>&3 3>&-
EOF
print "\nSpawning zsh and producing trace...\n\n"
ZDOTDIR=/tmp/ztrace zsh -ic 'exit'
print "Trace complete.
Parsing logs to a nicer format; this may take some time..."
# this is ugly thing makes it pretty...
while read line; do if [[ ${line} =~ '^[0-9]+-_-' ]]; then crt=000000$((${line%%-_-*}-10#0$last)); printf "%12.9f %s\n" ${crt:0:${#crt}-6}.${crt:${#crt}-6} ${line#*-_-}; last=${line%%-_-*}; fi; done < /tmp/ztrace/sample-time.(*).log > /tmp/ztrace/ztrace.log
print "Parsing complete!"
# safe to remove old, unneeded environment files
print "Tidying up before archive..."
rm -f /tmp/ztrace/sample-time.*
rm -rf /tmp/ztrace/.zim
rm -f /tmp/ztrace/.zshrc
mv /tmp/ztrace/.zshrc.orig /tmp/ztrace/.zshrc
rm -f /tmp/ztrace/.zhistory
rm -f /tmp/ztrace/.zcompdump*
print "Archiving trace logs...\n"
tar -czf /tmp/ztrace.tar.gz /tmp/ztrace/
print "Archive complete!\n
Trace by with execution time available at:
/tmp/ztrace/ztrace.log
Archive (for sharing/help) available at:
/tmp/ztrace.tar.gz"

View file

@ -1,16 +0,0 @@
directory
=========
Sets directory, navigation, and redirect options.
Zsh options
-----------
* `AUTO_CD` performs cd to a directory if the typed command is invalid, but is a directory.
* `AUTO_PUSHD` makes cd push the old directory to the directory stack.
* `PUSHD_IGNORE_DUPS` does not push multiple copies of the same directory to the stack.
* `PUSHD_SILENT` does not print the directory stack after pushd or popd.
* `PUSHD_TO_HOME` has pushd without arguments act like `pushd ${HOME}`.
* `EXTENDED_GLOB` treats `#`, `~`, and `^` as patterns for filename globbing.
* `MULTIOS` performs implicit tees or cats when using multiple redirections.
* `NO_CLOBBER` disallows `>` to overwrite existing files. Use `>|` or `>!` instead.

View file

@ -1,38 +0,0 @@
#
# Directory navigation options
#
#
# Navigation
#
# If a command is issued that cant be executed as a normal command,
# and the command is the name of a directory, perform the cd command to that directory.
setopt AUTO_CD
# Make cd push the old directory onto the directory stack.
setopt AUTO_PUSHD
# Dont push multiple copies of the same directory onto the directory stack.
setopt PUSHD_IGNORE_DUPS
# Do not print the directory stack after pushd or popd.
setopt PUSHD_SILENT
# Have pushd with no arguments act like pushd ${HOME}.
setopt PUSHD_TO_HOME
#
# Globbing and fds
#
# Treat the #, ~ and ^ characters as part of patterns for filename generation, etc.
# (An initial unquoted ~ always produces named directory expansion.)
setopt EXTENDED_GLOB
# Perform implicit tees or cats when multiple redirections are attempted.
setopt MULTIOS
# Disallow > redirection to overwrite existing files.
# >| or >! must be used to overwrite a file.
setopt NO_CLOBBER

View file

@ -1,19 +0,0 @@
environment
===========
Sets generic Zsh built-in environment options.
Also enables smart URL-pasting. This prevents the user from having to manually escape URLs.
Uses `.zimrc` defined `${ztermtitle}` variable to set the terminal title, if defined.
Zsh options
-----------
* `AUTO_RESUME` resumes an existing job before creating a new one.
* `INTERACTIVE_COMMENTS` allows comments starting with `#` in the shell.
* `LONG_LIST_JOBS` lists jobs in verbose format by default.
* `NOTIFY` reports job status immediately instead of waiting for the prompt.
* `NO_BG_NICE` prevents background jobs being given a lower priority.
* `NO_CHECK_JOBS` prevents status report of jobs on shell exit.
* `NO_HUP` prevents SIGHUP to jobs on shell exit.

View file

@ -1,52 +0,0 @@
#
# generic options and environment settings
#
# Use smart URL pasting and escaping.
autoload -Uz bracketed-paste-url-magic && zle -N bracketed-paste bracketed-paste-url-magic
autoload -Uz url-quote-magic && zle -N self-insert url-quote-magic
# Treat single word simple commands without redirection as candidates for resumption of an existing job.
setopt AUTO_RESUME
# Allow comments starting with `#` even in interactive shells.
setopt INTERACTIVE_COMMENTS
# List jobs in the long format by default.
setopt LONG_LIST_JOBS
# Report the status of background jobs immediately, rather than waiting until just before printing a prompt.
setopt NOTIFY
# Prevent runing all background jobs at a lower priority.
setopt NO_BG_NICE
# Prevent reporting the status of background and suspended jobs before exiting a shell with job control.
# NO_CHECK_JOBS is best used only in combination with NO_HUP, else such jobs will be killed automatically.
setopt NO_CHECK_JOBS
# Prevent sending the HUP signal to running jobs when the shell exits.
setopt NO_HUP
# Remove path separtor from WORDCHARS.
WORDCHARS=${WORDCHARS//[\/]}
# Set less or more as the default pager.
if (( ! ${+PAGER} )); then
if (( ${+commands[less]} )); then
export PAGER=less
else
export PAGER=more
fi
fi
# sets the window title and updates upon directory change
# more work probably needs to be done here to support multiplexers
if (( ${+ztermtitle} )); then
case ${TERM} in
xterm*|*rxvt)
precmd() { print -Pn "\e]0;${ztermtitle}\a" }
precmd # we execute it once to initialize the window title
;;
esac
fi

View file

@ -1,14 +0,0 @@
fasd
====
[Fasd](https://github.com/clvv/fasd) (pronounced similar to "fast") is a command-line productivity booster.
Fasd offers quick access to files and directories for POSIX shells. It is
inspired by tools like [autojump](https://github.com/joelthelion/autojump),
[z](http://github.com/rupa/z) and [v](https://github.com/rupa/v). Fasd keeps
track of files and directories you have accessed, so that you can quickly
reference them in the command line.
Contributing
------------
Contributions should be submitted [upstream to fasd](https://github.com/clvv/fasd).

View file

@ -1,424 +0,0 @@
# Fasd is originally written based on code from z (https://github.com/rupa/z)
# by rupa deadwyler under the WTFPL license. Most if not all of the code has
# been rewritten.
# Copyright (C) 2011, 2012 by Wei Dai. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# make zsh do word splitting inside this function
[ "$ZSH_VERSION" ] && emulate sh && setopt localoptions
case $1 in
--init) shift
while [ "$1" ]; do
case $1 in
env)
{ # Load configuration files
if [[ -s ${XDG_CONFIG_HOME:-"${HOME}/.config"}/fasd/config ]]; then
source ${XDG_CONFIG_HOME:-"${HOME}/.config"}/fasd/config
else
[[ -s /etc/fasdrc ]] && source /etc/fasd
[[ -s ${HOME}/.fasdrc ]] && source ${HOME}/.fasdrc
fi
# set default options
(( ! ${+_FASD_DATA} )) && _FASD_DATA="$HOME/.fasd"
(( ! ${+_FASD_BLACKLIST} )) && _FASD_BLACKLIST="--help"
(( ! ${+_FASD_SHIFT} )) && _FASD_SHIFT="sudo busybox"
(( ! ${+_FASD_IGNORE} )) && _FASD_IGNORE="fasd ls echo"
(( ! ${+_FASD_SINK} )) && _FASD_SINK=/dev/null
(( ! ${+_FASD_TRACK_PWD} )) && _FASD_TRACK_PWD=1
(( ! ${+_FASD_MAX} )) && _FASD_MAX=2000
(( ! ${+_FASD_BACKENDS} )) && _FASD_BACKENDS=native
(( ! ${+_FASD_FUZZY} )) && _FASD_FUZZY=2
(( ! ${+_FASD_VIMINFO} )) && _FASD_VIMINFO="$HOME/.viminfo"
(( ! ${+_FASD_RECENTLY_USED_XBEL} )) && \
_FASD_RECENTLY_USED_XBEL="$HOME/.local/share/recently-used.xbel"
if (( ! ${+_FASD_AWK} )); then
# awk preferences
local awk; for awk in mawk gawk original-awk nawk awk; do
$awk "" && _FASD_AWK=$awk && break
done
fi
} >> ${_FASD_SINK:-/dev/null} 2>&1
;;
esac; shift
done
;;
# if "$_fasd_cur" or "$2" is a query, then output shell code to be eval'd
--word-complete-trigger)
shift; [ "$2" ] && local _fasd_cur="$2" || return
case $_fasd_cur in
,*) printf %s\\n "$1 e $_fasd_cur";;
f,*) printf %s\\n "$1 f ${_fasd_cur#?}";;
d,*) printf %s\\n "$1 d ${_fasd_cur#?}";;
*,,) printf %s\\n "$1 e $_fasd_cur";;
*,,f) printf %s\\n "$1 f ${_fasd_cur%?}";;
*,,d) printf %s\\n "$1 d ${_fasd_cur%?}";;
esac
;;
--sanitize) shift; printf %s\\n "$*" | \
sed 's/\([^\]\)$( *[^ ]* *\([^)]*\)))*/\1\2/g
s/\([^\]\)[|&;<>$`{}]\{1,\}/\1 /g'
;;
--proc) shift # process commands
# stop if we don't own $_FASD_DATA or $_FASD_RO is set
[ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return
# blacklists
local each; for each in $_FASD_BLACKLIST; do
case " $* " in *\ $each\ *) return;; esac
done
# shifts
while true; do
case " $_FASD_SHIFT " in
*\ $1\ *) shift;;
*) break;;
esac
done
# ignores
case " $_FASD_IGNORE " in
*\ $1\ *) return;;
esac
shift; fasd --add "$@" # add all arguments except command
;;
--add|-A) shift # add entries
# stop if we don't own $_FASD_DATA or $_FASD_RO is set
[ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return
# find all valid path arguments, convert them to simplest absolute form
local paths="$(while [ "$1" ]; do
[ -e "$1" ] && printf %s\\n "$1"; shift
done | sed '/^[^/]/s@^@'"$PWD"'/@
s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0
s@[^/][^/]*//*\.\./@/@;t 0
s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@;s@^$@/@' 2>> "$_FASD_SINK" \
| tr '\n' '|')"
# add current pwd if the option is set
[ "$_FASD_TRACK_PWD" = "1" -a "$PWD" != "$HOME" ] && paths="$paths|$PWD"
[ -z "${paths##\|}" ] && return # stop if we have nothing to add
# maintain the file
local tempfile
tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return
$_FASD_AWK -v list="$paths" -v now="$(date +%s)" -v max="$_FASD_MAX" -F"|" '
BEGIN {
split(list, files, "|")
for(i in files) {
path = files[i]
if(path == "") continue
paths[path] = path # array for checking
rank[path] = 1
time[path] = now
}
}
$2 >= 1 {
if($1 in paths) {
rank[$1] = $2 + 1 / $2
time[$1] = now
} else {
rank[$1] = $2
time[$1] = $3
}
count += $2
}
END {
if(count > max)
for(i in rank) print i "|" 0.9*rank[i] "|" time[i] # aging
else
for(i in rank) print i "|" rank[i] "|" time[i]
}' "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile"
if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then
env rm -f "$tempfile"
else
env mv -f "$tempfile" "$_FASD_DATA"
fi
;;
--delete|-D) shift # delete entries
# stop if we don't own $_FASD_DATA or $_FASD_RO is set
[ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return
# turn valid arguments into entry-deleting sed commands
local sed_cmd="$(while [ "$1" ]; do printf %s\\n "$1"; shift; done | \
sed '/^[^/]/s@^@'"$PWD"'/@;s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0
s@[^/][^/]*//*\.\./@/@;t 0
s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@
s@^$@/@;s@\([.[\/*^$]\)@\\\1@g;s@^\(.*\)$@/^\1|/d@' 2>> "$_FASD_SINK")"
# maintain the file
local tempfile
tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return
sed "$sed_cmd" "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile"
if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then
env rm -f "$tempfile"
else
env mv -f "$tempfile" "$_FASD_DATA"
fi
;;
--query) shift # query the db, --query [$typ ["$fnd" [$mode]]]
[ -f "$_FASD_DATA" ] || return # no db yet
[ "$1" ] && local typ="$1"
[ "$2" ] && local fnd="$2"
[ "$3" ] && local mode="$3"
# cat all backends
local each _fasd_data; for each in $_FASD_BACKENDS; do
_fasd_data="$_fasd_data
$(fasd --backend $each)"
done
[ "$_fasd_data" ] || _fasd_data="$(cat "$_FASD_DATA")"
# set mode specific code for calculating the prior
case $mode in
rank) local prior='times[i]';;
recent) local prior='sqrt(100000/(1+t-la[i]))';;
*) local prior='times[i] * frecent(la[i])';;
esac
if [ "$fnd" ]; then # dafault matching
local bre="$(printf %s\\n "$fnd" | sed 's/\([*\.\\\[]\)/\\\1/g
s@ @[^|]*@g;s/\$$/|/')"
bre='^[^|]*'"$bre"'[^|/]*|'
local _ret="$(printf %s\\n "$_fasd_data" | grep "$bre")"
[ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do
[ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line"
done)"
if [ "$_ret" ]; then
_fasd_data="$_ret"
else # no case mathcing
_ret="$(printf %s\\n "$_fasd_data" | grep -i "$bre")"
[ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do
[ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line"
done)"
if [ "$_ret" ]; then
_fasd_data="$_ret"
elif [ "${_FASD_FUZZY:-0}" -gt 0 ]; then # fuzzy matching
local fuzzy_bre="$(printf %s\\n "$fnd" | \
sed 's/\([*\.\\\[]\)/\\\1/g;s/\$$/|/
s@\(\\\{0,1\}[^ ]\)@\1[^|/]\\{0,'"$_FASD_FUZZY"'\\}@g
s@ @[^|]*@g')"
fuzzy_bre='^[^|]*'"$fuzzy_bre"'[^|/]*|'
_ret="$(printf %s\\n "$_fasd_data" | grep -i "$fuzzy_bre")"
[ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do
[ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line"
done)"
[ "$_ret" ] && _fasd_data="$_ret" || _fasd_data=
fi
fi
else # no query arugments
_fasd_data="$(printf %s\\n "$_fasd_data" | while read -r line; do
[ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line"
done)"
fi
# query the database
[ "$_fasd_data" ] && printf %s\\n "$_fasd_data" | \
$_FASD_AWK -v t="$(date +%s)" -F"|" '
function frecent(time) {
dx = t-time
if( dx < 3600 ) return 6
if( dx < 86400 ) return 4
if( dx < 604800 ) return 2
return 1
}
{
if(!paths[$1]) {
times[$1] = $2
la[$1] = $3
paths[$1] = 1
} else {
times[$1] += $2
if($3 > la[$1]) la[$1] = $3
}
}
END {
for(i in paths) printf "%-10s %s\n", '"$prior"', i
}' - 2>> "$_FASD_SINK"
;;
--backend)
case $2 in
native) cat "$_FASD_DATA";;
viminfo)
< "$_FASD_VIMINFO" sed -n '/^>/{s@~@'"$HOME"'@
s/^..//
p
}' | $_FASD_AWK -v t="$(date +%s)" '{
t -= 60
print $0 "|1|" t
}'
;;
recently-used)
local nl="$(printf '\\\nX')"; nl="${nl%X}" # slash newline for sed
tr -d '\n' < "$_FASD_RECENTLY_USED_XBEL" | \
sed 's@file:/@'"$nl"'@g;s@count="@'"$nl"'@g' | sed '1d;s/".*$//' | \
tr '\n' '|' | sed 's@|/@'"$nl"'@g' | $_FASD_AWK -F'|' '{
sum = 0
for( i=2; i<=NF; i++ ) sum += $i
print $1 "|" sum
}'
;;
current)
for path in *; do
printf "$PWD/%s|1\\n" "$path"
done
;;
spotlight)
mdfind '(kMDItemFSContentChangeDate >= $time.today) ||
kMDItemLastUsedDate >= $time.this_month' \
| sed '/Library\//d
/\.app$/d
s/$/|2/'
;;
*) eval "$2";;
esac
;;
*) # parsing logic and processing
local fnd= last= _FASD_BACKENDS="$_FASD_BACKENDS" _fasd_data= comp= exec=
while [ "$1" ]; do case $1 in
--complete) [ "$2" = "--" ] && shift; set -- $2; local lst=1 r=r comp=1;;
--query|--add|--delete|-A|-D) fasd "$@"; return $?;;
--version) [ -z "$comp" ] && echo "1.0.1" && return;;
--) while [ "$2" ]; do shift; fnd="$fnd $1"; last="$1"; done;;
-*) local o="${1#-}"; while [ "$o" ]; do case $o in
s*) local show=1;;
l*) local lst=1;;
i*) [ -z "$comp" ] && local interactive=1 show=1;;
r*) local mode=rank;;
t*) local mode=recent;;
e*) o="${o#?}"; if [ "$o" ]; then # there are characters after "-e"
local exec="$o" # anything after "-e"
else # use the next argument
local exec="${2:?"-e: Argument needed "}"
shift
fi; break;;
b*) o="${o#?}"; if [ "$o" ]; then
_FASD_BACKENDS="$o"
else
_FASD_BACKENDS="${2:?"-b: Argument needed"}"
shift
fi; break;;
B*) o="${o#?}"; if [ "$o" ]; then
_FASD_BACKENDS="$_FASD_BACKENDS $o"
else
_FASD_BACKENDS="$_FASD_BACKENDS ${2:?"-B: Argument needed"}"
shift
fi; break;;
a*) local typ=e;;
d*) local typ=d;;
f*) local typ=f;;
R*) local r=r;;
[0-9]*) local _fasd_i="$o"; break;;
h*) [ -z "$comp" ] && echo "fasd [options] [query ...]
[f|a|s|d|z] [options] [query ...]
options:
-s list paths with scores
-l list paths without scores
-i interactive mode
-e <cmd> set command to execute on the result file
-b <name> only use <name> backend
-B <name> add additional backend <name>
-a match files and directories
-d match directories only
-f match files only
-r match by rank only
-t match by recent access only
-R reverse listing order
-h show a brief help message
-[0-9] select the nth entry
fasd [-A|-D] [paths ...]
-A add paths
-D delete paths" >&2 && return;;
esac; o="${o#?}"; done;;
*) fnd="$fnd $1"; last="$1";;
esac; shift; done
# guess whether the last query is selected from tab completion
case $last in
/?*) if [ -z "$show$lst" -a -${typ:-e} "$last" -a "$exec" ]; then
$exec "$last"
return
fi;;
esac
local R; [ -z "$r" ] && R=r || R= # let $R be the opposite of $r
fnd="${fnd# }"
local res
res="$(fasd --query 2>> "$_FASD_SINK")" # query the database
[ $? -gt 0 ] && return
if [ 0 -lt ${_fasd_i:-0} ] 2>> "$_FASD_SINK"; then
res="$(printf %s\\n "$res" | sort -n${R} | \
sed -n "$_fasd_i"'s/^[^ ]*[ ]*//p')"
elif [ "$interactive" ] || [ "$exec" -a -z "$fnd$lst$show" -a -t 1 ]; then
if [ "$(printf %s "$res" | sed -n '$=')" -gt 1 ]; then
res="$(printf %s\\n "$res" | sort -n${R})"
printf %s\\n "$res" | sed = | sed 'N;s/\n/ /' | sort -nr >&2
printf "> " >&2
local i; read i; [ 0 -lt "${i:-0}" ] 2>> "$_FASD_SINK" || return 1
fi
res="$(printf %s\\n "$res" | sed -n "${i:-1}"'s/^[^ ]*[ ]*//p')"
elif [ "$lst" ]; then
[ "$res" ] && printf %s\\n "$res" | sort -n${r} | sed 's/^[^ ]*[ ]*//'
return
elif [ "$show" ]; then
[ "$res" ] && printf %s\\n "$res" | sort -n${r}
return
elif [ "$fnd" ] && [ "$exec" -o ! -t 1 ]; then # exec or subshell
res="$(printf %s\\n "$res" | sort -n | sed -n '$s/^[^ ]*[ ]*//p')"
else # no args, show
[ "$res" ] && printf %s\\n "$res" | sort -n${r}
return
fi
if [ "$res" ]; then
fasd --add "$res"
[ -z "$exec" ] && exec='printf %s\n'
$exec "$res"
fi
;;
esac
#case $- in
# *i*) ;; # assume being sourced, do nothing
# *) # assume being executed as an executable
# if [ -x "$_FASD_SHELL" -a -z "$_FASD_SET" ]; then
# _FASD_SET=1 exec $_FASD_SHELL "$0" "$@"
# else
# fasd "$@"
# fi;;
#esac

View file

@ -1,88 +0,0 @@
fasd --init env
# function to execute built-in cd
fasd_cd() {
if [ $# -le 1 ]; then
fasd "$@"
else
local _fasd_ret="$(fasd -e 'printf %s' "$@")"
[ -z "$_fasd_ret" ] && return
[ -d "$_fasd_ret" ] && cd "$_fasd_ret" || printf %s\n "$_fasd_ret"
fi
}
alias a='fasd -a'
alias s='fasd -si'
alias sd='fasd -sid'
alias sf='fasd -sif'
alias d='fasd -d'
alias f='fasd -f'
alias v='f -e vim -b viminfo'
alias z='fasd_cd -d'
alias zz='fasd_cd -d -i'
# add zsh hook
_fasd_preexec() {
{ eval "fasd --proc $(fasd --sanitize $2)"; } >> "/dev/null" 2>&1
}
autoload -Uz add-zsh-hook
add-zsh-hook preexec _fasd_preexec
# zsh command mode completion
_fasd_zsh_cmd_complete() {
local compl
read -c compl
(( $+compstate )) && compstate[insert]=menu # no expand if compsys loaded
reply=(${(f)"$(fasd --complete "$compl")"})
}
# enable command mode completion
compctl -U -K _fasd_zsh_cmd_complete -V fasd -x 'C[-1,-*e],s[-]n[1,e]' -c - \
'c[-1,-A][-1,-D]' -f -- fasd fasd_cd
(( $+functions[compdef] )) && {
# zsh word mode completion
_fasd_zsh_word_complete() {
[ "$2" ] && local _fasd_cur="$2"
[ -z "$_fasd_cur" ] && local _fasd_cur="${words[CURRENT]}"
local fnd="${_fasd_cur//,/ }"
local typ=${1:-e}
fasd --query $typ "$fnd" 2>> "/dev/null" | \
sort -nr | sed 's/^[^ ]*[ ]*//' | while read -r line; do
compadd -U -V fasd "$line"
done
compstate[insert]=menu # no expand
}
_fasd_zsh_word_complete_f() { _fasd_zsh_word_complete f ; }
_fasd_zsh_word_complete_d() { _fasd_zsh_word_complete d ; }
_fasd_zsh_word_complete_trigger() {
local _fasd_cur="${words[CURRENT]}"
eval $(fasd --word-complete-trigger _fasd_zsh_word_complete $_fasd_cur)
}
# define zle widgets
zle -C fasd-complete complete-word _generic
zstyle ':completion:fasd-complete:*' completer _fasd_zsh_word_complete
zstyle ':completion:fasd-complete:*' menu-select
zle -C fasd-complete-f complete-word _generic
zstyle ':completion:fasd-complete-f:*' completer _fasd_zsh_word_complete_f
zstyle ':completion:fasd-complete-f:*' menu-select
zle -C fasd-complete-d complete-word _generic
zstyle ':completion:fasd-complete-d:*' completer _fasd_zsh_word_complete_d
zstyle ':completion:fasd-complete-d:*' menu-select
}
(( $+functions[compdef] )) && {
# enable word mode completion
orig_comp="$(zstyle -L ':completion:\*' completer 2>> "/dev/null")"
if [ "$orig_comp" ]; then
case $orig_comp in
*_fasd_zsh_word_complete_trigger*);;
*) eval "$orig_comp _fasd_zsh_word_complete_trigger";;
esac
else
zstyle ':completion:*' completer _complete _fasd_zsh_word_complete_trigger
fi
unset orig_comp
}

View file

@ -1,129 +0,0 @@
git-info
========
Exposes git repository status information to prompts.
Many thanks to [Sorin Ionescu](https://github.com/sorin-ionescu) and
[Colin Hebert](https://github.com/ColinHebert) for the original code.
Git **1.7.2** is the
[minimum required version](https://github.com/sorin-ionescu/prezto/issues/219).
Settings
--------
### Ignore submodules
Retrieving the status of a repository with submodules can take a long time.
So by default 'all' submodules are ignored. Optionally, 'untracked', 'dirty', or
'none' submodules can be ignored:
zstyle ':zim:git-info' ignore-submodules 'none'
### Verbose mode
Verbose mode uses `git status` and computes the count of indexed, unindexed and
also untracked files. It can be enabled with the following zstyle:
zstyle ':zim:git-info' verbose yes
In non-verbose mode, the 'untracked' context is not available (see *Main
contexts* below), and untracked files are also not considered for computing the
'dirty' context. Using `git status` to check for untracked files can be
[expensive](https://gist.github.com/sindresorhus/3898739).
Theming
-------
To display information about the current repository in a prompt, define your
custom styles in the `prompt_name_setup` function, where the syntax for setting
a style is:
zstyle ':zim:git-info:context' format 'string'
### Main contexts
| Name | Code | Description
| --------- | :----: | ---------------------------------------------------------
| action | %s | Special action name (see *Special action contexts* below)
| ahead | %A | Commits ahead of remote count
| behind | %B | Commits behind of remote count
| diverged | %V | Diverged commits (both ahead and behind are yield when it's not defined)
| branch | %b | Branch name
| commit | %c | Commit short hash (when in 'detached HEAD' state)
| clean | %C | Clean state
| dirty | %D | Dirty state (count with untracked files when verbose mode enabled)
| indexed | %i | Indexed files (count when verbose mode enabled)
| unindexed | %I | Unindexed files (count when verbose mode enabled)