1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-01-09 21:38:32 +08:00

Compare commits

...

19 Commits

Author SHA1 Message Date
Joshua Bedford
4cd5f7f920
Add lando plugin (#8748)
Co-authored-by: Joshua Bedford <joshua.bedford@hurstreview.com>
Co-authored-by: Marc Cornellà <marc.cornella@live.com>
2020-10-09 23:13:00 +02:00
James Zhang
a5e706d749
mvn: list modules (directories with pom.xml) (#8478)
Co-authored-by: zhangjinyan1 <zhangjinyan1@guazi.com>
2020-10-09 17:45:30 +02:00
Geoffrey GREBERT
e93a2dca0e
mvn: add Quarkus support in mvn completion (#9037)
Co-authored-by: Geoffrey GREBERT <ggrebert@sii.fr>
2020-10-09 17:42:44 +02:00
Atk
2abe4d6a25
wd: update to v0.5.1 (#9273) 2020-10-09 17:38:02 +02:00
Danny Grove
8c8fe2a171 nvm: add autoloading of nvm version in .nvmrc
Closes #5782
Fixes #8959
Closes #8976
2020-10-09 17:21:03 +02:00
Marc Cornellà
8163f65084 nvm: exit the plugin if the nvm loading script wasn't found 2020-10-09 17:21:03 +02:00
Marc Cornellà
a33c0cdb46 nvm: only lazy-load nvm if the NVM_LAZY setting is set 2020-10-09 17:21:03 +02:00
Keith Yao
3e97308003 nvm: speed-up nvm loading with --no-use
Closes #7138

Co-authored-by: Marc Cornellà <marc.cornella@live.com>
2020-10-09 17:21:03 +02:00
Chigozirim C
d6f3630932 nvm: check $XDG_CONFIG_HOME/nvm for an nvm installation
Closes #7807

Co-authored-by: Marc Cornellà <marc.cornella@live.com>
2020-10-09 17:21:03 +02:00
Marc Cornellà
d8cb670235 nvm: simplify nvm.sh and bash completion loading 2020-10-09 17:21:03 +02:00
Andrew Janke
ef44416df2 nvm: use nvm current in nvm_prompt_info and look in alternate install locations
This makes it work regardless of where nvm is loaded from. And it uses nvm's
version strings, which distinguish the "system" and "none" NVM environments,
instead of reporting the specific version of the system node.js or erroring,
respectively.

Fixes #4336
Closes #4338
2020-10-09 17:21:03 +02:00
Marc Cornellà
fc6c9ca4b4 lib: fix formatting in omz pr clean CLI command 2020-10-09 15:03:03 +02:00
Marc Cornellà
1bb402190d lib: add plugin and theme subcommands and fix omz pr clean
- Add plugin and theme subcommand

  Fixes #8961

- Add confirmation prompt to `omz pr clean` command

- Correct behavior on invalid answers on confirmation prompts

  If an invalid option is supplied, don't proceed with the potentially
  destructive action.

Co-authored-by: Rishabh Bohra <rishabhbohra01@gmail.com>
2020-10-09 13:55:56 +02:00
Marc Cornellà
6811a48618 Merge branch 'TheDauthi/enhanced-status-prompt' (#5531)
Closes #5531
2020-10-09 13:45:29 +02:00
Marc Cornellà
865f6572d5 Fix performance drop of iterating over lines and other stuff
- Fix 'STASHED' key and unsupported syntax in 5.0.2
- Optimise `if` statement to make it more idiomatic.
2020-10-09 13:44:50 +02:00
Billy Conn
45a954cb0f git_prompt_status now uses hash lookups instead of multiple greps 2020-10-09 13:24:37 +02:00
Michał Dębski
297238b739 lib: hide git_prompt_status when hide-status is set
Closes #4912
Closes #5137
Closes #8071
2020-10-09 13:14:44 +02:00
Tom Hale
df58625ca6
safe-paste: refresh plugin (update for zsh 5.1 and vi keymaps) (#7887) 2020-10-09 12:39:23 +02:00
Duc Nguyen
8ad9b315a3
Add git-lfs plugin (#9077) 2020-10-09 12:35:13 +02:00
15 changed files with 566 additions and 117 deletions

1
.github/CODEOWNERS vendored
View File

@ -1,3 +1,4 @@
# Plugin owners
plugins/gitfast/ @felipec
plugins/sdk/ @rgoldberg
plugins/git-lfs/ @vietduc01100001

View File

@ -23,16 +23,27 @@ function _omz {
local -a cmds subcmds
cmds=(
'help:Usage information'
'plugin:Commands for Oh My Zsh plugins management'
'pr:Commands for Oh My Zsh Pull Requests management'
'theme:Commands for Oh My Zsh themes management'
'update:Update Oh My Zsh'
'pr:Commands for Oh My Zsh Pull Requests'
)
if (( CURRENT == 2 )); then
_describe 'command' cmds
elif (( CURRENT == 3 )); then
case "$words[2]" in
pr) subcmds=( 'test:Test a Pull Request' 'clean:Delete all Pull Request branches' )
plugin) subcmds=('list:List plugins')
_describe 'command' subcmds ;;
pr) subcmds=('test:Test a Pull Request' 'clean:Delete all Pull Request branches')
_describe 'command' subcmds ;;
theme) subcmds=('use:Load a theme' 'list:List themes')
_describe 'command' subcmds ;;
esac
elif (( CURRENT == 4 )); then
case "$words[2]::$words[3]" in
theme::use) compadd "$ZSH"/themes/*.zsh-theme(.N:t:r) \
"$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::) ;;
esac
fi
@ -49,23 +60,40 @@ Usage: omz <command> [options]
Available commands:
help Print this help message
pr <command> Commands for Oh My Zsh Pull Requests management
theme <command> Commands for Oh My Zsh themes management
update Update Oh My Zsh
pr <command> Commands for Oh My Zsh Pull Requests
EOF
}
function _omz::confirm {
# If question supplied, ask it before reading the answer
# NOTE: uses the logname of the caller function
if [[ -n "$1" ]]; then
_omz::log prompt "$1" "${${functrace[1]#_}%:*}"
fi
# Read one character
read -r -k 1
# If no newline entered, add a newline
if [[ "$REPLY" != $'\n' ]]; then
echo
fi
}
function _omz::log {
# if promptsubst is set, a message with `` or $()
# will be run even if quoted due to `print -P`
setopt localoptions nopromptsubst
# $1 = info|warn|error|debug
# $@ = text
# $2 = text
# $3 = (optional) name of the logger
local logtype=$1
local logname=${${functrace[1]#_}%:*}
shift
local logname=${3:-${${functrace[1]#_}%:*}}
# Don't print anything if debug is not active
if [[ $logtype = debug && -z $_OMZ_DEBUG ]]; then
@ -74,14 +102,52 @@ function _omz::log {
# Choose coloring based on log type
case "$logtype" in
prompt) print -Pn "%S%F{blue}$logname%f%s: $@" ;;
debug) print -P "%F{white}$logname%f: $@" ;;
info) print -P "%F{green}$logname%f: $@" ;;
warn) print -P "%S%F{yellow}$logname%f%s: $@" ;;
error) print -P "%S%F{red}$logname%f%s: $@" ;;
prompt) print -Pn "%S%F{blue}$logname%f%s: $2" ;;
debug) print -P "%F{white}$logname%f: $2" ;;
info) print -P "%F{green}$logname%f: $2" ;;
warn) print -P "%S%F{yellow}$logname%f%s: $2" ;;
error) print -P "%S%F{red}$logname%f%s: $2" ;;
esac >&2
}
function _omz::plugin {
(( $# > 0 && $+functions[_omz::plugin::$1] )) || {
cat <<EOF
Usage: omz plugin <command> [options]
Available commands:
list List all available Oh My Zsh plugins
EOF
return 1
}
local command="$1"
shift
_omz::plugin::$command "$@"
}
function _omz::plugin::list {
local -a custom_plugins builtin_plugins
custom_plugins=("$ZSH_CUSTOM"/plugins/*(/N:t))
builtin_plugins=("$ZSH"/plugins/*(/N:t))
(( ${#custom_plugins} )) && {
print -Pn "%U%BCustom plugins%b%u: "
print -l ${(q-)custom_plugins}
} | fmt -w $COLUMNS
(( ${#builtin_plugins} )) && {
# add a line of separation
(( ${#custom_plugins} )) && echo
print -Pn "%U%BBuilt-in plugins%b%u: "
print -l ${(q-)builtin_plugins}
} | fmt -w $COLUMNS
}
function _omz::pr {
(( $# > 0 && $+functions[_omz::pr::$1] )) || {
cat <<EOF
@ -107,6 +173,24 @@ function _omz::pr::clean {
set -e
builtin cd -q "$ZSH"
# Check if there are PR branches
local fmt branches
fmt="%(color:bold blue)%(align:18,right)%(refname:short)%(end)%(color:reset) %(color:dim bold red)%(objectname:short)%(color:reset) %(color:yellow)%(contents:subject)"
branches="$(command git for-each-ref --sort=-committerdate --color --format="$fmt" "refs/heads/ohmyzsh/pull-*")"
# Exit if there are no PR branches
if [[ -z "$branches" ]]; then
_omz::log info "there are no Pull Request branches to remove."
return
fi
# Print found PR branches
echo "$branches\n"
# Confirm before removing the branches
_omz::confirm "do you want remove these Pull Request branches? [Y/n] "
# Only proceed if the answer is a valid yes option
[[ "$REPLY" != [yY$'\n'] ]] && return
_omz::log info "removing all Oh My Zsh Pull Request branches..."
command git branch --list 'ohmyzsh/pull-*' | while read branch; do
command git branch -D "$branch"
@ -181,13 +265,9 @@ function _omz::pr::test {
command zsh -l
# After testing, go back to the previous HEAD if the user wants
_omz::log prompt "do you want to go back to the previous branch? [Y/n] "
read -r -k 1
# If no newline entered, add a newline
[[ "$REPLY" != $'\n' ]] && echo
# If NO selected, do nothing else
[[ "$REPLY" = [nN] ]] && return
_omz::confirm "do you want to go back to the previous branch? [Y/n] "
# Only proceed if the answer is a valid yes option
[[ "$REPLY" != [yY$'\n'] ]] && return
(
set -e
@ -200,6 +280,64 @@ function _omz::pr::test {
)
}
function _omz::theme {
(( $# > 0 && $+functions[_omz::theme::$1] )) || {
cat <<EOF
Usage: omz theme <command> [options]
Available commands:
list List all available Oh My Zsh themes
use <theme> Load an Oh My Zsh theme
EOF
return 1
}
local command="$1"
shift
_omz::theme::$command "$@"
}
function _omz::theme::list {
local -a custom_themes builtin_themes
custom_themes=("$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
builtin_themes=("$ZSH"/themes/*.zsh-theme(.N:t:r))
(( ${#custom_themes} )) && {
print -Pn "%U%BCustom themes%b%u: "
print -l ${(q-)custom_themes}
} | fmt -w $COLUMNS
(( ${#builtin_themes} )) && {
# add a line of separation
(( ${#custom_themes} )) && echo
print -Pn "%U%BBuilt-in themes%b%u: "
print -l ${(q-)builtin_themes}
} | fmt -w $COLUMNS
}
function _omz::theme::use {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz theme use <theme>"
return 1
fi
# Respect compatibility with old lookup order
if [[ -f "$ZSH_CUSTOM/$1.zsh-theme" ]]; then
source "$ZSH_CUSTOM/$1.zsh-theme"
elif [[ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]]; then
source "$ZSH_CUSTOM/themes/$1.zsh-theme"
elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then
source "$ZSH/themes/$1.zsh-theme"
else
_omz::log error "theme '$1' not found"
return 1
fi
}
function _omz::update {
# Run update script
env ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh"

View File

@ -147,44 +147,102 @@ function git_prompt_long_sha() {
SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
}
# Get the status of the working tree
function git_prompt_status() {
emulate -L zsh
[[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return
local INDEX STATUS
INDEX=$(__git_prompt_git status --porcelain -b 2> /dev/null) || return 0
STATUS=""
if [[ "${INDEX}" =~ $'(^|\n)\\?\\? ' ]]; then
STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
# Maps a git status prefix to an internal constant
# This cannot use the prompt constants, as they may be empty
local -A prefix_constant_map
prefix_constant_map=(
'\?\? ' 'UNTRACKED'
'A ' 'ADDED'
'M ' 'ADDED'
'MM ' 'ADDED'
' M ' 'MODIFIED'
'AM ' 'MODIFIED'
' T ' 'MODIFIED'
'R ' 'RENAMED'
' D ' 'DELETED'
'D ' 'DELETED'
'UU ' 'UNMERGED'
'ahead' 'AHEAD'
'behind' 'BEHIND'
'diverged' 'DIVERGED'
'stashed' 'STASHED'
)
# Maps the internal constant to the prompt theme
local -A constant_prompt_map
constant_prompt_map=(
'UNTRACKED' "$ZSH_THEME_GIT_PROMPT_UNTRACKED"
'ADDED' "$ZSH_THEME_GIT_PROMPT_ADDED"
'MODIFIED' "$ZSH_THEME_GIT_PROMPT_MODIFIED"
'RENAMED' "$ZSH_THEME_GIT_PROMPT_RENAMED"
'DELETED' "$ZSH_THEME_GIT_PROMPT_DELETED"
'UNMERGED' "$ZSH_THEME_GIT_PROMPT_UNMERGED"
'AHEAD' "$ZSH_THEME_GIT_PROMPT_AHEAD"
'BEHIND' "$ZSH_THEME_GIT_PROMPT_BEHIND"
'DIVERGED' "$ZSH_THEME_GIT_PROMPT_DIVERGED"
'STASHED' "$ZSH_THEME_GIT_PROMPT_STASHED"
)
# The order that the prompt displays should be added to the prompt
local status_constants
status_constants=(
UNTRACKED ADDED MODIFIED RENAMED DELETED
STASHED UNMERGED AHEAD BEHIND DIVERGED
)
local status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)"
# Don't continue on a catastrophic failure
if [[ $? -eq 128 ]]; then
return 1
fi
if [[ "${INDEX}" =~ $'(^|\n)(A |M |MM) ' ]]; then
STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
# A lookup table of each git status encountered
local -A statuses_seen
if __git_prompt_git rev-parse --verify refs/stash &>/dev/null; then
statuses_seen[STASHED]=1
fi
if [[ "${INDEX}" =~ $'(^|\n)([ AM]M| T) ' ]]; then
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
local status_lines
status_lines=("${(@f)${status_text}}")
# If the tracking line exists, get and parse it
if [[ "$status_lines[1]" =~ "^## [^ ]+ \[(.*)\]" ]]; then
local branch_statuses
branch_statuses=("${(@s/,/)match}")
for branch_status in $branch_statuses; do
if [[ ! $branch_status =~ "(behind|diverged|ahead) ([0-9]+)?" ]]; then
continue
fi
local last_parsed_status=$prefix_constant_map[$match[1]]
statuses_seen[$last_parsed_status]=$match[2]
done
fi
if [[ "${INDEX}" =~ $'(^|\n)R ' ]]; then
STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS"
fi
if [[ "${INDEX}" =~ $'(^|\n)([A ]D|D ) ' ]]; then
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
fi
if $(__git_prompt_git rev-parse --verify refs/stash >/dev/null 2>&1); then
STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS"
fi
if [[ "${INDEX}" =~ $'(^|\n)UU ' ]]; then
STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
fi
if [[ "${INDEX}" =~ $'(^|\n)## [^ ]\+ .*ahead' ]]; then
STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS"
fi
if [[ "${INDEX}" =~ $'(^|\n)## [^ ]\+ .*behind' ]]; then
STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS"
fi
if [[ "${INDEX}" =~ $'(^|\n)## [^ ]\+ .*diverged' ]]; then
STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS"
fi
echo $STATUS
# For each status prefix, do a regex comparison
for status_prefix in ${(k)prefix_constant_map}; do
local status_constant="${prefix_constant_map[$status_prefix]}"
local status_regex="(^|\n)$status_prefix"
if [[ "$status_text" =~ $status_regex ]]; then
statuses_seen[$status_constant]=1
fi
done
# Display the seen statuses in the order specified
local status_prompt
for status_constant in $status_constants; do
if (( ${+statuses_seen[$status_constant]} )); then
local next_display=$constant_prompt_map[$status_constant]
status_prompt="$next_display$status_prompt"
fi
done
echo $status_prompt
}
# Outputs the name of the current user

View File

@ -1,9 +1,6 @@
# get the node.js version
# get the nvm-controlled node.js version
function nvm_prompt_info() {
[[ -f "$NVM_DIR/nvm.sh" ]] || return
local nvm_prompt
nvm_prompt=$(node -v 2>/dev/null)
[[ "${nvm_prompt}x" == "x" ]] && return
nvm_prompt=${nvm_prompt:1}
which nvm &>/dev/null || return
local nvm_prompt=${$(nvm current)#v}
echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${ZSH_THEME_NVM_PROMPT_SUFFIX}"
}

24
plugins/git-lfs/README.md Normal file
View File

@ -0,0 +1,24 @@
# git lfs plugin
The git lfs plugin provides [aliases](#aliases) and [functions](#functions) for [git-lfs](https://github.com/git-lfs/git-lfs).
To use it, add `git-lfs` to the plugins array in your zshrc file:
```zsh
plugins=(... git-lfs)
```
## Aliases
| Alias | Command |
| :------- | :---------------------------------- |
| `glfsi` | `git lfs install` |
| `glfst` | `git lfs track` |
| `glfsls` | `git lfs ls-files` |
| `glfsmi` | `git lfs migrate import --include=` |
## Functions
| Function | Command |
| :------- | :---------------------------------------------- |
| `gplfs` | `git lfs push origin "$(current_branch)" --all` |

View File

@ -0,0 +1,17 @@
#
# Aliases
#
alias glfsi='git lfs install'
alias glfst='git lfs track'
alias glfsls='git lfs ls-files'
alias glfsmi='git lfs migrate import --include='
#
# Functions
#
function gplfs() {
local b="$(git_current_branch)"
git lfs push origin "$b" --all
}

21
plugins/lando/LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Joshua Bedford
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.

37
plugins/lando/README.md Normal file
View File

@ -0,0 +1,37 @@
# Lando ZSH (lando-zsh)
This plugin adds aliases for using various languages and frameworks with [Lando](https://docs.lando.dev/basics/) for Docker. It will only run within lando-driven project directories.
To use it, add `lando` to the plugins array in your zshrc file:
```zsh
plugins=(... lando)
```
## ALIASES:
| Alias | Description |
|:----------:|:----------------:|
| `artisan` | `lando artisan` |
| `composer` | `lando composer` |
| `drush` | `lando drush` |
| `gulp` | `lando gulp` |
| `npm` | `lando npm` |
| `wp` | `lando wp` |
| `yarn` | `lando yarn` |
## How It Works:
This plugin removes the requirement to type `lando` before a command. It utilizes the lando version of supported commands run within directories with the following criteria:
- The `.lando.yml` file is found in the current directory or any parent directory within `$LANDO_ZSH_SITES_DIRECTORY`.
- The current directory is within `$LANDO_ZSH_SITES_DIRECTORY` but is not `$LANDO_ZSH_SITES_DIRECTORY` itself.
## Settings:
- `LANDO_ZSH_SITES_DIRECTORY`: The plugin will stop searching through parents for `CONFIG_FILE` once it hits this directory.
- `LANDO_ZSH_CONFIG_FILE`: The plugin will check to see if this provided file exists to check for presence of Lando.
## Author:
- Author: Joshua Bedford
- URL: [https://github.com/joshuabedford/lando-zsh](https://github.com/joshuabedford/lando-zsh)

View File

@ -0,0 +1,40 @@
# Settings
: ${LANDO_ZSH_SITES_DIRECTORY:="$HOME/Sites"}
: ${LANDO_ZSH_CONFIG_FILE:=.lando.yml}
# Enable multiple commands with lando.
function artisan \
composer \
drush \
gulp \
npm \
wp \
yarn {
if checkForLandoFile; then
lando "$0" "$@"
else
command "$0" "$@"
fi
}
# Check for the file in the current and parent directories.
checkForLandoFile() {
# Only bother checking for lando within the Sites directory.
if [[ "$PWD/" != "$LANDO_ZSH_SITES_DIRECTORY"/* ]]; then
# Not within $LANDO_ZSH_SITES_DIRECTORY
return 1
fi
local curr_dir="$PWD"
# Checking for file: $LANDO_ZSH_CONFIG_FILE within $LANDO_ZSH_SITES_DIRECTORY...
while [[ "$curr_dir" != "$LANDO_ZSH_SITES_DIRECTORY" ]]; do
if [[ -f "$curr_dir/$LANDO_ZSH_CONFIG_FILE" ]]; then
return 0
fi
curr_dir="${curr_dir:h}"
done
# Could not find $LANDO_ZSH_CONFIG_FILE in the current directory
# or in any of its parents up to $LANDO_ZSH_SITES_DIRECTORY.
return 1
}

View File

@ -19,6 +19,7 @@ if it's found, or the mvn command otherwise.
| `mvn!` | `mvn -f <root>/pom.xml` |
| `mvnag` | `mvn archetype:generate` |
| `mvnboot` | `mvn spring-boot:run` |
| `mvnqdev` | `mvn quarkus:dev` |
| `mvnc` | `mvn clean` |
| `mvncd` | `mvn clean deploy` |
| `mvnce` | `mvn clean eclipse:clean eclipse:eclipse` |

View File

@ -62,6 +62,7 @@ alias mvne='mvn eclipse:eclipse'
alias mvnfmt='mvn fmt:format'
alias mvnjetty='mvn jetty:run'
alias mvnp='mvn package'
alias mvnqdev='mvn quarkus:dev'
alias mvns='mvn site'
alias mvnsrc='mvn dependency:sources'
alias mvnt='mvn test'
@ -72,7 +73,7 @@ alias mvn-updates='mvn versions:display-dependency-updates'
function listMavenCompletions {
local file new_file
local -a profiles POM_FILES
local -a profiles POM_FILES modules
# Root POM
POM_FILES=(~/.m2/settings.xml)
@ -108,6 +109,9 @@ function listMavenCompletions {
profiles+=($(sed 's/<!--.*-->//' "$file" | sed '/<!--/,/-->/d' | grep -e "<profile>" -A 1 | grep -e "<id>.*</id>" | sed 's?.*<id>\(.*\)<\/id>.*?-P\1?'))
done
# List modules
modules=($(find **/pom.xml -type f | grep -v '/target/classes/META-INF/' | grep '/pom.xml' |sed 's|\(.*\)/pom\.xml|\1|'))
reply=(
# common lifecycle
clean initialize process-resources compile process-test-resources test-compile test package verify install deploy site
@ -184,6 +188,8 @@ function listMavenCompletions {
tomee:run tomee:run-war tomee:run-war-only tomee:stop tomee:deploy tomee:undeploy
# spring-boot
spring-boot:run spring-boot:repackage
# quarkus
quarkus:dev quarkus:list-extensions quarkus:add-extension quarkus:add-extensions quarkus:generate-config quarkus:help
# exec
exec:exec exec:java
# versions
@ -268,8 +274,8 @@ function listMavenCompletions {
stage:copy
# toolchain
toolchain:toolchain
#liberty
liberty:clean-server liberty:compile-jsp liberty:configure-arquillian liberty:create-server liberty:debug liberty:debug-server liberty:deploy liberty:dev liberty:display-url liberty:dump-server liberty:install-apps liberty:install-feature liberty:install-server liberty:java-dump-server liberty:package-server liberty:run liberty:run-server liberty:server-status liberty:start liberty:start-server liberty:status liberty:stop liberty:stop-server liberty:test-start-server liberty:test-stop-server liberty:undeploy liberty:uninstall-feature
#liberty
liberty:clean-server liberty:compile-jsp liberty:configure-arquillian liberty:create-server liberty:debug liberty:debug-server liberty:deploy liberty:dev liberty:display-url liberty:dump-server liberty:install-apps liberty:install-feature liberty:install-server liberty:java-dump-server liberty:package-server liberty:run liberty:run-server liberty:server-status liberty:start liberty:start-server liberty:status liberty:stop liberty:stop-server liberty:test-start-server liberty:test-stop-server liberty:undeploy liberty:uninstall-feature
# options
"-Dmaven.test.skip=true" -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile "-Dpmd.skip=true" "-Dcheckstyle.skip=true" "-Dtycho.mode=maven" "-Dmaven.test.failure.ignore=true" "-DgroupId=" "-DartifactId=" "-Dversion=" "-Dpackaging=jar" "-Dfile="
@ -320,6 +326,7 @@ function listMavenCompletions {
-Dit.test=$(if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dit.test=\1?' ; fi)
$profiles
$modules
)
}

View File

@ -16,3 +16,11 @@ plugins=(... nvm)
- **`NVM_HOMEBREW`**: if you installed nvm via Homebrew, in a directory other than `/usr/local/opt/nvm`, you
can set `NVM_HOMEBREW` to be the directory where you installed it.
- **`NVM_LAZY`**: if you want the plugin to defer the load of nvm to speed-up the start of your zsh session,
set `NVM_LAZY` to `1`. This will use the `--no-use` parameter when loading nvm, and will create a function
for `node`, `npm` and `yarn`, so when you call either of these three, nvm will load with `nvm use default`.
- **`NVM_AUTOLOAD`**: if `NVM_AUTOLOAD` is set to `1`, the plugin will automatically load a node version when
if finds a [`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating
which node version to load.

View File

@ -1,23 +1,77 @@
# Set NVM_DIR if it isn't already defined
[[ -z "$NVM_DIR" ]] && export NVM_DIR="$HOME/.nvm"
# See https://github.com/nvm-sh/nvm#installation-and-update
if [[ -z "$NVM_DIR" ]]; then
if [[ -d "$HOME/.nvm" ]]; then
export NVM_DIR="$HOME/.nvm"
elif [[ -d "${XDG_CONFIG_HOME:-$HOME/.config}/nvm" ]]; then
export NVM_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/nvm"
fi
fi
# Don't try to load nvm if command already available
type "nvm" &> /dev/null && return
which nvm &> /dev/null && return
# Load nvm if it exists in $NVM_DIR
if [[ -f "$NVM_DIR/nvm.sh" ]]; then
source "$NVM_DIR/nvm.sh"
# Load nvm if it exists in $NVM_DIR
source "$NVM_DIR/nvm.sh" ${NVM_LAZY+"--no-use"}
else
# Otherwise try to load nvm installed via Homebrew
# User can set this if they have an unusual Homebrew setup
NVM_HOMEBREW="${NVM_HOMEBREW:-/usr/local/opt/nvm}"
# Load nvm from Homebrew location if it exists
if [[ -f "$NVM_HOMEBREW/nvm.sh" ]]; then
source "$NVM_HOMEBREW/nvm.sh" ${NVM_LAZY+"--no-use"}
else
# Exit the plugin if we couldn't find nvm
return
fi
fi
# Otherwise try to load nvm installed via Homebrew
# Call nvm when first using node, npm or yarn
if (( $+NVM_LAZY )); then
function node npm yarn {
unfunction node npm yarn
nvm use default
command "$0" "$@"
}
fi
# User can set this if they have an unusual Homebrew setup
NVM_HOMEBREW="${NVM_HOMEBREW:-/usr/local/opt/nvm}"
# Load nvm from Homebrew location if it exists
[[ -f "$NVM_HOMEBREW/nvm.sh" ]] && source "$NVM_HOMEBREW/nvm.sh"
# Load nvm bash completion from Homebrew if it exists
if [[ -f "$NVM_HOMEBREW/etc/bash_completion.d/nvm" ]]; then
# Autoload nvm when finding a .nvmrc file in the current directory
# Adapted from: https://github.com/nvm-sh/nvm#zsh
if (( $+NVM_AUTOLOAD )); then
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [[ -n "$nvmrc_path" ]]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [[ "$nvmrc_node_version" = "N/A" ]]; then
nvm install
elif [[ "$nvmrc_node_version" != "$node_version" ]]; then
nvm use
fi
elif [[ "$node_version" != "$(nvm version default)" ]]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
autoload -U add-zsh-hook
add-zsh-hook chpwd load-nvmrc
load-nvmrc
fi
# Load nvm bash completion
for nvm_completion in "$NVM_DIR/bash_completion" "$NVM_HOMEBREW/etc/bash_completion.d/nvm"; do
if [[ -f "$nvm_completion" ]]; then
# Load bashcompinit
autoload -U +X bashcompinit && bashcompinit
source "$NVM_HOMEBREW/etc/bash_completion.d/nvm"
fi
# Bypass compinit call in nvm bash completion script. See:
# https://github.com/nvm-sh/nvm/blob/4436638/bash_completion#L86-L93
ZSH_VERSION= source "$nvm_completion"
break
fi
done
unset NVM_HOMEBREW NVM_LAZY NVM_AUTOLOAD nvm_completion

View File

@ -1,54 +1,100 @@
# A good summary of the zsh 5.1 Bracketed Paste Mode changes is at:
# https://archive.zhimingwang.org/blog/2015-09-21-zsh-51-and-bracketed-paste.html
# zsh 5.1 (September 2015) introduced built-in support for Bracketed Paste Mode
# https://github.com/zsh-users/zsh/blob/68405f31a043bdd5bf338eb06688ed3e1f740937/README#L38-L45
#
# zsh 5.1 breaks url-quote-magic and other widgets replacing self-insert
# zsh-users' bracketed-paste-magic resolves these issues:
# https://github.com/zsh-users/zsh/blob/f702e17b14d75aa21bff014168fa9048124db286/Functions/Zle/bracketed-paste-magic#L9-L12
# Load bracketed-paste-magic if zsh version is >= 5.1
if [[ ${ZSH_VERSION:0:3} -ge 5.1 ]]; then
set zle_bracketed_paste # Explicitly restore this zsh default
autoload -Uz bracketed-paste-magic
zle -N bracketed-paste bracketed-paste-magic
return ### The rest of this file is NOT executed on zsh version >= 5.1 ###
fi
######################################################################
# The rest of this file is ONLY executed if zsh version < 5.1
######################################################################
# Code from Mikael Magnusson: https://www.zsh.org/mla/users/2011/msg00367.html
#
# Requires xterm, urxvt, iTerm2 or any other terminal that supports bracketed
# paste mode as documented: https://www.xfree86.org/current/ctlseqs.html
# Requires xterm, urxvt, iTerm2 or any other terminal that supports
# Bracketed Paste Mode as documented:
# https://www.xfree86.org/current/ctlseqs.html#Bracketed%20Paste%20Mode
#
# For tmux, use: bind ] paste-buffer -p
#
# Additional technical details: https://cirw.in/blog/bracketed-paste
# create a new keymap to use while pasting
bindkey -N paste
# make everything in this keymap call our custom widget
bindkey -R -M paste "^@"-"\M-^?" paste-insert
# these are the codes sent around the pasted text in bracketed
# paste mode.
# do the first one with both -M viins and -M vicmd in vi mode
bindkey '^[[200~' _start_paste
bindkey -M paste '^[[201~' _end_paste
# insert newlines rather than carriage returns when pasting newlines
bindkey -M paste -s '^M' '^J'
# Create a new keymap to use while pasting
bindkey -N bracketed-paste
# Make everything in this new keymap enqueue characters for pasting
bindkey -RM bracketed-paste '\x00-\xFF' bracketed-paste-enqueue
# These are the codes sent around the pasted text in bracketed paste mode
bindkey -M main '^[[200~' _bracketed_paste_begin
bindkey -M bracketed-paste '^[[201~' _bracketed_paste_end
# Insert newlines rather than carriage returns when pasting newlines
bindkey -M bracketed-paste -s '^M' '^J'
zle -N _start_paste
zle -N _end_paste
zle -N zle-line-init _zle_line_init
zle -N zle-line-finish _zle_line_finish
zle -N paste-insert _paste_insert
zle -N _bracketed_paste_begin
zle -N _bracketed_paste_end
zle -N bracketed-paste-enqueue _bracketed_paste_enqueue
# switch the active keymap to paste mode
function _start_paste() {
bindkey -A paste main
# Attempt to not clobber zle_line_{init,finish}
# Use https://github.com/willghatch/zsh-hooks if available
if typeset -f hooks-add-hook > /dev/null; then
hooks-add-hook zle_line_init_hook _bracketed_paste_zle_init
hooks-add-hook zle_line_finish_hook _bracketed_paste_zle_finish
else
zle -N zle-line-init _bracketed_paste_zle_init
zle -N zle-line-finish _bracketed_paste_zle_finish
fi
# Switch the active keymap to paste mode
_bracketed_paste_begin() {
# Save the bindkey command to restore the active ("main") keymap
# Tokenise the restorative bindkey command into an array
_bracketed_paste_restore_keymap=( ${(z)"$(bindkey -lL main)"} )
bindkey -A bracketed-paste main
}
# go back to our normal keymap, and insert all the pasted text in the
# command line. this has the nice effect of making the whole paste be
# Go back to our normal keymap, and insert all the pasted text in the
# command line. This has the nice effect of making the whole paste be
# a single undo/redo event.
function _end_paste() {
#use bindkey -v here with vi mode probably. maybe you want to track
#if you were in ins or cmd mode and restore the right one.
bindkey -e
LBUFFER+=$_paste_content
unset _paste_content
_bracketed_paste_end() {
# Only execute the restore command if it starts with 'bindkey'
# Allow for option KSH_ARRAYS being set (indexing starts at 0)
if [ ${_bracketed_paste_restore_keymap[@]:0:1} = 'bindkey' ]; then
$_bracketed_paste_restore_keymap
fi
LBUFFER+=$_bracketed_paste_content
unset _bracketed_paste_content _bracketed_paste_restore_keymap
}
function _paste_insert() {
_paste_content+=$KEYS
# Append a pasted character to the content which is later inserted as a whole
_bracketed_paste_enqueue() {
_bracketed_paste_content+=$KEYS
}
function _zle_line_init() {
# Tell terminal to send escape codes around pastes.
[[ $TERM == rxvt-unicode || $TERM == xterm || $TERM = xterm-256color || $TERM = screen || $TERM = screen-256color ]] && printf '\e[?2004h'
# Run at zle-line-init
_bracketed_paste_zle_init() {
_bracketed_paste_content=''
# Tell terminal to send escape codes around pastes
if [ $TERM =~ '^(rxvt-unicode|xterm(-256color)?|screen(-256color)?)$' ]; then
printf '\e[?2004h'
fi
}
function _zle_line_finish() {
# Tell it to stop when we leave zle, so pasting in other programs
# doesn't get the ^[[200~ codes around the pasted text.
[[ $TERM == rxvt-unicode || $TERM == xterm || $TERM = xterm-256color || $TERM = screen || $TERM = screen-256color ]] && printf '\e[?2004l'
# Run at zle-line-finish
_bracketed_paste_zle_finish() {
# Turn off bracketed paste when we leave ZLE, so pasting in other programs
# doesn't get the ^[[200~ codes around the pasted text
if [ $TERM =~ '^(rxvt-unicode|xterm(-256color)?|screen(-256color)?)$' ]; then
printf '\e[?2004l'
fi
}

View File

@ -71,7 +71,7 @@ wd_print_msg()
wd_print_usage()
{
cat <<- EOF
command cat <<- EOF
Usage: wd [command] [point]
Commands:
@ -175,9 +175,9 @@ wd_add()
elif [[ $point =~ "[[:space:]]+" ]]
then
wd_exit_fail "Warp point should not contain whitespace"
elif [[ $point == *:* ]]
elif [[ $point =~ : ]] || [[ $point =~ / ]]
then
wd_exit_fail "Warp point cannot contain colons"
wd_exit_fail "Warp point contains illegal character (:/)"
elif [[ ${points[$point]} == "" ]] || [ ! -z "$force" ]
then
wd_remove "$point" > /dev/null
@ -185,7 +185,7 @@ wd_add()
if (whence sort >/dev/null); then
local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
# use 'cat' below to ensure we respect $WD_CONFIG as a symlink
sort -o "${config_tmp}" "$WD_CONFIG" && cat "${config_tmp}" > "$WD_CONFIG" && rm "${config_tmp}"
command sort -o "${config_tmp}" "$WD_CONFIG" && command cat "${config_tmp}" > "$WD_CONFIG" && command rm "${config_tmp}"
fi
wd_export_static_named_directories
@ -270,7 +270,7 @@ wd_ls()
wd_path()
{
wd_getdir "$1"
echo "$(echo "$dir" | sed "s:${HOME}:~:g")"
echo "$(echo "$dir" | sed "s:~:${HOME}:g")"
}
wd_show()