Updated Plugin Loading
This commit is contained in:
commit
1b10871913
|
@ -0,0 +1,26 @@
|
|||
Please check the existing issues to make sure you're not duplicating a report.
|
||||
|
||||
For bug reports, please provide the following information:
|
||||
|
||||
In a terminal, run `zmanage info` and paste the output below:
|
||||
|
||||
```
|
||||
#Paste the output here
|
||||
```
|
||||
|
||||
- gist of .zimrc:
|
||||
- gist of .zshrc:
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
|
||||
Steps to reproduce
|
||||
------------------
|
||||
|
||||
|
||||
Images or other information
|
||||
---------------------------
|
||||
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
Please follow Zim's [code style guidelines](https://github.com/zimfw/zimfw/wiki/Code-Style-Guide).
|
|
@ -0,0 +1,4 @@
|
|||
*.swp
|
||||
*.zwc
|
||||
*.zwc.old
|
||||
custom/
|
|
@ -0,0 +1,21 @@
|
|||
[submodule "modules/history-substring-search/external"]
|
||||
path = modules/history-substring-search/external
|
||||
url = https://github.com/zsh-users/zsh-history-substring-search.git
|
||||
[submodule "modules/completion/external"]
|
||||
path = modules/completion/external
|
||||
url = https://github.com/zsh-users/zsh-completions.git
|
||||
[submodule "modules/syntax-highlighting/external"]
|
||||
path = modules/syntax-highlighting/external
|
||||
url = https://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||
[submodule "modules/prompt/external-themes/pure"]
|
||||
path = modules/prompt/external-themes/pure
|
||||
url = https://github.com/sindresorhus/pure.git
|
||||
[submodule "modules/prompt/external-themes/liquidprompt"]
|
||||
path = modules/prompt/external-themes/liquidprompt
|
||||
url = https://github.com/nojhan/liquidprompt.git
|
||||
[submodule "modules/prompt/external-themes/lean"]
|
||||
path = modules/prompt/external-themes/lean
|
||||
url = https://github.com/miekg/lean
|
||||
[submodule "modules/autosuggestions/external"]
|
||||
path = modules/autosuggestions/external
|
||||
url = https://github.com/zsh-users/zsh-autosuggestions.git
|
|
@ -0,0 +1,25 @@
|
|||
The MIT License (MIT)
|
||||
=====================
|
||||
|
||||
Copyright (c) `2015-2016` `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.
|
|
@ -0,0 +1,104 @@
|
|||
ZIM - Zsh IMproved
|
||||
==================
|
||||
|
||||
<div align="center">
|
||||
<a href="https://github.com/zimfw/zimfw">
|
||||
<img width=650px src="https://i.eriner.me/zim_banner.png">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
What is Zim?
|
||||
------------
|
||||
Zim is a Zsh configuration framework with [blazing speed][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]!
|
||||
|
||||
Below is a brief showcase of Zim's features.
|
||||
|
||||
### Speed
|
||||
For a speed comparison between Zim and other frameworks, see [this wiki entry][speed].
|
||||
|
||||
### Themes
|
||||
|
||||
To preview some of the available themes, check the [themes wiki page][themes].
|
||||
|
||||
### Fish-shell History Navigation
|
||||
![history-substring-search][fish_shell]
|
||||
|
||||
### 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:
|
||||
|
||||
1. In a Zsh shell, clone the repository:
|
||||
```
|
||||
git clone --recursive https://github.com/zimfw/zimfw.git ${ZDOTDIR:-${HOME}}/.zim
|
||||
```
|
||||
|
||||
2. Paste this into your terminal to prepend the initialization templates to your configs:
|
||||
```
|
||||
setopt EXTENDED_GLOB
|
||||
for template_file ( ${ZDOTDIR:-${HOME}}/.zim/templates/* ); do
|
||||
user_file="${ZDOTDIR:-${HOME}}/.${template_file:t}"
|
||||
touch ${user_file}
|
||||
( print -rn "$(<${template_file})$(<${user_file})" >! ${user_file} ) 2>/dev/null
|
||||
done
|
||||
```
|
||||
|
||||
3. Set Zsh as the default shell:
|
||||
```
|
||||
chsh -s =zsh
|
||||
```
|
||||
|
||||
4. Open a new terminal and finish optimization (this is only needed once, hereafter it will happen upon desktop/tty login):
|
||||
```
|
||||
source ${ZDOTDIR:-${HOME}}/.zlogin
|
||||
```
|
||||
|
||||
5. You're done! Enjoy your Zsh IMproved! Take some time to read about the [available modules][modules] and tweak your `.zshrc` file.
|
||||
|
||||
Updating
|
||||
--------
|
||||
|
||||
To update zim, run:
|
||||
|
||||
```
|
||||
zmanage update
|
||||
```
|
||||
|
||||
For more information about the `zmanage` tool, see the [meta module][meta-module] documentation.
|
||||
|
||||
Uninstalling
|
||||
------------
|
||||
|
||||
The best way to remove zim is to manually delete `~/.zim`, `~/.zimrc`, and
|
||||
remove the initialization lines from your `~/.zshrc`.
|
||||
|
||||
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://i.eriner.me/zim_history-substring-search.gif
|
||||
[syntax_highlighting]: https://i.eriner.me/zim_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
|
||||
[meta-module]: https://github.com/zimfw/zimfw/tree/master/modules/meta
|
|
@ -0,0 +1,89 @@
|
|||
#
|
||||
# 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
|
||||
|
||||
# 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|README*|*.zwc|*.zwc.old)(-.N:t); do
|
||||
autoload -Uz ${mod_function}
|
||||
done
|
||||
}
|
||||
|
||||
# Initialize modules
|
||||
() {
|
||||
local zmodule
|
||||
for zmodule (${zmodules}); do
|
||||
local zmodule_dir=${ZIM_HOME}/modules/${zmodule}
|
||||
if [[ ! -d ${zmodule_dir} ]]; then
|
||||
print "No such module \"${zmodule}\"." >&2
|
||||
else
|
||||
for zmodule_file (${zmodule_dir}/{,zsh-}${zmodule}.zsh-theme \
|
||||
${zmodule_dir}/init.zsh \
|
||||
${zmodule_dir}/{,zsh-}${zmodule}.plugin.zsh \
|
||||
${zmodule_dir}/{,zsh-}${zmodule}.{z,}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
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
|
||||
|
||||
#
|
||||
# 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|README*|*.zwc|*.zwc.old)(-.N)
|
||||
done
|
||||
|
||||
# zcompile enabled module init scripts
|
||||
local zmodule
|
||||
for zmodule (${zmodules}); do
|
||||
local zmodule_dir=${ZIM_HOME}/modules/${zmodule}
|
||||
if [[ -d ${zmodule_dir} ]]; then
|
||||
for zmodule_file (${zmodule_dir}/{,zsh-}${zmodule}.zsh-theme \
|
||||
${zmodule_dir}/init.zsh \
|
||||
${zmodule_dir}/{,zsh-}${zmodule}.plugin.zsh \
|
||||
${zmodule_dir}/{,zsh-}${zmodule}.{z,}sh); do
|
||||
if [[ -f ${zmodule_file} ]]; then
|
||||
zrecompile -pq ${zmodule_file}
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
# zcompile all prompt setup scripts
|
||||
for file in ${ZIM_HOME}/modules/prompt/functions/prompt_*_setup; do
|
||||
zrecompile -pq ${file}
|
||||
done
|
||||
|
||||
# syntax-highlighting
|
||||
for file in ${ZIM_HOME}/modules/syntax-highlighting/external/highlighters/**^test-data/*.zsh; do
|
||||
zrecompile -pq ${file}
|
||||
done
|
||||
zrecompile -pq ${ZIM_HOME}/modules/syntax-highlighting/external/zsh-syntax-highlighting.zsh
|
||||
|
||||
# zsh-histery-substring-search
|
||||
zrecompile -pq ${ZIM_HOME}/modules/history-substring-search/external/zsh-history-substring-search.zsh
|
||||
|
||||
) &!
|
|
@ -0,0 +1,31 @@
|
|||
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 a file based on the extension. Syntax is `unarchive myarchive.7z`
|
||||
|
||||
Archive Formats
|
||||
---------------
|
||||
|
||||
| Format | Requirements |
|
||||
| ------ | ------------ |
|
||||
| .tar | `tar` |
|
||||
| .tar.gz, .tgz | `tar` or `pigz` |
|
||||
| .tar.bz2, .tbz | `tar` or `pbzip2` |
|
||||
| .tar.xz, .txz | `tar` with xz support |
|
||||
| .tar.zma, .tlz | `tar` with lzma support |
|
||||
| .gz | `gunzip` or `pigz` |
|
||||
| .bz2 | `bunzip2` or `pbzip2` |
|
||||
| .xz | `unxz` |
|
||||
| .lzma | `unzlma` |
|
||||
| .Z | `uncompress` |
|
||||
| .zip | `unzip` |
|
||||
| .rar | `unrar` or `rar` |
|
||||
| .7z | `7za` |
|
|
@ -0,0 +1,4 @@
|
|||
#compdef unarchive
|
||||
|
||||
_arguments \
|
||||
":archive:_files -g '(#i)*.(tar|gz|tgz|bz2|tbz|tbz2|xz|txz|tlz|lzma|Z|zip|rar|7z|001)(-.)'"
|
|
@ -0,0 +1,41 @@
|
|||
#
|
||||
# Creates archive files
|
||||
#
|
||||
|
||||
if (( ${#} != 2 )); then
|
||||
print "usage: ${0} [archive_name.ext] [/path/to/include/in/archive]" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# we are quitting (above) if there are not exactly 2 vars,
|
||||
# so we don't need any argc check here.
|
||||
|
||||
# strip the path, just in case one is provided for some reason
|
||||
local archive_name="${1:t}"
|
||||
# use absolute paths, and follow symlinks
|
||||
local dir_to_archive="${2}"
|
||||
|
||||
# if the directory doesn't exist, quit. Nothing to archive
|
||||
if [[ ! -e "${dir_to_archive}" ]]; then
|
||||
print "${0}: file or directory not valid: ${dir_to_archive}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# 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 -cvf "${archive_name}" --use-compress-program="gzip" "${dir_to_archive}" ;;
|
||||
(*.tar.bz2|*.tbz|*.tbz2) tar -cvf "${archive_name}" --use-compress-program="bzip2" "${dir_to_archive}" ;;
|
||||
(*.tar.xz|*.txz) tar --xz --help &>/dev/null && tar -cvJf "${archive_name}" "${dir_to_archive}" ;;
|
||||
(*.tar.lzma|*.tlz) tar --lzma --help &>/dev/null && tar -cvf "${archive_name}" --lzma "${dir_to_archive}" ;;
|
||||
(*.tar) tar -cvf "${archive_name}" "${dir_to_archive}" ;;
|
||||
(*.zip) zip -r "${archive_name}" "${dir_to_archive}" ;;
|
||||
(*.rar) rar a "${archive_name}" "${dir_to_archive}" ;;
|
||||
(*.7z) 7za a "${archive_name}" "${dir_to_archive}" ;;
|
||||
(*.gz) print "${0}: .gz is only useful for single files, and does not capture permissions. Use .tar.gz" ;;
|
||||
(*.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
|
|
@ -0,0 +1,39 @@
|
|||
#
|
||||
# Unarchives files
|
||||
#
|
||||
|
||||
if (( ${#} != 1 )); then
|
||||
print "usage: ${0} [archive.ext]" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ ! -s ${1} ]]; then
|
||||
print "archive \"${1}\" was not found or has size 0." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# strip the path, just in case one is provided for some reason
|
||||
local archive_name="${1:t}"
|
||||
|
||||
# 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.
|
||||
|
||||
case "${archive_name}" in
|
||||
(*.tar.gz|*.tgz) tar -xvzf "${archive_name}" ;;
|
||||
(*.tar.bz2|*.tbz|*.tbz2) tar -xvjf "${archive_name}" ;;
|
||||
(*.tar.xz|*.txz) tar --xz --help &>/dev/null && tar --xz -xvf "${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}" ;;
|
||||
(*.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}" ;;
|
||||
esac
|
|
@ -0,0 +1,17 @@
|
|||
#
|
||||
# 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'
|
|
@ -0,0 +1,13 @@
|
|||
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)
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 15931f04ffac91a2f9a1a044b6b3ee4050751064
|
|
@ -0,0 +1,9 @@
|
|||
#
|
||||
# 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
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
Completion
|
||||
==========
|
||||
|
||||
Enables and configures smart and extensive tab completion.
|
||||
|
||||
Completions are sourced from [zsh-completions](https://github.com/zsh-users/zsh-completions).
|
||||
|
||||
This should be the **LAST** module in the `zmodules` list in your `.zimrc`.
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Command completions should be submitted [upstream to zsh-completions](https://github.com/zsh-users/zsh-completions).
|
|
@ -0,0 +1,14 @@
|
|||
#
|
||||
# Alias compdefs
|
||||
#
|
||||
|
||||
# Any aliased commands will not function with completion without compdefs.
|
||||
# Because completion is the LAST module to be loaded (so we make sure to catch all completions)
|
||||
# we must assign the compdefs here, as opposed to within the modules themselves.
|
||||
|
||||
# Unfortunately, I'm not aware of a worthwhile way to ensure that these will be included in .zcompdump
|
||||
|
||||
# zpacman_frontend -> pacman
|
||||
if (( ${+zpacman_frontend} )); then
|
||||
compdef ${zpacman_frontend}='pacman'
|
||||
fi
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 7ec52769d3a0dd505d33d857511866d2b90d0eec
|
|
@ -0,0 +1,91 @@
|
|||
#
|
||||
# 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}"
|
||||
|
||||
# set any compdefs
|
||||
source ${0:h}/compdefs.zsh
|
||||
|
||||
|
||||
#
|
||||
# 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.
|
||||
unsetopt CASE_GLOB
|
||||
|
||||
# Don't beep on an ambiguous completion.
|
||||
unsetopt 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
|
||||
local case_insensitive='m:{a-zA-Z}={A-Za-z}'
|
||||
zstyle ':completion:*' matcher-list ${case_insensitive} "${case_insensitive} r:|?=**"
|
||||
|
||||
# directories
|
||||
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'
|
|
@ -0,0 +1,18 @@
|
|||
Custom
|
||||
======
|
||||
|
||||
Add any custom aliases/settings to the `init.zsh` file.
|
||||
|
||||
Any functions should go in the `functions` folder, where the name of the file is the name of the function.
|
||||
|
||||
For example, this function from your .zshrc:
|
||||
```
|
||||
foo() {
|
||||
print 'bar'
|
||||
}
|
||||
```
|
||||
|
||||
becomes a file named 'foo' in the functions folder containing:
|
||||
```
|
||||
print 'bar'
|
||||
```
|
|
@ -0,0 +1,4 @@
|
|||
# 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!"
|
|
@ -0,0 +1,8 @@
|
|||
#
|
||||
# Custom aliases/settings
|
||||
#
|
||||
|
||||
# any custom stuff should go here.
|
||||
# ensure that 'custom' exists in the zmodules array in your .zimrc
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
Debug
|
||||
=====
|
||||
|
||||
Provides a function to debug Zim.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
- `trace-zim` provides a trace of Zsh/Zim startup
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
The `trace-zim` command 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.
|
|
@ -0,0 +1,105 @@
|
|||
#!/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"
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
Directory
|
||||
=========
|
||||
|
||||
Sets directory, navigation, and redirect options.
|
||||
|
||||
ZSH options
|
||||
-----------
|
||||
|
||||
| Option | Effect |
|
||||
| ------ | ----------- |
|
||||
| AUTO_CD | If the typed command is invalid, but is a directory, cd to that directory |
|
||||
| AUTO_PUSHD | After cd, push the old directory to the directory stack |
|
||||
| PUSHD_IGNORE_DUPS | Don't push multiple copies of the same directory to the stack |
|
||||
| PUSHD_SILENT | Don't print the directory after pushd or popd |
|
||||
| PUSHD_TO_HOME | pushd without arguments acts like `pushd ${HOME}` |
|
||||
| EXTENDED_GLOB | Treat `#`, `~`, and `^` as patterns for filename globbing |
|
||||
| MULTIOS | Performs implicit tees or cats when using redirections |
|
||||
| NO_CLOBBER | Disables overwrite existing files with `>`. Use `>|` or `>!` instead |
|
|
@ -0,0 +1,38 @@
|
|||
#
|
||||
# Directory navigation options
|
||||
#
|
||||
|
||||
#
|
||||
# Navigation
|
||||
#
|
||||
|
||||
# If a command is issued that can’t 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
|
||||
|
||||
# Don’t 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
|
|
@ -0,0 +1,21 @@
|
|||
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
|
||||
-----------
|
||||
|
||||
| Option | Effect |
|
||||
| ------ | ------ |
|
||||
| AUTO_RESUME | Resume existing jobs before creating a new job |
|
||||
| LONG_LIST_JOBS | Use the verbose list format by default |
|
||||
| NOTIFY | Report job status immediately instead of waiting for new prompt |
|
||||
| INTERACTIVE_COMMENTS | Recognize comments starting with `#` |
|
||||
| BG_NICE | Disabled to prevent jobs being given a lower priority |
|
||||
| HUP | Disabed to prevent SIGHUP to jobs on shell close |
|
||||
| CHECK_JOBS | Disabled to prevent job report on shell close |
|
|
@ -0,0 +1,55 @@
|
|||
#
|
||||
# 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
|
||||
|
||||
# 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
|
||||
|
||||
# Recognize comments starting with `#`.
|
||||
setopt INTERACTIVE_COMMENTS
|
||||
|
||||
# Run all background jobs at a lower priority. This option is set by default.
|
||||
unsetopt BG_NICE
|
||||
|
||||
# Send the HUP signal to running jobs when the shell exits.
|
||||
unsetopt HUP
|
||||
|
||||
# Report the status of background and suspended jobs before exiting a shell with job control;
|
||||
# a second attempt to exit the shell will succeed.
|
||||
# NO_CHECK_JOBS is best used only in combination with NO_HUP, else such jobs will be killed automatically.
|
||||
unsetopt CHECK_JOBS
|
||||
|
||||
# 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
|
|
@ -0,0 +1,14 @@
|
|||
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).
|
|
@ -0,0 +1,424 @@
|
|||
# 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
|
|
@ -0,0 +1,88 @@
|
|||
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
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
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.
|
||||
Submodules may be ignored when 'none', 'untracked', 'dirty', or 'all', which is
|
||||
the default.
|
||||
|
||||
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` or checking 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)
|
||||
| position | %p | Commits from nearest tag count (when in 'detached HEAD' state)
|
||||
| remote | %R | Remote name
|
||||
| stashed | %S | Stashed states count
|
||||
| untracked | %u | Untracked files count (only when verbose mode enabled)
|
||||
|
||||
While `commit` and `position` are only available when in ['detached HEAD'
|
||||
state](http://gitfaq.org/articles/what-is-a-detached-head.html), on the other
|
||||
hand, `ahead`, `behind`, `diverged`, `branch` and `remote` are only available
|
||||
when an actual branch is checked out (so when **not** in 'detached HEAD' state).
|
||||
|
||||
### Special Action Contexts
|
||||
|
||||
| Name | Format | Default Value
|
||||
| --------------------------- | :-----: | -------------------------------------
|
||||
| action:apply | value | 'apply'
|
||||
| action:bisect | value | 'bisect'
|
||||
| action:cherry-pick | value | 'cherry-pick'
|
||||
| action:cherry-pick-sequence | value | 'cherry-pick-sequence'
|
||||
| action:merge | value | 'merge'
|
||||
| action:rebase | value | 'rebase'
|
||||
| action:rebase-interactive | value | 'rebase-interactive'
|
||||
| action:rebase-merge | value | 'rebase-merge'
|
||||
|
||||
Formatting example for special actions:
|
||||
|
||||
zstyle ':zim:git-info:action:bisect' format '<B>'
|
||||
zstyle ':zim:git-info:action:merge' format '>M<'
|
||||
zstyle ':zim:git-info:action:rebase' format '>R>'
|
||||
|
||||
### Usage
|
||||
|
||||
First, format the repository state attributes. For example, to format the
|
||||
branch name, commit, and remote name, define the following styles:
|
||||
|
||||
zstyle ':zim:git-info:branch' format 'branch:%b'
|
||||
zstyle ':zim:git-info:commit' format 'commit:%c'
|
||||
zstyle ':zim:git-info:remote' format 'remote:%R'
|
||||
|
||||
Second, format how the above attributes are displayed in prompts:
|
||||
|
||||
zstyle ':zim:git-info:keys' format \
|
||||
'prompt' 'git(%b%c)' \
|
||||
'rprompt' '[%R]'
|
||||
|
||||
Last, add `$git_info[prompt]` to `$PROMPT` and `$git_info[rprompt]` to
|
||||
`$RPROMPT` respectively and call `git-info` in the `prompt_name_precmd` hook
|
||||
function.
|
|
@ -0,0 +1,6 @@
|
|||
# Prints the first non-empty string in the arguments array.
|
||||
for arg in ${argv}; do
|
||||
print -n ${arg}
|
||||
return 0
|
||||
done
|
||||
return 1
|
|
@ -0,0 +1,312 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
#
|
||||
# Exposes Git repository information via the git_info associative array.
|
||||
#
|
||||
|
||||
# Extended globbing is needed to parse repository status.
|
||||
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
||||
|
||||
# Clean up previous git_info.
|
||||
unset git_info
|
||||
typeset -gA git_info
|
||||
|
||||
# Return if not inside a Git repository work tree.
|
||||
if ! command git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Ignore submodule status.
|
||||
local ignore_submodules
|
||||
zstyle -s ':zim:git-info' ignore-submodules 'ignore_submodules' || ignore_submodules='all'
|
||||
|
||||
# Format stashed.
|
||||
local stashed_format stashed_formatted
|
||||
zstyle -s ':zim:git-info:stashed' format 'stashed_format'
|
||||
if [[ -n ${stashed_format} ]]; then
|
||||
local -i stashed=$(command git stash list 2>/dev/null | wc -l)
|
||||
(( stashed )) && zformat -f stashed_formatted ${stashed_format} "S:${stashed}"
|
||||
fi
|
||||
|
||||
# Format action.
|
||||
local action_format action_formatted
|
||||
zstyle -s ':zim:git-info:action' format 'action_format'
|
||||
if [[ -n ${action_format} ]]; then
|
||||
# Gets the Git special action (am, bisect, cherry, merge, rebase).
|
||||
# Borrowed from vcs_info and edited.
|
||||
git-action() {
|
||||
local git_dir=${$(command git rev-parse --git-dir):A}
|
||||
local action_dir
|
||||
for action_dir in \
|
||||
"${git_dir}/rebase-apply" \
|
||||
"${git_dir}/rebase" \
|
||||
"${git_dir}/../.dotest"
|
||||
do
|
||||
if [[ -d ${action_dir} ]]; then
|
||||
local apply_formatted rebase_formatted
|
||||
zstyle -s ':zim:git-info:action:apply' format 'apply_formatted' || apply_formatted='apply'
|
||||
zstyle -s ':zim:git-info:action:rebase' format 'rebase_formatted' || rebase_formatted='rebase'
|
||||
|
||||
if [[ -f "${action_dir}/rebasing" ]]; then
|
||||
print ${rebase_formatted}
|
||||
elif [[ -f "${action_dir}/applying" ]]; then
|
||||
print ${apply_formatted}
|
||||
else
|
||||
print "${rebase_formatted}/${apply_formatted}"
|
||||
fi
|
||||
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
for action_dir in \
|
||||
"${git_dir}/rebase-merge/interactive" \
|
||||
"${git_dir}/.dotest-merge/interactive"
|
||||
do
|
||||
if [[ -f ${action_dir} ]]; then
|
||||
local rebase_interactive_formatted
|
||||
zstyle -s ':zim:git-info:action:rebase-interactive' format 'rebase_interactive_formatted' || rebase_interactive_formatted='rebase-interactive'
|
||||
print ${rebase_interactive_formatted}
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
for action_dir in \
|
||||
"${git_dir}/rebase-merge" \
|
||||
"${git_dir}/.dotest-merge"
|
||||
do
|
||||
if [[ -d ${action_dir} ]]; then
|
||||
local rebase_merge_formatted
|
||||
zstyle -s ':zim:git-info:action:rebase-merge' format 'rebase_merge_formatted' || rebase_merge_formatted='rebase-merge'
|
||||
print ${rebase_merge_formatted}
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -f "${git_dir}/MERGE_HEAD" ]]; then
|
||||
local merge_formatted
|
||||
zstyle -s ':zim:git-info:action:merge' format 'merge_formatted' || merge_formatted='merge'
|
||||
print ${merge_formatted}
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f "${git_dir}/CHERRY_PICK_HEAD" ]]; then
|
||||
if [[ -d "${git_dir}/sequencer" ]]; then
|
||||
local cherry_pick_sequence_formatted
|
||||
zstyle -s ':zim:git-info:action:cherry-pick-sequence' format 'cherry_pick_sequence_formatted' || cherry_pick_sequence_formatted='cherry-pick-sequence'
|
||||
print ${cherry_pick_sequence_formatted}
|
||||
else
|
||||
local cherry_pick_formatted
|
||||
zstyle -s ':zim:git-info:action:cherry-pick' format 'cherry_pick_formatted' || cherry_pick_formatted='cherry-pick'
|
||||
print ${cherry_pick_formatted}
|
||||
fi
|
||||
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f "${git_dir}/BISECT_LOG" ]]; then
|
||||
local bisect_formatted
|
||||
zstyle -s ':zim:git-info:action:bisect' format 'bisect_formatted' || bisect_formatted='bisect'
|
||||
print ${bisect_formatted}
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
local action=$(git-action)
|
||||
if [[ -n ${action} ]]; then
|
||||
zformat -f action_formatted ${action_format} "s:${action}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# The contents of git_info are subject to expansion by the shell. Avoid
|
||||
# putting raw ref names in the prompt to protect the user from arbitrary code
|
||||
# execution via specially crafted ref names (e.g., a ref named
|
||||
# '$(IFS=_;cmd=sudo_rm_-rf_/;$cmd)' would execute 'sudo rm -rf /' when the
|
||||
# prompt is drawn). Instead, put the ref names in new global variables and
|
||||
# reference these variables from git_info.
|
||||
# See https://github.com/njhartwell/pw3nage
|
||||
|
||||
# Get the branch.
|
||||
__GIT_INFO_BRANCH=$(command git symbolic-ref -q --short HEAD 2>/dev/null)
|
||||
|
||||
local ahead_formatted behind_formatted branch_formatted commit_formatted diverged_formatted position_formatted remote_formatted
|
||||
if [[ -n ${__GIT_INFO_BRANCH} ]]; then
|
||||
unset __GIT_INFO_POSITION
|
||||
|
||||
# Format branch.
|
||||
local branch_format
|
||||
zstyle -s ':zim:git-info:branch' format 'branch_format'
|
||||
if [[ -n ${branch_format} ]]; then
|
||||
zformat -f branch_formatted ${branch_format} 'b:${__GIT_INFO_BRANCH}'
|
||||
fi
|
||||
|
||||
# Format remote.
|
||||
local remote_format
|
||||
zstyle -s ':zim:git-info:remote' format 'remote_format'
|
||||
if [[ -n ${remote_format} ]]; then
|
||||
# Gets the remote name.
|
||||
local remote_cmd='command git rev-parse --symbolic-full-name --verify HEAD@{upstream}'
|
||||
__GIT_INFO_REMOTE=${$(${(z)remote_cmd} 2>/dev/null)##refs/remotes/}
|
||||
if [[ -n ${__GIT_INFO_REMOTE} ]]; then
|
||||
zformat -f remote_formatted ${remote_format} 'R:${__GIT_INFO_REMOTE}'
|
||||
else
|
||||
unset __GIT_INFO_REMOTE
|
||||
fi
|
||||
fi
|
||||
|
||||
local ahead_format behind_format diverged_format
|
||||
zstyle -s ':zim:git-info:ahead' format 'ahead_format'
|
||||
zstyle -s ':zim:git-info:behind' format 'behind_format'
|
||||
zstyle -s ':zim:git-info:diverged' format 'diverged_format'
|
||||
if [[ -n ${ahead_format} || -n ${behind_format} || -n ${diverged_format} ]]; then
|
||||
# Gets the commit difference counts between local and remote.
|
||||
local ahead_and_behind_cmd='command git rev-list --count --left-right HEAD...@{upstream}'
|
||||
|
||||
# Get ahead and behind counts.
|
||||
local ahead_and_behind=$(${(z)ahead_and_behind_cmd} 2>/dev/null)
|
||||
local -i ahead=${ahead_and_behind[(w)1]}
|
||||
local -i behind=${ahead_and_behind[(w)2]}
|
||||
|
||||
if [[ -n ${diverged_format} && ${ahead} -gt 0 && ${behind} -gt 0 ]]; then
|
||||
# Format diverged.
|
||||
diverged_formatted=${diverged_format}
|
||||
else
|
||||
# Format ahead.
|
||||
if [[ -n ${ahead_format} && ${ahead} -gt 0 ]]; then
|
||||
zformat -f ahead_formatted ${ahead_format} "A:${ahead}"
|
||||
fi
|
||||
# Format behind.
|
||||
if [[ -n ${behind_format} && ${behind} -gt 0 ]]; then
|
||||
zformat -f behind_formatted ${behind_format} "B:${behind}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
unset __GIT_INFO_BRANCH
|
||||
unset __GIT_INFO_REMOTE
|
||||
|
||||
# Format commit.
|
||||
local commit_format
|
||||
zstyle -s ':zim:git-info:commit' format 'commit_format'
|
||||
if [[ -n ${commit_format} ]]; then
|
||||
local commit=$(command git rev-parse --short HEAD 2>/dev/null)
|
||||
if [[ -n ${commit} ]]; then
|
||||
zformat -f commit_formatted ${commit_format} "c:${commit}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Format position.
|
||||
local position_format
|
||||
zstyle -s ':zim:git-info:position' format 'position_format'
|
||||
if [[ -n ${position_format} ]]; then
|
||||
__GIT_INFO_POSITION=$(command git describe --contains --all HEAD 2>/dev/null)
|
||||
if [[ -n ${__GIT_INFO_POSITION} ]]; then
|
||||
zformat -f position_formatted ${position_format} 'p:${__GIT_INFO_POSITION}'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Dirty and clean format.
|
||||
local dirty_format dirty_formatted clean_format clean_formatted
|
||||
zstyle -s ':zim:git-info:dirty' format 'dirty_format'
|
||||
zstyle -s ':zim:git-info:clean' format 'clean_format'
|
||||
|
||||
local -i dirty
|
||||
local indexed_formatted unindexed_formatted untracked_formatted
|
||||
if ! zstyle -t ':zim:git-info' verbose; then
|
||||
# Format unindexed.
|
||||
local unindexed_format
|
||||
zstyle -s ':zim:git-info:unindexed' format 'unindexed_format'
|
||||
if [[ -n ${unindexed_format} || -n ${dirty_format} || -n ${clean_format} ]]; then
|
||||
if ! command git diff-files --no-ext-diff --quiet --ignore-submodules=${ignore_submodules} >/dev/null 2>&1; then
|
||||
unindexed_formatted=${unindexed_format}
|
||||
dirty=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Format indexed.
|
||||
local indexed_format
|
||||
zstyle -s ':zim:git-info:indexed' format 'indexed_format'
|
||||
if [[ -n ${indexed_format} || (${dirty} -eq 0 && (-n ${dirty_format} || -n ${clean_format})) ]]; then
|
||||
if ! command git diff-index --no-ext-diff --quiet --cached --ignore-submodules=${ignore_submodules} HEAD >/dev/null 2>&1; then
|
||||
indexed_formatted=${indexed_format}
|
||||
dirty=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Format dirty and clean.
|
||||
if (( dirty )); then
|
||||
dirty_formatted=${dirty_format}
|
||||
else
|
||||
clean_formatted=${clean_format}
|
||||
fi
|
||||
else
|
||||
# Use porcelain status for easy parsing.
|
||||
local status_cmd="command git status --porcelain --ignore-submodules=${ignore_submodules}"
|
||||
|
||||
local -i indexed unindexed untracked
|
||||
# Get current status.
|
||||
while IFS=$'\n' read line; do
|
||||
if [[ ${line:0:2} == '??' ]]; then
|
||||
(( untracked++ ))
|
||||
else
|
||||
[[ ${line:0:1} != ' ' ]] && (( indexed++ ))
|
||||
[[ ${line:1:1} != ' ' ]] && (( unindexed++ ))
|
||||
fi
|
||||
(( dirty++ ))
|
||||
done < <(${(z)status_cmd} 2>/dev/null)
|
||||
|
||||
# Format indexed.
|
||||
if (( indexed )); then
|
||||
local indexed_format
|
||||
zstyle -s ':zim:git-info:indexed' format 'indexed_format'
|
||||
zformat -f indexed_formatted ${indexed_format} "i:${indexed}"
|
||||
fi
|
||||
|
||||
# Format unindexed.
|
||||
if (( unindexed )); then
|
||||
local unindexed_format
|
||||
zstyle -s ':zim:git-info:unindexed' format 'unindexed_format'
|
||||
zformat -f unindexed_formatted ${unindexed_format} "I:${unindexed}"
|
||||
fi
|
||||
|
||||
# Format untracked.
|
||||
if (( untracked )); then
|
||||
local untracked_format
|
||||
zstyle -s ':zim:git-info:untracked' format 'untracked_format'
|
||||
zformat -f untracked_formatted ${untracked_format} "u:${untracked}"
|
||||
fi
|
||||
|
||||
# Format dirty and clean.
|
||||
if (( dirty )); then
|
||||
zformat -f dirty_formatted ${dirty_format} "u:${dirty}"
|
||||
else
|
||||
clean_formatted=${clean_format}
|
||||
fi
|
||||
fi
|
||||
|
||||
# Format info.
|
||||
local -A info_formats
|
||||
local info_format reply
|
||||
zstyle -a ':zim:git-info:keys' format 'info_formats'
|
||||
for info_format in ${(k)info_formats}; do
|
||||
zformat -f reply "${info_formats[${info_format}]}" \
|
||||
"A:${ahead_formatted}" \
|
||||
"B:${behind_formatted}" \
|
||||
"b:${branch_formatted}" \
|
||||
"C:${clean_formatted}" \
|
||||
"c:${commit_formatted}" \
|
||||
"D:${dirty_formatted}" \
|
||||
"i:${indexed_formatted}" \
|
||||
"I:${unindexed_formatted}" \
|
||||
"p:${position_formatted}" \
|
||||
"R:${remote_formatted}" \
|
||||
"s:${action_formatted}" \
|
||||
"S:${stashed_formatted}" \
|
||||
"u:${untracked_formatted}" \
|
||||
"V:${diverged_formatted}"
|
||||
git_info[${info_format}]=${reply}
|
||||
done
|
||||
|
||||
return 0
|
|
@ -0,0 +1,227 @@
|
|||
Git
|
||||
===
|
||||
|
||||
Provides nice git aliases and functions.
|
||||
|
||||
Many thanks to [Sorin Ionescu](https://github.com/sorin-ionescu) for the
|
||||
excellent aliases.
|
||||
|
||||
Aliases
|
||||
-------
|
||||
|
||||
### Git
|
||||
|
||||
- `g` is short for `git`.
|
||||
|
||||
### Branch
|
||||
|
||||
- `gb` lists, creates, renames, and deletes branches.
|
||||
- `gbc` creates a new branch.
|
||||
- `gbl` lists branches and their commits.
|
||||
- `gbL` lists local and remote branches and their commits.
|
||||
- `gbm` renames a branch.
|
||||
- `gbM` renames a branch even if the new branch name already exists.
|
||||
- `gbs` lists branches and their commits with ancestry graphs.
|
||||
- `gbS` lists local and remote branches and their commits with ancestry
|
||||
graphs.
|
||||
- `gbx` deletes a branch.
|
||||
- `gbX` deletes a branch irrespective of its merged status.
|
||||
|
||||
### Commit
|
||||
|
||||
- `gc` records changes to the repository.
|
||||
- `gca` commits all modified and deleted files.
|
||||
- `gcm` commits with the given message.
|
||||
- `gco` checks out a branch or paths to the working tree.
|
||||
- `gcO` checks out hunks from the index or the tree interactively.
|
||||
- `gcf` amends the tip of the current branch reusing the same log message as
|
||||
*HEAD*.
|
||||
- `gcF` amends the tip of the current branch.
|
||||
- `gcp` applies changes introduced by existing commits.
|
||||
- `gcP` applies changes introduced by existing commits without committing.
|
||||
- `gcr` reverts existing commits by reverting patches and recording new
|
||||
commits.
|
||||
- `gcR` removes the *HEAD* commit.
|
||||
- `gcs` shows one or more objects (blobs, trees, tags and commits).
|
||||
- `gcS` commits with GPG signature.
|
||||
- `gcv` verifies the GPG signature of commits.
|
||||
|
||||
### Conflict
|
||||
|
||||
- `gCl` lists unmerged files.
|
||||
- `gCa` adds unmerged file contents to the index.
|
||||
- `gCe` executes merge-tool on all unmerged files.
|
||||
- `gCo` checks out our changes for unmerged paths.
|
||||
- `gCO` checks out our changes for all unmerged paths.
|
||||
- `gCt` checks out their changes for unmerged paths.
|
||||
- `gCT` checks out their changes for all unmerged paths.
|
||||
|
||||
### Data
|
||||
|
||||
- `gd` displays information about files in the index and the work tree.
|
||||
- `gdc` lists cached files.
|
||||
- `gdx` lists deleted files.
|
||||
- `gdm` lists modified files.
|
||||
- `gdu` lists untracked files.
|
||||
- `gdk` lists killed files.
|
||||
- `gdi` lists ignored files.
|
||||
|
||||
### Fetch
|
||||
|
||||
- `gf` downloads objects and references from another repository.
|
||||
- `gfc` clones a repository into a new directory.
|
||||
- `gfm` fetches from and merges with another repository or local branch.
|
||||
- `gfr` fetches from and rebases on another repository or local branch.
|
||||
|
||||
### Grep
|
||||
|
||||
- `gg` displays lines matching a pattern.
|
||||
- `ggi` displays lines matching a pattern ignoring case.
|
||||
- `ggl` lists files matching a pattern.
|
||||
- `ggL` lists files that are not matching a pattern.
|
||||
- `ggv` displays lines not matching a pattern.
|
||||
- `ggw` displays lines matching a pattern at word boundary.
|
||||
|
||||
### Index
|
||||
|
||||
- `gia` adds file contents to the index.
|
||||
- `giA` adds file contents to the index interactively.
|
||||
- `giu` adds file contents to the index (updates only known files).
|
||||
- `gid` displays changes between the index and a named commit (diff).
|
||||
- `giD` displays changes between the index and a named commit (word diff).
|
||||
- `gir` resets the current *HEAD* to the specified state.
|
||||
- `giR` resets the current index interactively.
|
||||
- `gix` removes files/directories from the index (recursively).
|
||||
- `giX` removes files/directories from the index (recursively and forced).
|
||||
|
||||
### Log
|
||||
|
||||
- `gl` displays the log.
|
||||
- `gls` displays the stats log.
|
||||
- `gld` displays the diff log.
|
||||
- `glo` displays the one line log.
|
||||
- `glO` displays the one line log with authors and dates.
|
||||
- `glg` displays the graph log.
|
||||
- `glG` displays the graph log with authors and dates.
|
||||
- `glv` displays the log verifying the GPG signature of commits.
|
||||
- `glc` displays the commit count for each contributor in descending order.
|
||||
|
||||
### Merge
|
||||
|
||||
- `gm` joins two or more development histories together.
|
||||
- `gmC` performs the merge but does not commit.
|
||||
- `gmF` performs the merge generating a commit even if the merge resolved as a
|
||||
fast-forward.
|
||||
- `gma` aborts the conflict resolution, and reconstructs the pre-merge state.
|
||||
- `gmt` runs the merge conflict resolution tools to resolve conflicts.
|
||||
|
||||
### Push
|
||||
|
||||
- `gp` updates remote refs along with associated objects.
|
||||
- `gpf` forces a push.
|
||||
- `gpa` pushes all branches.
|
||||
- `gpA` pushes all branches and tags.
|
||||
- `gpt` pushes all tags.
|
||||
- `gpc` pushes the current branch and adds *origin* as an upstream reference
|
||||
for it.
|
||||
- `gpp` pulls and pushes the current branch from *origin* to *origin*.
|
||||
|
||||
### Rebase
|
||||
|
||||
- `gr` forward-ports local commits to the updated upstream head.
|
||||
- `gra` aborts the rebase.
|
||||
- `grc` continues the rebase after merge conflicts are resolved.
|
||||
- `gri` makes a list of commits to be rebased and opens the editor.
|
||||
- `grs` skips the current patch.
|
||||
|
||||
### Remote
|
||||
|
||||
- `gR` manages tracked repositories.
|
||||
- `gRl` lists remote names and their URLs.
|
||||
- `gRa` adds a new remote.
|
||||
- `gRx` removes a remote.
|
||||
- `gRm` renames a remote.
|
||||
- `gRu` fetches remotes updates.
|
||||
- `gRp` prunes all stale remote tracking branches.
|
||||
- `gRs` shows information about a given remote.
|
||||
|
||||
### Stash
|
||||
|
||||
- `gs` stashes the changes of the dirty working directory.
|
||||
- `gsa` applies the changes recorded in a stash to the working directory.
|
||||
- `gsx` drops a stashed state.
|
||||
- `gsX` drops all the stashed states.
|
||||
- `gsl` lists stashed states.
|
||||
- `gsd` displays changes between the stash and its original parent.
|
||||
- `gsp` removes and applies a single stashed state from the stash list.
|
||||
- `gsr` recovers a given stashed state.
|
||||
- `gss` stashes the working directory changes, including untracked files.
|
||||
- `gsS` stashes the working directory changes interactively.
|
||||
- `gsw` stashes the working directory changes retaining the index.
|
||||
- `gsu` unapplies (reverts) applied changes.
|
||||
|
||||
### Submodule
|
||||
|
||||
- `gS` initializes, updates, or inspects submodules.
|
||||
- `gSa` adds given a repository as a submodule.
|
||||
- `gSf` evaluates a shell command in each of checked out submodules.
|
||||
- `gSi` initializes submodules.
|
||||
- `gSI` initializes and clones submodules recursively.
|
||||
- `gSl` lists the commits of all submodules.
|
||||
- `gSm` moves a submodule.
|
||||
- `gSs` synchronizes submodules' remote URL to the value specified in
|
||||
.gitmodules.
|
||||
- `gSu` fetches and merges the latest changes for all submodules.
|
||||
- `gSx` removes a submodule.
|
||||
|
||||
### Tag
|
||||
|
||||
- `gt` creates, lists, deletes or verifies a tag object signed with GPG.
|
||||
- `gts` creates a GPG-signed tag.
|
||||
- `gtv` verifies the GPG signature of tags.
|
||||
- `gtx` deletes tags with given names.
|
||||
|
||||
### Working tree
|
||||
|
||||
- `gws` displays working-tree status in the short format.
|
||||
- `gwS` displays working-tree status.
|
||||
- `gwd` displays changes between the working tree and the index (diff).
|
||||
- `gwD` displays changes between the working tree and the index (word diff).
|
||||
- `gwr` resets the current *HEAD* to the specified state, does not touch the
|
||||
index nor the working tree.
|
||||
- `gwR` resets the current *HEAD*, index and working tree to the specified
|
||||
state.
|
||||
- `gwc` cleans untracked files from the working tree (dry-run).
|
||||
- `gwC` cleans untracked files from the working tree.
|
||||
- `gwx` removes files from the working tree and from the index recursively.
|
||||
- `gwX` removes files from the working tree and from the index recursively and
|
||||
forcefully.
|
||||
|
||||
### Misc
|
||||
|
||||
- `g..` changes the current directory to the top level of the working tree.
|
||||
|
||||
### Shadows
|
||||
|
||||
The following aliases may shadow system commands:
|
||||
|
||||
- `gpt` shadows the GUID partition table maintenance utility.
|
||||
- `gs` shadows Ghostscript.
|
||||
|
||||
If you frequently use the above commands, you may wish to remove said aliases
|
||||
from this module or to disable them at the bottom of the zshrc with `unalias`.
|
||||
|
||||
You can temporarily bypass an alias by prefixing it with a backward slash:
|
||||
`\gpt`.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
- `git-branch-current` displays the current branch.
|
||||
- `git-dir` displays the path to the Git directory.
|
||||
- `git-ignore-add` adds any arguments to the .gitignore in the project root.
|
||||
- `git-root` displays the path to the working tree root.
|
||||
- `git-stash-clear-interactive` asks for confirmation before clearing the stash.
|
||||
- `git-stash-recover` recovers given dropped stashed states.
|
||||
- `git-submodule-move` moves a submodule.
|
||||
- `git-submodule-remove` removes a submodule.
|
|
@ -0,0 +1,2 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
command git symbolic-ref -q --short HEAD
|
|
@ -0,0 +1,16 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
local -a remotes
|
||||
if (( ${*[(I)-r]} || ${*[(I)--remotes]} )); then
|
||||
remotes=(${^*:#-*})
|
||||
else
|
||||
remotes=(${(f)"$(command git rev-parse --abbrev-ref ${^*:#-*}@{u} 2>/dev/null)"})
|
||||
fi
|
||||
if command git branch --delete ${@} && \
|
||||
(( ${#remotes[@]} )) && \
|
||||
read -q "?Also delete remote branch(es) ${remotes} [y/N]? "; then
|
||||
print
|
||||
local remote
|
||||
for remote (${remotes}); do
|
||||
command git push ${remote%%/*} :${remote#*/}
|
||||
done
|
||||
fi
|
|
@ -0,0 +1,4 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
local git_dir
|
||||
git_dir=$(command git rev-parse --git-dir) || return 1
|
||||
print ${git_dir:A}
|
|
@ -0,0 +1,8 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
local git_root
|
||||
git_root=$(git-root) || return 1
|
||||
|
||||
# we are in a git repository. add parameters to .gitignore
|
||||
for file in "${@}"; do
|
||||
print "${file}" >>! "${git_root}/.gitignore"
|
||||
done
|
|
@ -0,0 +1,2 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
command git rev-parse --show-toplevel
|
|
@ -0,0 +1,10 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
setopt LOCAL_OPTIONS PIPE_FAIL
|
||||
|
||||
local -i stashed
|
||||
stashed=$(command git stash list | wc -l) || return 1
|
||||
if (( stashed )) && \
|
||||
read -q "?Clear ${stashed} stashed state(s) [y/N]? "; then
|
||||
print
|
||||
command git stash clear
|
||||
fi
|
|
@ -0,0 +1,8 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
command git rev-parse --is-inside-work-tree >/dev/null || return 1
|
||||
|
||||
local commit
|
||||
for commit in "${@}"; do
|
||||
git update-ref -m "$(command git log -1 --pretty='format:%s' ${commit})" \
|
||||
refs/stash ${commit}
|
||||
done
|
|
@ -0,0 +1,22 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
local git_root
|
||||
git_root=$(git-root) || return 1
|
||||
|
||||
if [[ ${PWD} != ${git_root} ]]; then
|
||||
print "${0}: must be run from the root of the work tree" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local src="${1}"
|
||||
local dst="${2}"
|
||||
local url=$(command git config --file .gitmodules --get "submodule.${src}.url")
|
||||
if [[ -z "${url}" ]]; then
|
||||
print "${0}: submodule not found: ${src}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
mkdir -p "${dst:h}"
|
||||
git-submodule-remove "${src}"
|
||||
git submodule add "${url}" "${dst}"
|
||||
|
||||
return 0
|
|
@ -0,0 +1,21 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
local git_dir
|
||||
git_dir=$(git-dir) || return 1
|
||||
|
||||
if [[ ${PWD} != $(git-root) ]]; then
|
||||
print "${0}: must be run from the root of the work tree" >&2
|
||||
return 1
|
||||
elif ! command git config --file .gitmodules --get "submodule.${1}.path" &>/dev/null; then
|
||||
print "${0}: submodule not found: ${1}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
command git config --file "${git_dir}/config" --remove-section "submodule.${1}" &>/dev/null
|
||||
command git config --file .gitmodules --remove-section "submodule.${1}" &>/dev/null
|
||||
command git add .gitmodules
|
||||
|
||||
command git rm --cached "${1}" &>/dev/null
|
||||
rm -rf "${1}"
|
||||
rm -rf "${git_dir}/modules/${1}"
|
||||
|
||||
return 0
|
|
@ -0,0 +1,183 @@
|
|||
#
|
||||
# Git aliases.
|
||||
#
|
||||
|
||||
#
|
||||
# Settings
|
||||
#
|
||||
|
||||
# Log colour scheme has yellow commit hash, bold blue author, cyan date, auto ref names
|
||||
# See https://git-scm.com/docs/pretty-formats
|
||||
_git_log_medium_format='%C(bold)Commit:%C(reset) %C(yellow)%H%C(auto)%d%n%C(bold)Author:%C(reset) %C(bold blue)%an <%ae>%n%C(bold)Date:%C(reset) %C(cyan)%ai (%ar)%C(reset)%n%+B'
|
||||
_git_log_oneline_format='%C(yellow)%h%C(reset) %s%C(auto)%d%C(reset)'
|
||||
_git_log_oneline_medium_format='%C(yellow)%h%C(reset) %<|(60,trunc)%s %C(bold blue)<%an> %C(reset)%C(cyan)(%ar)%C(auto)%d%C(reset)'
|
||||
|
||||
#
|
||||
# Aliases
|
||||
#
|
||||
|
||||
# Git
|
||||
alias g='git'
|
||||
|
||||
# Branch (b)
|
||||
alias gb='git branch'
|
||||
alias gbc='git checkout -b'
|
||||
alias gbl='git branch -vv'
|
||||
alias gbL='git branch --all -vv'
|
||||
alias gbm='git branch --move'
|
||||
alias gbM='git branch --move --force'
|
||||
alias gbs='git show-branch'
|
||||
alias gbS='git show-branch --all'
|
||||
alias gbx='git-branch-delete-interactive'
|
||||
alias gbX='git-branch-delete-interactive --force'
|
||||
|
||||
# Commit (c)
|
||||
alias gc='git commit --verbose'
|
||||
alias gca='git commit --verbose --all'
|
||||
alias gcm='git commit --message'
|
||||
alias gco='git checkout'
|
||||
alias gcO='git checkout --patch'
|
||||
alias gcf='git commit --amend --reuse-message HEAD'
|
||||
alias gcF='git commit --verbose --amend'
|
||||
alias gcp='git cherry-pick --ff'
|
||||
alias gcP='git cherry-pick --no-commit'
|
||||
alias gcr='git revert'
|
||||
alias gcR='git reset "HEAD^"'
|
||||
alias gcs='git show --pretty=format:"${_git_log_medium_format}"'
|
||||
alias gcS='git commit -S'
|
||||
alias gcv='git verify-commit'
|
||||
|
||||
# Conflict (C)
|
||||
alias gCl='git --no-pager diff --diff-filter=U --name-only'
|
||||
alias gCa='git add $(gCl)'
|
||||
alias gCe='git mergetool $(gCl)'
|
||||
alias gCo='git checkout --ours --'
|
||||
alias gCO='gCo $(gCl)'
|
||||
alias gCt='git checkout --theirs --'
|
||||
alias gCT='gCt $(gCl)'
|
||||
|
||||
# Data (d)
|
||||
alias gd='git ls-files'
|
||||
alias gdc='git ls-files --cached'
|
||||
alias gdx='git ls-files --deleted'
|
||||
alias gdm='git ls-files --modified'
|
||||
alias gdu='git ls-files --other --exclude-standard'
|
||||
alias gdk='git ls-files --killed'
|
||||
alias gdi='git status --porcelain --short --ignored | sed -n "s/^!! //p"'
|
||||
|
||||
# Fetch (f)
|
||||
alias gf='git fetch'
|
||||
alias gfc='git clone'
|
||||
alias gfm='git pull'
|
||||
alias gfr='git pull --rebase'
|
||||
alias gfu='git fetch --all --prune && git merge --ff-only @\{u\}'
|
||||
|
||||
# Grep (g)
|
||||
alias gg='git grep'
|
||||
alias ggi='git grep --ignore-case'
|
||||
alias ggl='git grep --files-with-matches'
|
||||
alias ggL='git grep --files-without-match'
|
||||
alias ggv='git grep --invert-match'
|
||||
alias ggw='git grep --word-regexp'
|
||||
|
||||
# Index (i)
|
||||
alias gia='git add'
|
||||
alias giA='git add --patch'
|
||||
alias giu='git add --update'
|
||||
alias gid='git diff --no-ext-diff --cached'
|
||||
alias giD='git diff --no-ext-diff --cached --word-diff'
|
||||
alias gir='git reset'
|
||||
alias giR='git reset --patch'
|
||||
alias gix='git rm --cached -r'
|
||||
alias giX='git rm --cached -rf'
|
||||
|
||||
# Log (l)
|
||||
alias gl='git log --topo-order --pretty=format:"${_git_log_medium_format}"'
|
||||
alias gls='git log --topo-order --stat --pretty=format:"${_git_log_medium_format}"'
|
||||
alias gld='git log --topo-order --stat --patch --full-diff --pretty=format:"${_git_log_medium_format}"'
|
||||
alias glo='git log --topo-order --pretty=format:"${_git_log_oneline_format}"'
|
||||
alias glO='git log --topo-order --pretty=format:"${_git_log_oneline_medium_format}"'
|
||||
alias glg='git log --topo-order --all --graph --pretty=format:"${_git_log_oneline_format}%n"'
|
||||
alias glG='git log --topo-order --all --graph --pretty=format:"${_git_log_oneline_medium_format}%n"'
|
||||
alias glv='git log --topo-order --show-signature --pretty=format:"${_git_log_medium_format}"'
|
||||
alias glc='git shortlog --summary --numbered'
|
||||
|
||||
# Merge (m)
|
||||
alias gm='git merge'
|
||||
alias gmC='git merge --no-commit'
|
||||
alias gmF='git merge --no-ff'
|
||||
alias gma='git merge --abort'
|
||||
alias gmt='git mergetool'
|
||||
|
||||
# Push (p)
|
||||
alias gp='git push'
|
||||
alias gpf='git push --force'
|
||||
alias gpa='git push --all'
|
||||
alias gpA='git push --all && git push --tags'
|
||||
alias gpt='git push --tags'
|
||||
alias gpc='git push --set-upstream origin "$(git-branch-current 2> /dev/null)"'
|
||||
alias gpp='git pull origin "$(git-branch-current 2> /dev/null)" && git push origin "$(git-branch-current 2> /dev/null)"'
|
||||
|
||||
# Rebase (r)
|
||||
alias gr='git rebase'
|
||||
alias gra='git rebase --abort'
|
||||
alias grc='git rebase --continue'
|
||||
alias gri='git rebase --interactive'
|
||||
alias grs='git rebase --skip'
|
||||
|
||||
# Remote (R)
|
||||
alias gR='git remote'
|
||||
alias gRl='git remote --verbose'
|
||||
alias gRa='git remote add'
|
||||
alias gRx='git remote rm'
|
||||
alias gRm='git remote rename'
|
||||
alias gRu='git remote update'
|
||||
alias gRp='git remote prune'
|
||||
alias gRs='git remote show'
|
||||
|
||||
# Stash (s)
|
||||
alias gs='git stash'
|
||||
alias gsa='git stash apply'
|
||||
alias gsx='git stash drop'
|
||||
alias gsX='git-stash-clear-interactive'
|
||||
alias gsl='git stash list'
|
||||
alias gsd='git stash show --patch --stat'
|
||||
alias gsp='git stash pop'
|
||||
alias gsr='git-stash-recover'
|
||||
alias gss='git stash save --include-untracked'
|
||||
alias gsS='git stash save --patch --no-keep-index'
|
||||
alias gsw='git stash save --include-untracked --keep-index'
|
||||
alias gsu='git stash show --patch | git apply --reverse'
|
||||
|
||||
# Submodule (S)
|
||||
alias gS='git submodule'
|
||||
alias gSa='git submodule add'
|
||||
alias gSf='git submodule foreach'
|
||||
alias gSi='git submodule init'
|
||||
alias gSI='git submodule update --init --recursive'
|
||||
alias gSl='git submodule status'
|
||||
alias gSm='git-submodule-move'
|
||||
alias gSs='git submodule sync'
|
||||
alias gSu='git submodule foreach git pull origin master'
|
||||
alias gSx='git-submodule-remove'
|
||||
|
||||
# Tag (t)
|
||||
alias gt='git tag'
|
||||
alias gts='git tag --sign'
|
||||
alias gtv='git verify-tag'
|
||||
alias gtx='git tag --delete'
|
||||
|
||||
# Working tree (w)
|
||||
alias gws='git status --short'
|
||||
alias gwS='git status'
|
||||
alias gwd='git diff --no-ext-diff'
|
||||
alias gwD='git diff --no-ext-diff --word-diff'
|
||||
alias gwr='git reset --soft'
|
||||
alias gwR='git reset --hard'
|
||||
alias gwc='git clean --dry-run'
|
||||
alias gwC='git clean -d --force'
|
||||
alias gwx='git rm -r'
|
||||
alias gwX='git rm -rf'
|
||||
|
||||
# Misc
|
||||
alias g..='cd "$(git-root || print .)"'
|
|
@ -0,0 +1,22 @@
|
|||
History-Substring-Search
|
||||
========================
|
||||
|
||||
Allows for fish shell-like searching of history with UP and DOWN.
|
||||
|
||||
![example][fish_shell]
|
||||
|
||||
This module requires the [input](https://github.com/zimfw/zimfw/blob/master/modules/input/README.md) module. Without it, you may experience odd behavior.
|
||||
Put 'input' in the first line and 'history-substring-search' on the second line of `zmodules` in your `.zimrc`.
|
||||
|
||||
Additionally, if you use [syntax-highlighting](https://github.com/zimfw/zimfw/blob/master/modules/syntax-highlighting/README.md), place 'syntax-highlighting' before 'history-substring-search' on the second line of `zmodules` in your `.zimrc`.
|
||||
|
||||
The options set explicitly by init.zsh are the default options, and are only set for consistancy.
|
||||
|
||||
Functionality is sourced from [history-substring-search](https://github.com/zsh-users/zsh-history-substring-search)
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Contributions should be submitted [upstream to history-substring-search](https://github.com/zsh-users/zsh-history-substring-search)
|
||||
|
||||
[fish_shell]: https://i.eriner.me/zim_history-substring-search.gif
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 933733e86724a018cb98cb8f514fc3d323461f74
|
|
@ -0,0 +1,14 @@
|
|||
#
|
||||
# enables searching history with substrings
|
||||
#
|
||||
|
||||
# source script
|
||||
source ${0:h}/external/zsh-history-substring-search.zsh || return 1
|
||||
|
||||
# bind UP and DOWN keys
|
||||
bindkey "${terminfo[kcuu1]}" history-substring-search-up
|
||||
bindkey "${terminfo[kcud1]}" history-substring-search-down
|
||||
|
||||
# bind UP and DOWN arrow keys (compatibility fallback)
|
||||
bindkey '^[[A' history-substring-search-up
|
||||
bindkey '^[[B' history-substring-search-down
|
|
@ -0,0 +1,28 @@
|
|||
History
|
||||
=======
|
||||
|
||||
Sets sane default history options.
|
||||
|
||||
History file is set to save in `${ZDOTDIR:-${HOME}}/.zhistory`
|
||||
|
||||
(most likely ~/.zhistory)
|
||||
|
||||
Zsh Options
|
||||
-----------
|
||||
|
||||
| Option | Effect |
|
||||
| ------ | ------ |
|
||||
| BANG_HIST | Use csh-style '!' expansion |
|
||||
| EXTENDED_HISTORY | Save timestamps along with commands |
|
||||
| INC_APPEND_HISTORY | Commands are added to the history file immediately upon execution |
|
||||
| SHARE_HISTORY | Causes all terminals to share the same history 'session' |
|
||||
| HIST_IGNORE_DUPS | Do not enter immediate duplicates into history |
|
||||
| HIST_IGNORE_ALL_DUPS | If duplicate is to be added, remove older instance in history |
|
||||
| HIST_IGNORE_SPACE | Do not add any commands to history that begin with a space |
|
||||
| HIST_SAVE_NO_DUPS | When saving, older commands that duplicate newer commands are omitted |
|
||||
| HIST_VERIFY | Upon history 'selection', don't execute immediately. Require a carriage return |
|
||||
|
||||
Aliases
|
||||
-------
|
||||
|
||||
* `history-stat` lists the 10 most used commands
|
|
@ -0,0 +1,46 @@
|
|||
#
|
||||
# Configures history options
|
||||
#
|
||||
|
||||
# sets the location of the history file
|
||||
HISTFILE="${ZDOTDIR:-${HOME}}/.zhistory"
|
||||
|
||||
# limit of history entries
|
||||
HISTSIZE=10000
|
||||
SAVEHIST=10000
|
||||
|
||||
# Perform textual history expansion, csh-style, treating the character ‘!’ specially.
|
||||
setopt BANG_HIST
|
||||
|
||||
# Save each command’s beginning timestamp (in seconds since the epoch) and the duration (in seconds) to the history file.
|
||||
# ‘: <beginning time>:<elapsed seconds>;<command>’.
|
||||
setopt EXTENDED_HISTORY
|
||||
|
||||
# This options works like APPEND_HISTORY except that new history lines are added to the ${HISTFILE} incrementally
|
||||
# (as soon as they are entered), rather than waiting until the shell exits.
|
||||
setopt INC_APPEND_HISTORY
|
||||
|
||||
# Shares history across all sessions rather than waiting for a new shell invocation to read the history file.
|
||||
setopt SHARE_HISTORY
|
||||
|
||||
# Do not enter command lines into the history list if they are duplicates of the previous event.
|
||||
setopt HIST_IGNORE_DUPS
|
||||
|
||||
# If a new command line being added to the history list duplicates an older one,
|
||||
# the older command is removed from the list (even if it is not the previous event).
|
||||
setopt HIST_IGNORE_ALL_DUPS
|
||||
|
||||
# Remove command lines from the history list when the first character on the line is a space,
|
||||
# or when one of the expanded aliases contains a leading space.
|
||||
setopt HIST_IGNORE_SPACE
|
||||
|
||||
# When writing out the history file, older commands that duplicate newer ones are omitted.
|
||||
setopt HIST_SAVE_NO_DUPS
|
||||
|
||||
# Whenever the user enters a line with history expansion, don’t execute the line directly;
|
||||
# instead, perform history expansion and reload the line into the editing buffer.
|
||||
setopt HIST_VERIFY
|
||||
|
||||
|
||||
# Lists the ten most used commands.
|
||||
alias history-stat="history 0 | awk '{print \$2}' | sort | uniq -c | sort -n -r | head"
|
|
@ -0,0 +1,10 @@
|
|||
Input
|
||||
=====
|
||||
|
||||
Applies correct bindkeys for input events.
|
||||
|
||||
Without this module, you may experience oddities in how Zsh interprets input.
|
||||
For example, using the UP key, then using the back arrow and pressing DELETE may capatalize characters rather than delete them.
|
||||
|
||||
This module also provides double-dot parent directory expansion.
|
||||
It can be enabled by uncommenting `zdouble_dot_expand='true'` in your .zimrc
|
|
@ -0,0 +1,126 @@
|
|||
#
|
||||
# Editor and input char assignment
|
||||
#
|
||||
|
||||
|
||||
# Return if requirements are not found.
|
||||
if [[ ${TERM} == 'dumb' ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Use human-friendly identifiers.
|
||||
zmodload zsh/terminfo
|
||||
typeset -gA key_info
|
||||
key_info=(
|
||||
'Control' '\C-'
|
||||
'ControlLeft' '\e[1;5D \e[5D \e\e[D \eOd \eOD'
|
||||
'ControlRight' '\e[1;5C \e[5C \e\e[C \eOc \eOC'
|
||||
'Escape' '\e'
|
||||
'Meta' '\M-'
|
||||
'Backspace' "^?"
|
||||
'Delete' "^[[3~"
|
||||
'F1' "${terminfo[kf1]}"
|
||||
'F2' "${terminfo[kf2]}"
|
||||
'F3' "${terminfo[kf3]}"
|
||||
'F4' "${terminfo[kf4]}"
|
||||
'F5' "${terminfo[kf5]}"
|
||||
'F6' "${terminfo[kf6]}"
|
||||
'F7' "${terminfo[kf7]}"
|
||||
'F8' "${terminfo[kf8]}"
|
||||
'F9' "${terminfo[kf9]}"
|
||||
'F10' "${terminfo[kf10]}"
|
||||
'F11' "${terminfo[kf11]}"
|
||||
'F12' "${terminfo[kf12]}"
|
||||
'Insert' "${terminfo[kich1]}"
|
||||
'Home' "${terminfo[khome]}"
|
||||
'PageUp' "${terminfo[kpp]}"
|
||||
'End' "${terminfo[kend]}"
|
||||
'PageDown' "${terminfo[knp]}"
|
||||
'Up' "${terminfo[kcuu1]}"
|
||||
'Left' "${terminfo[kcub1]}"
|
||||
'Down' "${terminfo[kcud1]}"
|
||||
'Right' "${terminfo[kcuf1]}"
|
||||
'BackTab' "${terminfo[kcbt]}"
|
||||
)
|
||||
|
||||
# Bind the keys
|
||||
|
||||
local key
|
||||
for key in "${(s: :)key_info[ControlLeft]}"; do
|
||||
bindkey ${key} backward-word
|
||||
done
|
||||
for key in "${(s: :)key_info[ControlRight]}"; do
|
||||
bindkey ${key} forward-word
|
||||
done
|
||||
|
||||
if [[ -n "${key_info[Home]}" ]]; then
|
||||
bindkey "${key_info[Home]}" beginning-of-line
|
||||
fi
|
||||
|
||||
if [[ -n "${key_info[End]}" ]]; then
|
||||
bindkey "${key_info[End]}" end-of-line
|
||||
fi
|
||||
|
||||
if [[ -n "${key_info[PageUp]}" ]]; then
|
||||
bindkey "${key_info[PageUp]}" up-line-or-history
|
||||
fi
|
||||
|
||||
if [[ -n "${key_info[PageDown]}" ]]; then
|
||||
bindkey "${key_info[PageDown]}" down-line-or-history
|
||||
fi
|
||||
|
||||
if [[ -n "${key_info[Insert]}" ]]; then
|
||||
bindkey "${key_info[Insert]}" overwrite-mode
|
||||
fi
|
||||
|
||||
if [[ ${zdouble_dot_expand} == "true" ]]; then
|
||||
double-dot-expand() {
|
||||
if [[ ${LBUFFER} == *.. ]]; then
|
||||
LBUFFER+='/..'
|
||||
else
|
||||
LBUFFER+='.'
|
||||
fi
|
||||
}
|
||||
zle -N double-dot-expand
|
||||
bindkey "." double-dot-expand
|
||||
fi
|
||||
|
||||
bindkey "${key_info[Delete]}" delete-char
|
||||
bindkey "${key_info[Backspace]}" backward-delete-char
|
||||
|
||||
bindkey "${key_info[Left]}" backward-char
|
||||
bindkey "${key_info[Right]}" forward-char
|
||||
|
||||
# Expandpace.
|
||||
bindkey ' ' magic-space
|
||||
|
||||
# Clear
|
||||
bindkey "${key_info[Control]}L" clear-screen
|
||||
|
||||
# Bind Shift + Tab to go to the previous menu item.
|
||||
if [[ -n "${key_info[BackTab]}" ]]; then
|
||||
bindkey "${key_info[BackTab]}" reverse-menu-complete
|
||||
fi
|
||||
|
||||
# Redisplay after completing, and avoid blank prompt after <Tab><Tab><Ctrl-C>
|
||||
expand-or-complete-with-redisplay() {
|
||||
print -n '...'
|
||||
zle expand-or-complete
|
||||
zle redisplay
|
||||
}
|
||||
zle -N expand-or-complete-with-redisplay
|
||||
bindkey "${key_info[Control]}I" expand-or-complete-with-redisplay
|
||||
|
||||
# Put into application mode and validate ${terminfo}
|
||||
zle-line-init() {
|
||||
if (( ${+terminfo[smkx]} )); then
|
||||
echoti smkx
|
||||
fi
|
||||
}
|
||||
zle-line-finish() {
|
||||
if (( ${+terminfo[rmkx]} )); then
|
||||
echoti rmkx
|
||||
fi
|
||||
}
|
||||
zle -N zle-line-init
|
||||
zle -N zle-line-finish
|
|
@ -0,0 +1,61 @@
|
|||
Pacman
|
||||
======
|
||||
|
||||
Adds aliases for the pacman package manager.
|
||||
|
||||
Also includes optional helper(s).
|
||||
|
||||
.zimrc Configuration
|
||||
-------------
|
||||
* `zpacman_frontend='helper_here'` Set helper_here to a wrapper if applicable (powerpill, pacmatic, etc).
|
||||
* `zpacman_helper=(aur)` add/remove any helper scripts to be loaded here.
|
||||
|
||||
Helpers
|
||||
-------
|
||||
|
||||
### aur
|
||||
|
||||
provides simple AUR helper aliases.
|
||||
|
||||
* `aurb package_name` clone the package from the AUR, build, and install.
|
||||
* `aurd package_name` clone the package from the AUR, but do not build.
|
||||
* `auru` run inside a directory created with `aurb`, this will update, build, and install a package.
|
||||
|
||||
Aliases
|
||||
-------
|
||||
|
||||
### Build
|
||||
|
||||
* `pacb` build package in the current directory, cleanup, and install.
|
||||
|
||||
### Install
|
||||
|
||||
* `paci` install, sync, and upgrade packages.
|
||||
* `pacu` install, sync, and upgrade packages (forcibly refresh package list).
|
||||
* `pacU` install packages from pkg file.
|
||||
* `pacd` install all packages in current directory.
|
||||
|
||||
### Remove
|
||||
|
||||
* `pacr` remove package and unneeded dependencies.
|
||||
* `pacrm` remove package, unneded dependencies, and configuration files.
|
||||
|
||||
### Query
|
||||
|
||||
* `pacq` query package information from remote repository
|
||||
* `pacQ` query package information from local repository
|
||||
|
||||
### Search
|
||||
|
||||
* `pacs` search for package in the remote repository
|
||||
* `pacS` search for package in the local repository
|
||||
|
||||
### Orphans
|
||||
|
||||
* `pacol` list orphan packages
|
||||
* `pacor` remove all orphan packages
|
||||
|
||||
### Ownership
|
||||
|
||||
* `pacown` list all files provided by a given package
|
||||
* `pacblame` show package(s) that own a specified file
|
|
@ -0,0 +1,20 @@
|
|||
#
|
||||
# AUR aliases
|
||||
#
|
||||
|
||||
# download and build AUR package
|
||||
aurb() {
|
||||
git clone https://aur.archlinux.org/${1}.git && cd ${1} && makepkg --clean --install --syncdeps
|
||||
}
|
||||
|
||||
# only download aur package; do not build
|
||||
aurd() {
|
||||
git clone https://aur.archlinux.org/${1}.git
|
||||
}
|
||||
|
||||
# remove old package, rebuild, and install.
|
||||
#NOTE: this is will remove any unstashed/uncommitted changes.
|
||||
# due to how makepkg will update the PKGBUILD, a git pull alone will not suffice.
|
||||
auru() {
|
||||
git reset HEAD --hard && git pull && makepkg --clean --force --install --syncdeps --cleanbuild
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
#
|
||||
# Pacman aliases
|
||||
#
|
||||
|
||||
# ${zpacman_frontend} is provided by either .zimrc or (if not set) init.zsh
|
||||
# The zpacman_frontend is _only_ used for package installs.
|
||||
|
||||
#
|
||||
# Setup
|
||||
#
|
||||
|
||||
# ensure pacman is available
|
||||
if (( ! ${+commands[pacman]} )); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
local zpacman_frontend_priv helper
|
||||
|
||||
if (( ! ${+zpacman_frontend} )); then
|
||||
zpacman_frontend='pacman'
|
||||
zpacman_frontend_priv='sudo pacman'
|
||||
elif (( ! ${+commands[${zpacman_frontend}]} )); then
|
||||
print "pacman frontend \"${zpacman_frontend}\" is invalid or not installed. Reverting to \"pacman\".
|
||||
You can fix this error by editing the 'zpacman_frontend' variable in your .zimrc" >&2
|
||||
zpacman_frontend='pacman'
|
||||
zpacman_frontend_priv='sudo pacman'
|
||||
elif [[ ${zpacman_frontend} == ("yaourt"|"pacaur") ]]; then
|
||||
# yaourt and pacaur handles SUID themselves
|
||||
zpacman_frontend_priv="${zpacman_frontend}"
|
||||
else
|
||||
zpacman_frontend_priv="sudo ${zpacman_frontend}"
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# General
|
||||
#
|
||||
|
||||
alias pac=${zpacman_frontend}
|
||||
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
# build package in current directory, cleanup, and install
|
||||
alias pacb='makepkg -sci'
|
||||
|
||||
#
|
||||
# Install
|
||||
#
|
||||
|
||||
#NOTE: Installing/upgrading individual packages is NOT supported. Sync and upgrade ALL on install.
|
||||
|
||||
# install, sync, and upgrade packages
|
||||
alias paci="${zpacman_frontend_priv} -Syu"
|
||||
|
||||
# install packages without syncing
|
||||
alias pacI="${zpacman_frontend_priv} -S"
|
||||
|
||||
# install, sync, and upgrade packages (forcibly refresh package lists)
|
||||
alias pacu="${zpacman_frontend_priv} -Syyu"
|
||||
|
||||
# install packages by filename
|
||||
alias pacU="${zpacman_frontend_priv} -U"
|
||||
|
||||
# install all packages in current directory
|
||||
alias pacd="${zpacman_frontend_priv} -U *.pkg.*"
|
||||
|
||||
|
||||
#
|
||||
# Remove
|
||||
#
|
||||
|
||||
# remove package and unneeded dependencies
|
||||
alias pacr="${zpacman_frontend_priv} -R"
|
||||
|
||||
# remove package, unneeded dependencies, and configuration files
|
||||
alias pacrm="${zpacman_frontend_priv} -Rns"
|
||||
|
||||
|
||||
#
|
||||
# Query
|
||||
#
|
||||
|
||||
# query package information from the remote repository
|
||||
alias pacq="${zpacman_frontend} -Si"
|
||||
|
||||
# query package information from the local repository
|
||||
alias pacQ="${zpacman_frontend} -Qi"
|
||||
|
||||
|
||||
#
|
||||
# Search
|
||||
#
|
||||
|
||||
# search for package in the remote repository
|
||||
alias pacs="${zpacman_frontend} -Ss"
|
||||
|
||||
# search for the package in the local repository
|
||||
alias pacS="${zpacman_frontend} -Qs"
|
||||
|
||||
|
||||
#
|
||||
# Orphans
|
||||
#
|
||||
|
||||
# list orphan packages
|
||||
alias pacol="${zpacman_frontend} -Qdt"
|
||||
|
||||
# remove orphan packages
|
||||
alias pacor="${zpacman_frontend_priv} -Rns \$(pacman -Qtdq)"
|
||||
|
||||
|
||||
#
|
||||
# Ownership
|
||||
#
|
||||
|
||||
# list all files that belong to a package
|
||||
alias pacown="${zpacman_frontend} -Ql"
|
||||
|
||||
# show package(s) owning the specified file
|
||||
alias pacblame="${zpacman_frontend} -Qo"
|
||||
|
||||
#
|
||||
# Helpers
|
||||
#
|
||||
|
||||
# source helper functions/aliases
|
||||
for helper ( ${zpacman_helper[@]} ); do
|
||||
if [[ -s ${0:h}/helper_${helper}.zsh ]]; then
|
||||
source ${0:h}/helper_${helper}.zsh
|
||||
else
|
||||
print "no such helper script \"helper_${helper}.zsh\"" >&2
|
||||
fi
|
||||
done
|
|
@ -0,0 +1,15 @@
|
|||
Prompt
|
||||
======
|
||||
|
||||
Initializes and provides customizable prompt themes.
|
||||
|
||||
Images of various prompt themes can be found on the [wiki](https://github.com/zimfw/zimfw/wiki/Themes).
|
||||
|
||||
A list of available prompts can be found by running `prompt -l`.
|
||||
|
||||
To test a prompt, simply run `prompt prompt_name_here`.
|
||||
|
||||
.zimrc Configuration
|
||||
--------------------
|
||||
|
||||
* `zprompt_theme='eriner'` change 'eriner' to the name of your desired prompt. This will set it as you default prompt.
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 3cf61b240d0bb0e3d1c517d2324534ddbf3614e8
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 9c80396021a8106bfaeade9a1ea51b85152e951d
|
|
@ -0,0 +1 @@
|
|||
Subproject commit a95d55cc7d3a73fc562ac11e23c26113ed6d58cf
|
|
@ -0,0 +1 @@
|
|||
../external-themes/pure/async.zsh
|
|
@ -0,0 +1 @@
|
|||
../external-themes/liquidprompt/liquidprompt
|
|
@ -0,0 +1 @@
|
|||
../themes/eriner.zsh-theme
|
|
@ -0,0 +1 @@
|
|||
../themes/gitster.zsh-theme
|
|
@ -0,0 +1 @@
|
|||
../external-themes/lean/prompt_lean_setup
|
|
@ -0,0 +1,12 @@
|
|||
prompt_liquidprompt_setup() {
|
||||
autoload -Uz ex-liquidprompt
|
||||
ext-liquidprompt
|
||||
}
|
||||
|
||||
prompt_liquidprompt_preview() {
|
||||
_lp_set_prompt
|
||||
prompt_preview_theme liquidprompt
|
||||
prompt_off
|
||||
}
|
||||
|
||||
prompt_liquidprompt_setup "$@"
|
|
@ -0,0 +1 @@
|
|||
../themes/magicmace.zsh-theme
|
|
@ -0,0 +1 @@
|
|||
../themes/minimal.zsh-theme
|
|
@ -0,0 +1 @@
|
|||
../external-themes/pure/pure.zsh
|
|
@ -0,0 +1 @@
|
|||
../themes/steeef.zsh-theme
|
|
@ -0,0 +1,13 @@
|
|||
# shortens the pwd for use in prompt
|
||||
|
||||
local current_dir="${1:-${PWD}}"
|
||||
local return_dir='~'
|
||||
|
||||
current_dir="${current_dir/#${HOME}/~}"
|
||||
|
||||
# if we aren't in ~
|
||||
if [[ ${current_dir} != '~' ]]; then
|
||||
return_dir="${${${${(@j:/:M)${(@s:/:)current_dir}##.#?}:h}%/}//\%/%%}/${${current_dir:t}//\%/%%}"
|
||||
fi
|
||||
|
||||
print ${return_dir}
|
|
@ -0,0 +1,8 @@
|
|||
#
|
||||
# load user-defined prompt
|
||||
#
|
||||
|
||||
if [[ ! ${TERM} == (linux|*bsd*|dumb) ]] && (( ${+zprompt_theme} )); then
|
||||
autoload -Uz promptinit && promptinit
|
||||
prompt ${(ps: :)${zprompt_theme}}
|
||||
fi
|
|
@ -0,0 +1,140 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
#
|
||||
# Eriner's Theme - fork of agnoster
|
||||
# A Powerline-inspired theme for ZSH
|
||||
#
|
||||
# In order for this theme to render correctly, a font with Powerline symbols is
|
||||
# required. A simple way to install a font with Powerline symbols is to follow
|
||||
# the instructions here: https://github.com/powerline/fonts#installation
|
||||
#
|
||||
# The aim of this theme is to only show you *relevant* information. Like most
|
||||
# prompts, it will only show git information when in a git working directory.
|
||||
# However, it goes a step further: everything from the current user and
|
||||
# hostname to whether the last call exited with an error to whether background
|
||||
# jobs are running in this shell will all be displayed automatically when
|
||||
# appropriate.
|
||||
#
|
||||
# Requires the `git-info` zmodule to be included in the .zimrc file.
|
||||
|
||||
prompt_eriner_help () {
|
||||
cat <<EOH
|
||||
This prompt is color-scheme-able. You can customize it using:
|
||||
|
||||
prompt eriner [status_color] [pwd_color] [git_clean_color] [git_dirty_color]
|
||||
|
||||
where the parameters are the background colors for each segment. The default
|
||||
values are black, cyan, green, and yellow.
|
||||
|
||||
In order for this prompt to render correctly, a font with Powerline symbols is
|
||||
required. A simple way to install a font with Powerline symbols is to follow
|
||||
the instructions here: https://github.com/powerline/fonts#installation
|
||||
EOH
|
||||
}
|
||||
|
||||
prompt_eriner_main() {
|
||||
local prompt_eriner_retval=${?}
|
||||
local prompt_eriner_color1=${1:-black}
|
||||
local prompt_eriner_color2=${2:-cyan}
|
||||
|
||||
### Segment drawing
|
||||
# Utility functions to make it easy and re-usable to draw segmented prompts.
|
||||
|
||||
local prompt_eriner_bg
|
||||
|
||||
# Begin a segment. Takes two arguments, background color and contents of the
|
||||
# new segment.
|
||||
prompt_eriner_segment() {
|
||||
print -n "%K{${1}}"
|
||||
[[ -n ${prompt_eriner_bg} ]] && print -n "%F{${prompt_eriner_bg}}"
|
||||
print -n "${2}"
|
||||
prompt_eriner_bg=${1}
|
||||
}
|
||||
|
||||
prompt_eriner_standout_segment() {
|
||||
print -n "%S%F{${1}}"
|
||||
[[ -n ${prompt_eriner_bg} ]] && print -n "%K{${prompt_eriner_bg}}%k"
|
||||
print -n "${2}%s"
|
||||
prompt_eriner_bg=${1}
|
||||
}
|
||||
|
||||
# End the prompt, closing last segment.
|
||||
prompt_eriner_end() {
|
||||
print -n "%k%F{${prompt_eriner_bg}}%f "
|
||||
}
|
||||
|
||||
### Prompt components
|
||||
# Each component will draw itself, or hide itself if no information needs to
|
||||
# be shown.
|
||||
|
||||
# Status: Was there an error? Am I root? Are there background jobs? Ranger
|
||||
# spawned shell? Who and where am I (user@hostname)?
|
||||
prompt_eriner_status() {
|
||||
local segment=''
|
||||
(( prompt_eriner_retval )) && segment+=' %F{red}✘'
|
||||
(( UID == 0 )) && segment+=' %F{yellow}⚡'
|
||||
(( $(jobs -l | wc -l) )) && segment+=' %F{cyan}⚙'
|
||||
(( RANGER_LEVEL )) && segment+=' %F{cyan}r'
|
||||
if [[ ${USER} != ${DEFAULT_USER} || -n ${SSH_CLIENT} ]]; then
|
||||
segment+=' %F{%(!.yellow.default)}${USER}@%m'
|
||||
fi
|
||||
if [[ -n ${segment} ]]; then
|
||||
prompt_eriner_segment ${prompt_eriner_color1} "${segment} "
|
||||
fi
|
||||
}
|
||||
|
||||
# Pwd: current working directory.
|
||||
prompt_eriner_pwd() {
|
||||
prompt_eriner_standout_segment ${prompt_eriner_color2} " $(short_pwd) "
|
||||
}
|
||||
|
||||
# Git: branch/detached head, dirty status.
|
||||
prompt_eriner_git() {
|
||||
if [[ -n ${git_info} ]]; then
|
||||
local indicator
|
||||
[[ ${git_info[color]} == yellow ]] && indicator='± '
|
||||
prompt_eriner_standout_segment ${git_info[color]} " \${(e)git_info[prompt]} ${indicator}"
|
||||
fi
|
||||
}
|
||||
|
||||
prompt_eriner_status
|
||||
prompt_eriner_pwd
|
||||
prompt_eriner_git
|
||||
prompt_eriner_end
|
||||
}
|
||||
|
||||
prompt_eriner_precmd() {
|
||||
(( ${+functions[git-info]} )) && git-info
|
||||
}
|
||||
|
||||
prompt_eriner_setup() {
|
||||
autoload -Uz add-zsh-hook && add-zsh-hook precmd prompt_eriner_precmd
|
||||
|
||||
prompt_opts=(cr percent sp subst)
|
||||
|
||||
local prompt_eriner_color3=${3:-green}
|
||||
local prompt_eriner_color4=${4:-yellow}
|
||||
|
||||
zstyle ':zim:git-info:branch' format ' %b'
|
||||
zstyle ':zim:git-info:commit' format '➦ %c'
|
||||
zstyle ':zim:git-info:action' format ' (%s)'
|
||||
zstyle ':zim:git-info:clean' format ${prompt_eriner_color3}
|
||||
zstyle ':zim:git-info:dirty' format ${prompt_eriner_color4}
|
||||
zstyle ':zim:git-info:keys' format \
|
||||
'prompt' '%b%c%s' \
|
||||
'color' '%C%D'
|
||||
|
||||
PS1="\${(e)\$(prompt_eriner_main ${@:1:2})}"
|
||||
RPS1=''
|
||||
}
|
||||
|
||||
prompt_eriner_preview () {
|
||||
if (( ${#} )); then
|
||||
prompt_preview_theme eriner "${@}"
|
||||
else
|
||||
prompt_preview_theme eriner
|
||||
print
|
||||
prompt_preview_theme eriner black blue green yellow
|
||||
fi
|
||||
}
|
||||
|
||||
prompt_eriner_setup "${@}"
|
|
@ -0,0 +1,40 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
#
|
||||
# Gitster theme
|
||||
# https://github.com/shashankmehta/dotfiles/blob/master/thesetup/zsh/.oh-my-zsh/custom/themes/gitster.zsh-theme
|
||||
#
|
||||
# Requires the `git-info` zmodule to be included in the .zimrc file.
|
||||
|
||||
prompt_gitster_pwd() {
|
||||
prompt_short_dir=$(short_pwd)
|
||||
git_root=$(command git rev-parse --show-toplevel 2> /dev/null) && prompt_short_dir=${prompt_short_dir#${$(short_pwd $git_root):h}/}
|
||||
print -n "%F{white}${prompt_short_dir}"
|
||||
}
|
||||
|
||||
prompt_gitster_git() {
|
||||
[[ -n ${git_info} ]] && print -n "${(e)git_info[prompt]}"
|
||||
}
|
||||
|
||||
prompt_gitster_precmd() {
|
||||
(( ${+functions[git-info]} )) && git-info
|
||||
}
|
||||
|
||||
prompt_gitster_setup() {
|
||||
local prompt_gitster_status='%(?:%F{green}:%F{red})➜ '
|
||||
|
||||
autoload -Uz add-zsh-hook && add-zsh-hook precmd prompt_gitster_precmd
|
||||
|
||||
prompt_opts=(cr percent sp subst)
|
||||
|
||||
zstyle ':zim:git-info:branch' format '%b'
|
||||
zstyle ':zim:git-info:commit' format '%c'
|
||||
zstyle ':zim:git-info:clean' format '%F{green}✓'
|
||||
zstyle ':zim:git-info:dirty' format '%F{yellow}✗'
|
||||
zstyle ':zim:git-info:keys' format \
|
||||
'prompt' ' %F{cyan}%b%c %C%D'
|
||||
|
||||
PS1="${prompt_gitster_status}\$(prompt_gitster_pwd)\$(prompt_gitster_git)%f "
|
||||
RPS1=''
|
||||
}
|
||||
|
||||
prompt_gitster_setup "${@}"
|
|
@ -0,0 +1,72 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
#
|
||||
# magicmace theme
|
||||
# Ideas and code taken from:
|
||||
# xero's zsh prompt <http://code.xero.nu/dotfiles>
|
||||
# eriner's eriner prompt <https://github.com/zimfw/zimfw/blob/master/modules/prompt/themes/eriner.zsh-theme>
|
||||
#
|
||||
# Requires the `git-info` zmodule to be included in the .zimrc file.
|
||||
|
||||
# Global variables
|
||||
function {
|
||||
COLOR_ROOT="%F{red}"
|
||||
COLOR_USER="%F{cyan}"
|
||||
COLOR_NORMAL="%F{white}"
|
||||
COLOR_ERROR="%F{red}"
|
||||
|
||||
if (( ${EUID} )); then
|
||||
COLOR_USER_LEVEL=${COLOR_USER}
|
||||
else
|
||||
COLOR_USER_LEVEL=${COLOR_ROOT}
|
||||
fi
|
||||
}
|
||||
|
||||
# Status:
|
||||
# - was there an error?
|
||||
# - are there background jobs?
|
||||
# - are we in a ranger session?
|
||||
prompt_magicmace_status() {
|
||||
local symbols=""
|
||||
|
||||
(( ${RETVAL} )) && symbols+="${COLOR_ERROR}${RETVAL}${COLOR_NORMAL}" # $? for error.
|
||||
(( $(jobs -l | wc -l) > 0 )) && symbols+='b' # 'b' for background.
|
||||
(( ${RANGER_LEVEL} )) && symbols+='r' # 'r' for... you guessed it!
|
||||
|
||||
[[ -n ${symbols} ]] && print -n "─${COLOR_NORMAL}${symbols}${COLOR_USER_LEVEL}─"
|
||||
}
|
||||
|
||||
prompt_magicmace_git() {
|
||||
[[ -n ${git_info} ]] && print -n "${(e)git_info[prompt]}"
|
||||
}
|
||||
|
||||
prompt_magicmace_precmd() {
|
||||
# While it would be apt to have this as a local variable in prompt_status(),
|
||||
# $? (returned value) and ${(%):-%?} ("The return status of the last command
|
||||
# executed just before the prompt") both change before executing the function.
|
||||
# Is this perhaps because prompt_status _is_ here?
|
||||
# We could also just set $? as an argument, and thus get our nifty local variable,
|
||||
# but that's stretching it, and makes the code harder to read.
|
||||
RETVAL=$?
|
||||
(( ${+functions[git-info]} )) && git-info
|
||||
}
|
||||
|
||||
prompt_magicmace_setup() {
|
||||
autoload -Uz add-zsh-hook && add-zsh-hook precmd prompt_magicmace_precmd
|
||||
autoload -Uz colors && colors
|
||||
|
||||
prompt_opts=(cr percent sp subst)
|
||||
|
||||
zstyle ':zim:git-info:branch' format '%b'
|
||||
zstyle ':zim:git-info:commit' format '%c...'
|
||||
zstyle ':zim:git-info:dirty' format '*'
|
||||
zstyle ':zim:git-info:ahead' format '↑'
|
||||
zstyle ':zim:git-info:behind' format '↓'
|
||||
zstyle ':zim:git-info:keys' format \
|
||||
'prompt' '─[${COLOR_NORMAL}%b%c%D%A%B${COLOR_USER_LEVEL}]'
|
||||
|
||||
# Call git directly, ignoring aliases under the same name.
|
||||
PS1='${COLOR_USER_LEVEL}$(prompt_magicmace_status)[${COLOR_NORMAL}$(short_pwd)${COLOR_USER_LEVEL}]$(prompt_magicmace_git)── ─%f '
|
||||
RPS1=''
|
||||
}
|
||||
|
||||
prompt_magicmace_setup "${@}"
|
|
@ -0,0 +1,88 @@
|
|||
#
|
||||
# Minimal theme
|
||||
# https://github.com/S1cK94/minimal
|
||||
#
|
||||
# Requires the `git-info` zmodule to be included in the .zimrc file.
|
||||
|
||||
# Global variables
|
||||
function {
|
||||
PROMPT_CHAR='❯'
|
||||
|
||||
ON_COLOR='%F{green}'
|
||||
OFF_COLOR='%f'
|
||||
ERR_COLOR='%F{red}'
|
||||
}
|
||||
|
||||
prompt_minimal_user() {
|
||||
print -n '%(!.${ON_COLOR}.${OFF_COLOR})${PROMPT_CHAR}'
|
||||
}
|
||||
|
||||
prompt_minimal_jobs() {
|
||||
print -n '%(1j.${ON_COLOR}.${OFF_COLOR})${PROMPT_CHAR}'
|
||||
}
|
||||
|
||||
prompt_minimal_vimode() {
|
||||
local color
|
||||
|
||||
case ${KEYMAP} in
|
||||
main|viins)
|
||||
color=${ON_COLOR}
|
||||
;;
|
||||
*)
|
||||
color=${OFF_COLOR}
|
||||
;;
|
||||
esac
|
||||
|
||||
print -n "${color}${PROMPT_CHAR}"
|
||||
}
|
||||
|
||||
prompt_minimal_status() {
|
||||
print -n '%(0?.${ON_COLOR}.${ERR_COLOR})${PROMPT_CHAR}'
|
||||
}
|
||||
|
||||
prompt_minimal_path() {
|
||||
local path_color='%F{244}'
|
||||
print -n "${path_color}${$(short_pwd)//\//%f\/${path_color}}%f"
|
||||
}
|
||||
|
||||
prompt_minimal_git() {
|
||||
if [[ -n ${git_info} ]]; then
|
||||
print -n " ${(e)git_info[color]}${(e)git_info[prompt]}"
|
||||
fi
|
||||
}
|
||||
|
||||
function zle-line-init zle-keymap-select {
|
||||
zle reset-prompt
|
||||
zle -R
|
||||
}
|
||||
|
||||
prompt_minimal_precmd() {
|
||||
(( ${+functions[git-info]} )) && git-info
|
||||
}
|
||||
|
||||
prompt_minimal_setup() {
|
||||
zle -N zle-line-init
|
||||
zle -N zle-keymap-select
|
||||
|
||||
autoload -Uz colors && colors
|
||||
autoload -Uz add-zsh-hook
|
||||
|
||||
prompt_opts=(cr percent sp subst)
|
||||
|
||||
add-zsh-hook precmd prompt_minimal_precmd
|
||||
|
||||
zstyle ':zim:git-info:branch' format '%b'
|
||||
zstyle ':zim:git-info:commit' format '%c'
|
||||
zstyle ':zim:git-info:dirty' format '${ERR_COLOR}'
|
||||
zstyle ':zim:git-info:diverged' format '${ERR_COLOR}'
|
||||
zstyle ':zim:git-info:behind' format '%F{11}'
|
||||
zstyle ':zim:git-info:ahead' format '${OFF_COLOR}'
|
||||
zstyle ':zim:git-info:keys' format \
|
||||
'prompt' '%b%c' \
|
||||
'color' '$(coalesce "%D" "%V" "%B" "%A" "${ON_COLOR}")'
|
||||
|
||||
PROMPT="$(prompt_minimal_user)$(prompt_minimal_jobs)\$(prompt_minimal_vimode)$(prompt_minimal_status)%f "
|
||||
RPROMPT='$(prompt_minimal_path)$(prompt_minimal_git)'
|
||||
}
|
||||
|
||||
prompt_minimal_setup "$@"
|
|
@ -0,0 +1,114 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
#
|
||||
# A customizable version of the steeef theme from
|
||||
# https://github.com/robbyrussell/oh-my-zsh/blob/master/themes/steeef.zsh-theme
|
||||
#
|
||||
# Requires the `git-info` zmodule to be included in the .zimrc file.
|
||||
|
||||
prompt_steeef_help () {
|
||||
cat <<EOH
|
||||
This prompt can be customized with:
|
||||
|
||||
prompt steeef [username_color] [hostname_color] [pwd_color] [branch_color]
|
||||
[unindexed_color] [unindexed_indicator]
|
||||
[indexed_color] [indexed_indicator]
|
||||
[untracked_color] [untracked_indicator]
|
||||
[stashed_color] [stashed_indicator]
|
||||
|
||||
The default values for each parameter, for 256-color terminals (or otherwise)
|
||||
are the following:
|
||||
|
||||
1. username color: 135 (or magenta)
|
||||
2. hostname color: 166 (or yellow)
|
||||
3. current working directory color: 118 (or green)
|
||||
4. git branch name color: 81 (or cyan)
|
||||
5. git unindexed color: 166 (or yellow)
|
||||
6. git unindexed indicator: ●
|
||||
7. git indexed color: 118 (or green)
|
||||
8. git indexed indicator: ●
|
||||
9. git untracked color: 161 (or red)
|
||||
10. git untracked indicator: ●
|
||||
|
||||
The git stashed color and indicator are not defined by default, and will not be
|
||||
shown unless defined.
|
||||
EOH
|
||||
}
|
||||
|
||||
prompt_steeef_git() {
|
||||
[[ -n ${git_info} ]] && print -n " ${(e)git_info[prompt]}"
|
||||
}
|
||||
|
||||
prompt_steeef_virtualenv() {
|
||||
[[ -n ${VIRTUAL_ENV} ]] && print -n " (%F{blue}${VIRTUAL_ENV:t}%f)"
|
||||
}
|
||||
|
||||
prompt_steeef_precmd() {
|
||||
(( ${+functions[git-info]} )) && git-info
|
||||
}
|
||||
|
||||
prompt_steeef_setup() {
|
||||
[[ -n ${VIRTUAL_ENV} ]] && export VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||
|
||||
local col_user
|
||||
local col_host
|
||||
local col_pwd
|
||||
local col_brnch
|
||||
local col_unidx
|
||||
local col_idx
|
||||
local col_untrk
|
||||
# use extended color palette if available
|
||||
if (( terminfo[colors] >= 256 )); then
|
||||
col_user="%F{${1:-135}}"
|
||||
col_host="%F{${2:-166}}"
|
||||
col_pwd="%F{${3:-118}}"
|
||||
col_brnch="%F{${4:-81}}"
|
||||
col_unidx="%F{${5:-166}}"
|
||||
col_idx="%F{${7:-118}}"
|
||||
col_untrk="%F{${9:-161}}"
|
||||
else
|
||||
col_user="%F{${1:-magenta}}"
|
||||
col_host="%F{${2:-yellow}}"
|
||||
col_pwd="%F{${3:-green}}"
|
||||
col_brnch="%F{${4:-cyan}}"
|
||||
col_unidx="%F{${5:-yellow}}"
|
||||
col_idx="%F{${7:-green}}"
|
||||
col_untrk="%F{${9:-red}}"
|
||||
fi
|
||||
local ind_unidx=${6:-●}
|
||||
local ind_idx=${8:-●}
|
||||
local ind_untrk=${10:-●}
|
||||
local col_stash=${11:+%F{${11}}}
|
||||
local ind_stash=${12}
|
||||
|
||||
autoload -Uz add-zsh-hook && add-zsh-hook precmd prompt_steeef_precmd
|
||||
|
||||
prompt_opts=(cr percent sp subst)
|
||||
|
||||
zstyle ':zim:git-info' verbose 'yes'
|
||||
zstyle ':zim:git-info:branch' format '%b'
|
||||
zstyle ':zim:git-info:commit' format '%c'
|
||||
zstyle ':zim:git-info:action' format "(${col_idx}%s%f)"
|
||||
zstyle ':zim:git-info:unindexed' format "${col_unidx}${ind_unidx}"
|
||||
zstyle ':zim:git-info:indexed' format "${col_idx}${ind_idx}"
|
||||
zstyle ':zim:git-info:untracked' format "${col_untrk}${ind_untrk}"
|
||||
zstyle ':zim:git-info:stashed' format "${col_stash}${ind_stash}"
|
||||
zstyle ':zim:git-info:keys' format \
|
||||
'prompt' "(${col_brnch}%b%c%I%i%u%f%S%f)%s"
|
||||
|
||||
PS1="
|
||||
${col_user}%n%f at ${col_host}%m%f in ${col_pwd}%~%f\$(prompt_steeef_git)\$(prompt_steeef_virtualenv)
|
||||
%(!.#.$) "
|
||||
RPS1=''
|
||||
}
|
||||
|
||||
prompt_steeef_preview () {
|
||||
if (( ${#} )); then
|
||||
prompt_preview_theme steeef "${@}"
|
||||
else
|
||||
prompt_preview_theme steeef
|
||||
print
|
||||
prompt_preview_theme steeef magenta yellow green cyan magenta '!' green '+' red '?' yellow '$'
|
||||
fi
|
||||
}
|
||||
|
||||
prompt_steeef_setup "${@}"
|
|
@ -0,0 +1,9 @@
|
|||
SSH
|
||||
===
|
||||
|
||||
Provides a convenient way to load ssh-agent. This enables one-time login and caching of SSH credentials per session.
|
||||
|
||||
.zimrc Configuration
|
||||
--------------------
|
||||
|
||||
* `zssh_ids=(id_rsa)` add any identities (from ~/.ssh) to this list to have them loaded and cached on login.
|
|
@ -0,0 +1,46 @@
|
|||
#
|
||||
# sets up ssh-agent
|
||||
#
|
||||
|
||||
# don't do anything unless we can actually use ssh-agent
|
||||
if (( ! ${+commands[ssh-agent]} )); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# use a sane temp dir; creating 1k ssh-* files in /tmp is crazy
|
||||
if [[ ${TMPDIR} ]]; then
|
||||
local ssh_env=${TMPDIR}/ssh-agent.env
|
||||
local ssh_sock=${TMPDIR}/ssh-agent.sock
|
||||
else
|
||||
# create a sane tmp dir at /tmp/username
|
||||
mkdir -p /tmp/${USER}
|
||||
local ssh_env=/tmp/${USER}/ssh-agent.env
|
||||
local ssh_sock=/tmp/${USER}/ssh-agent.sock
|
||||
fi
|
||||
|
||||
# start ssh-agent if not already running
|
||||
if [[ ! -S ${SSH_AUTH_SOCK} ]]; then
|
||||
# read environment if possible
|
||||
source ${ssh_env} 2> /dev/null
|
||||
|
||||
if ! ps -U ${LOGNAME} -o pid,ucomm | grep -q -- "${SSH_AGENT_PID:--1} ssh-agent"; then
|
||||
eval "$(ssh-agent | sed '/^echo /d' | tee ${ssh_env})"
|
||||
fi
|
||||
fi
|
||||
|
||||
# create socket
|
||||
if [[ -S ${SSH_AUTH_SOCKET} && ${SSH_AUTH_SOCKET} != ${ssh_sock} ]]; then
|
||||
ln -sf ${SSH_AUTH_SOCKET} ${ssh_sock}
|
||||
export SSH_AUTH_SOCK=${ssh_sock}
|
||||
fi
|
||||
|
||||
# load ids
|
||||
if ssh-add -l 2>&1 | grep -q 'no identities'; then
|
||||
if (( ${#zssh_ids} > 0 )); then
|
||||
ssh-add "${HOME}/.ssh/${^zssh_ids[@]}" 2> /dev/null
|
||||
else
|
||||
ssh-add 2> /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
unset ssh_{sock,env}
|
|
@ -0,0 +1,21 @@
|
|||
Syntax-Highlighting
|
||||
===================
|
||||
|
||||
Adds fish shell-like [syntax highlighting](https://github.com/zsh-users/zsh-syntax-highlighting) to your shell.
|
||||
|
||||
![syntax-highlighting][syntax_highlighting]
|
||||
|
||||
If you are also using [history-substring-search](https://github.com/zimfw/zimfw/blob/master/modules/history-substring-search/README.md),
|
||||
ensure you have placed 'syntax-highlighting' before 'history-substring-search' on the second line of `zmodules` in your `.zimrc`.
|
||||
|
||||
.zimrc Configuration
|
||||
--------------------
|
||||
|
||||
* `zhighlighters=(main brackets cursor)` add any highlighters you want as described [here](https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md#zsh-syntax-highlighting--highlighters).
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Contributions should be submitted [upstream to zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting)
|
||||
|
||||
[syntax_highlighting]: https://i.eriner.me/zim_syntax-highlighting.gif
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 434af7b11dd33641231f1b48b8432e68eb472e46
|
|
@ -0,0 +1,8 @@
|
|||
#
|
||||
# enables fish-shell like syntax highlighting
|
||||
#
|
||||
|
||||
# highlighters
|
||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=(${zhighlighters[@]})
|
||||
|
||||
source "${0:h}/external/zsh-syntax-highlighting.zsh" || return 1
|
|
@ -0,0 +1,48 @@
|
|||
Utility
|
||||
=======
|
||||
|
||||
Utility aliases and functions.
|
||||
|
||||
Adds colour to `ls`, `grep` and `less`.
|
||||
|
||||
Aliases
|
||||
-------
|
||||
|
||||
### ls
|
||||
|
||||
| alias | command | description |
|
||||
| ----- | ------- | ----------- |
|
||||
| `ls` | `ls --group-directories-first --color=auto` | directories first, use color (applies to all ls aliases) |
|
||||
| `l` | `ls -lAh` | all files, human-readable sizes |
|
||||
| `lm` | `l | ${PAGER}` | all files, human-readable sizes, use pager |
|
||||
| `ll` | `ls -lh` | human-readable sizes |
|
||||
| `lr` | `ll -R` | human-readable sizes, recursive |
|
||||
| `lx` | `ll -XB` | human-readable sizes, sort by extension (GNU only) |
|
||||
| `lk` | `ll -Sr` | human-readable sizes, largest last |
|
||||
| `lt` | `ll -tr` | human-readable sizes, most recent last |
|
||||
| `lc` | `lt -c` | human-readable sizes, most recent last, change time |
|
||||
|
||||
### File Downloads
|
||||
|
||||
Aliases `get` to ( `aria2c` || `axel` || `wget` || `curl` ).
|
||||
|
||||
### Resource Usage
|
||||
|
||||
| alias | command |
|
||||
| ----- | ------- |
|
||||
| `df` | `df -kh` |
|
||||
| `du` | `du -kh` |
|
||||
|
||||
### Condoms
|
||||
|
||||
| alias | command |
|
||||
| ----- | ------- |
|
||||
| `chmod` | `chmod --preserve-root -v` |
|
||||
| `chown` | `chown --preserve-root -v` |
|
||||
| `rm` | if available, `safe-rm` |
|
||||
|
||||
### Misc
|
||||
|
||||
| alias | description |
|
||||
| ----- | ----------- |
|
||||
| `mkcd` | mkdir and cd |
|
|
@ -0,0 +1 @@
|
|||
[[ -n ${1} ]] && mkdir -p ${1} && builtin cd ${1}
|
|
@ -0,0 +1,113 @@
|
|||
#
|
||||
# Utility Functions and Options
|
||||
#
|
||||
|
||||
#
|
||||
# Colours
|
||||
#
|
||||
|
||||
if (( terminfo[colors] >= 8 )); then
|
||||
|
||||
# ls Colours
|
||||
if (( ${+commands[dircolors]} )); then
|
||||
# GNU
|
||||
|
||||
(( ! ${+LS_COLORS} )) && if [[ -s ${HOME}/.dir_colors ]]; then
|
||||
eval "$(dircolors --sh ${HOME}/.dir_colors)"
|
||||
else
|
||||
export 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
|
||||
|
||||
alias ls='ls --group-directories-first --color=auto'
|
||||
|
||||
else
|
||||
# BSD
|
||||
|
||||
(( ! ${+LSCOLORS} )) && export LSCOLORS='ExfxcxdxbxGxDxabagacad'
|
||||
|
||||
# stock OpenBSD ls does not support colors at all, but colorls does.
|
||||
if [[ ${OSTYPE} == openbsd* ]]; then
|
||||
if (( ${+commands[colorls]} )); then
|
||||
alias ls='colorls -G'
|
||||
fi
|
||||
else
|
||||
alias ls='ls -G'
|
||||
fi
|
||||
fi
|
||||
|
||||
# grep Colours
|
||||
(( ! ${+GREP_COLOR} )) && export GREP_COLOR='37;45' #BSD
|
||||
(( ! ${+GREP_COLORS} )) && export GREP_COLORS="mt=${GREP_COLOR}" #GNU
|
||||
if [[ ${OSTYPE} == openbsd* ]]; then
|
||||
if (( ${+commands[ggrep]} )); then
|
||||
alias grep='ggrep --color=auto'
|
||||
fi
|
||||
else
|
||||
alias grep='grep --color=auto'
|
||||
fi
|
||||
|
||||
# less Colours
|
||||
if [[ ${PAGER} == 'less' ]]; then
|
||||
(( ! ${+LESS_TERMCAP_mb} )) && export LESS_TERMCAP_mb=$'\E[1;31m' # Begins blinking.
|
||||
(( ! ${+LESS_TERMCAP_md} )) && export LESS_TERMCAP_md=$'\E[1;31m' # Begins bold.
|
||||
(( ! ${+LESS_TERMCAP_me} )) && export LESS_TERMCAP_me=$'\E[0m' # Ends mode.
|
||||
(( ! ${+LESS_TERMCAP_se} )) && export LESS_TERMCAP_se=$'\E[0m' # Ends standout-mode.
|
||||
(( ! ${+LESS_TERMCAP_so} )) && export LESS_TERMCAP_so=$'\E[7m' # Begins standout-mode.
|
||||
(( ! ${+LESS_TERMCAP_ue} )) && export LESS_TERMCAP_ue=$'\E[0m' # Ends underline.
|
||||
(( ! ${+LESS_TERMCAP_us} )) && export LESS_TERMCAP_us=$'\E[1;32m' # Begins underline.
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# ls Aliases
|
||||
#
|
||||
|
||||
alias l='ls -lAh' # all files, human-readable sizes
|
||||
[[ -n ${PAGER} ]] && alias lm="l | ${PAGER}" # all files, human-readable sizes, use pager
|
||||
alias ll='ls -lh' # human-readable sizes
|
||||
alias lr='ll -R' # human-readable sizes, recursive
|
||||
alias lx='ll -XB' # human-readable sizes, sort by extension (GNU only)
|
||||
alias lk='ll -Sr' # human-readable sizes, largest last
|
||||
alias lt='ll -tr' # human-readable sizes, most recent last
|
||||
alias lc='lt -c' # human-readable sizes, most recent last, change time
|
||||
|
||||
|
||||
#
|
||||
# File Downloads
|
||||
#
|
||||
|
||||
# order of preference: aria2c, axel, wget, curl. This order is derrived from speed based on personal tests.
|
||||
if (( ${+commands[aria2c]} )); then
|
||||
alias get='aria2c --max-connection-per-server=5 --continue'
|
||||
elif (( ${+commands[axel]} )); then
|
||||
alias get='axel --num-connections=5 --alternate'
|
||||
elif (( ${+commands[wget]} )); then
|
||||
alias get='wget --continue --progress=bar --timestamping'
|
||||
elif (( ${+commands[curl]} )); then
|
||||
alias get='curl --continue-at - --location --progress-bar --remote-name --remote-time'
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Resource Usage
|
||||
#
|
||||
|
||||
alias df='df -kh'
|
||||
alias du='du -kh'
|
||||
|
||||
|
||||
#
|
||||
# Always wear a condom
|
||||
#
|
||||
|
||||
if [[ ${OSTYPE} == linux* ]]; then
|
||||
alias chmod='chmod --preserve-root -v'
|
||||
alias chown='chown --preserve-root -v'
|
||||
fi
|
||||
|
||||
# not aliasing rm -i, but if safe-rm is available, use condom.
|
||||
# if safe-rmdir is available, the OS is suse which has its own terrible 'safe-rm' which is not what we want
|
||||
if (( ${+commands[safe-rm]} && ! ${+commands[safe-rmdir]} )); then
|
||||
alias rm='safe-rm'
|
||||
fi
|
|
@ -0,0 +1,92 @@
|
|||
|
||||
|
||||
#################
|
||||
# CORE SETTINGS #
|
||||
#################
|
||||
|
||||
#
|
||||
# Zim settings
|
||||
#
|
||||
|
||||
# Select what modules you would like enabled.
|
||||
# The second line of modules may depend on options set by modules in the first
|
||||
# line. These dependencies are noted on the respective module's README.md.
|
||||
zmodules=(directory environment git git-info history input utility custom \
|
||||
syntax-highlighting history-substring-search prompt completion)
|
||||
|
||||
|
||||
###################
|
||||
# MODULE SETTINGS #
|
||||
###################
|
||||
|
||||
#
|
||||
# Prompt
|
||||
#
|
||||
|
||||
# Set your desired prompt here
|
||||
zprompt_theme='steeef'
|
||||
|
||||
#
|
||||
# Completion
|
||||
#
|
||||
|
||||
# set an optional host-specific filename for the completion cache file
|
||||
# if none is provided, the default '.zcompdump' is used.
|
||||
#zcompdump_file=".zcompdump-${HOST}-${ZSH_VERSION}"
|
||||
|
||||
#
|
||||
# Utility
|
||||
#
|
||||
|
||||
# Uncomment to enable command correction prompts
|
||||
# See: http://zsh.sourceforge.net/Doc/Release/Options.html#Input_002fOutput
|
||||
#setopt CORRECT
|
||||
|
||||
#
|
||||
# Environment
|
||||
#
|
||||
|
||||
# Set the string below to the desired terminal title format string.
|
||||
# The terminal title is redrawn upon directory change, however, variables like
|
||||
# ${PWD} are only evaluated once. Use prompt expansion strings for dynamic data:
|
||||
# http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Simple-Prompt-Escapes
|
||||
# The example below uses the following format: 'username@host:/current/directory'
|
||||
ztermtitle='%n@%m:%~'
|
||||
|
||||
#
|
||||
# Input
|
||||
#
|
||||
|
||||
# Uncomment to enable double-dot expansion.
|
||||
# This appends '../' to your input for each '.' you type after an initial '..'
|
||||
#zdouble_dot_expand='true'
|
||||
|
||||
#
|
||||
# Syntax-Highlighting
|
||||
#
|
||||
|
||||
# This determines what highlighters will be used with the syntax-highlighting module.
|
||||
# Documentation of the highlighters can be found here:
|
||||
# https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
|
||||
# For (u)rxvt, termite and gnome-terminal users,
|
||||
# removing the 'cursor' highlighter will fix the disappearing cursor problem
|
||||
zhighlighters=(main brackets cursor)
|
||||
|
||||
|
||||
#
|
||||
# SSH
|
||||
#
|
||||
|
||||
# Load these ssh identities with the ssh module
|
||||
#zssh_ids=(id_rsa)
|
||||
|
||||
|
||||
#
|
||||
# Pacman
|
||||
#
|
||||
|
||||
# Set (optional) pacman front-end.
|
||||
#zpacman_frontend='powerpill'
|
||||
|
||||
# Load any helper scripts as defined here
|
||||
#zpacman_helper=(aur)
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
|
||||
#
|
||||
# User configuration sourced by login shells
|
||||
#
|
||||
|
||||
# Initialize zim
|
||||
[[ -s ${ZIM_HOME}/login_init.zsh ]] && source ${ZIM_HOME}/login_init.zsh
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
|
||||
#
|
||||
# User configuration sourced by interactive shells
|
||||
#
|
||||
|
||||
# Change default zim location
|
||||
export ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim
|
||||
|
||||
# Start zim
|
||||
[[ -s ${ZIM_HOME}/init.zsh ]] && source ${ZIM_HOME}/init.zsh
|
|
@ -0,0 +1,7 @@
|
|||
#
|
||||
# zim_build_cache - rebuilds the zim cache
|
||||
#
|
||||
|
||||
source ${ZIM_HOME}/login_init.zsh
|
||||
|
||||
print 'To rebuild the completion cache, please restart your terminal'
|
|
@ -0,0 +1,7 @@
|
|||
#
|
||||
# zim_clean_cache - removes all zcompiled files
|
||||
#
|
||||
|
||||
find ${ZIM_HOME} \( -name '*.zwc' -or -name '*.zwc.old' \) -delete
|
||||
rm -f ${ZDOTDIR:-${HOME}}/.zshrc.zwc{,.old}
|
||||
rm -f ${ZDOTDIR:-${HOME}}/${zcompdump_file:-.zcompdump}{,.zwc{,.old}}
|
|
@ -0,0 +1,9 @@
|
|||
#
|
||||
# zim_info - prints zim and system info
|
||||
#
|
||||
|
||||
cd ${ZIM_HOME}
|
||||
|
||||
print "Zim commit ref: $(command git rev-parse --short HEAD)"
|
||||
print "Zsh version: $(command zsh --version)"
|
||||
print "System info: $(command uname -a)"
|
|
@ -0,0 +1,65 @@
|
|||
#
|
||||
# zim_info - easily create an issue template
|
||||
#
|
||||
|
||||
# create our 'pause' function
|
||||
waiter_func() {
|
||||
local input_key
|
||||
read -sk \?"Press [Enter] to continue; anything else to quit." input_key
|
||||
if [[ ${input_key} == $'\n' ]]; then
|
||||
print "\r "
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# print init dialog
|
||||
print "Please check the existing issues to make sure you\'re not duplicating a report"
|
||||
print "https://github.com/zimfw/zimfw/issues"
|
||||
|
||||
# if they don't accept, bail
|
||||
if ! waiter_func; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# for convenience, this is our new home
|
||||
cd ${ZIM_HOME}
|
||||
|
||||
# collect sys info
|
||||
local git_dirty=$(command git status --porcelain 2>/dev/null | tail -n1)
|
||||
local zim_info=$(zsh tools/zim_info)
|
||||
|
||||
print "Environment Info
|
||||
----------------
|
||||
${zim_info}
|
||||
|
||||
Description
|
||||
-----------
|
||||
${user_desc}
|
||||
|
||||
Steps to Reproduce
|
||||
------------------
|
||||
${user_reproduce}
|
||||
|
||||
Images or other Information
|
||||
---------------------------
|
||||
"
|
||||
|
||||
|
||||
# if we have a dirty git, report it
|
||||
if [[ -n ${git_dirty} ]]; then
|
||||
print "${ZIM_HOME} has a dirty git working tree."
|
||||
print "here is the diff:"
|
||||
print '```'
|
||||
print $(command git diff)
|
||||
print '```'
|
||||
fi
|
||||
|
||||
|
||||
print '\n\n'
|
||||
print 'Please copy the above and use this when reporting the issue\n'
|
||||
|
||||
# optionally, now we can produce debug info
|
||||
print 'If you would like to produce some helpful logs about your environment, run:'
|
||||
print '$ zmanage debug'
|
|
@ -0,0 +1,13 @@
|
|||
#
|
||||
# zim_remove - removes zim from the system
|
||||
#
|
||||
# Note: this doesn't remove _everything_. It removes as much as
|
||||
# possible while maintaining safety (don't delete custom user content).
|
||||
#
|
||||
|
||||
sed '/# Source zim/,/fi/d' ${ZDOTDIR:-${HOME}}/.zshrc
|
||||
sed '/# The following code helps/,/) &!/d' ${ZDOTDIR:-${HOME}}/.zlogin
|
||||
rm -f ${ZDOTDIR:-${HOME}}/.zimrc
|
||||
|
||||
# not forcing this one, as it is recursive. It's possible something went wrong.
|
||||
rm -r ${ZIM_HOME}
|
|
@ -0,0 +1,6 @@
|
|||
#
|
||||
# zim_reset - resets the zim repository to latest commit
|
||||
#
|
||||
|
||||
cd ${ZIM_HOME}
|
||||
git reset --hard
|
|
@ -0,0 +1,11 @@
|
|||
#
|
||||
# zim_update - update the zim repository
|
||||
#
|
||||
|
||||
cd ${ZIM_HOME}
|
||||
|
||||
# this is the cleanest way I know how to update a repository
|
||||
git remote update -p
|
||||
git merge --ff-only @\{u\}
|
||||
# and update the submodules
|
||||
git submodule update --init --recursive
|
Loading…
Reference in New Issue