mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-10-16 11:40:46 +00:00
Compare commits
15 commits
380ecbd109
...
6df03ea7d7
Author | SHA1 | Date | |
---|---|---|---|
|
6df03ea7d7 | ||
|
1514145a09 | ||
|
99e2c31484 | ||
|
e52598a5cc | ||
|
d91944d47e | ||
|
865291cb7a | ||
|
9bcafe1c27 | ||
|
3151c9c1a3 | ||
|
ac325a7cab | ||
|
ec7d01faf8 | ||
|
8c13f021bf | ||
|
e3e80b98b5 | ||
|
a84bc2dadd | ||
|
33ac2ee30f | ||
|
f709cd4548 |
21 changed files with 88 additions and 65 deletions
2
.github/dependencies.yml
vendored
2
.github/dependencies.yml
vendored
|
@ -28,7 +28,7 @@ dependencies:
|
|||
plugins/wd:
|
||||
repo: mfaerevaag/wd
|
||||
branch: master
|
||||
version: tag:v0.7.1
|
||||
version: tag:v0.9.0
|
||||
precopy: |
|
||||
set -e
|
||||
rm -r test
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
certifi==2024.8.30
|
||||
charset-normalizer==3.3.2
|
||||
idna==3.8
|
||||
idna==3.9
|
||||
PyYAML==6.0.2
|
||||
requests==2.32.3
|
||||
semver==3.0.2
|
||||
urllib3==2.2.2
|
||||
urllib3==2.2.3
|
||||
|
|
|
@ -57,6 +57,16 @@ function takeurl() {
|
|||
cd "$thedir"
|
||||
}
|
||||
|
||||
function takezip() {
|
||||
local data thedir
|
||||
data="$(mktemp)"
|
||||
curl -L "$1" > "$data"
|
||||
unzip "$data" -d "./"
|
||||
thedir="$(unzip -l "$data" | awk 'NR==4 {print $4}' | sed 's/\/.*//')"
|
||||
rm "$data"
|
||||
cd "$thedir"
|
||||
}
|
||||
|
||||
function takegit() {
|
||||
git clone "$1"
|
||||
cd "$(basename ${1%%.git})"
|
||||
|
@ -65,6 +75,8 @@ function takegit() {
|
|||
function take() {
|
||||
if [[ $1 =~ ^(https?|ftp).*\.(tar\.(gz|bz2|xz)|tgz)$ ]]; then
|
||||
takeurl "$1"
|
||||
elif [[ $1 =~ ^(https?|ftp).*\.(zip)$ ]]; then
|
||||
takezip "$1"
|
||||
elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then
|
||||
takegit "$1"
|
||||
else
|
||||
|
|
14
lib/git.zsh
14
lib/git.zsh
|
@ -162,6 +162,18 @@ function git_current_branch() {
|
|||
echo ${ref#refs/heads/}
|
||||
}
|
||||
|
||||
# Outputs the name of the previously checked out branch
|
||||
# Usage example: git pull origin $(git_current_branch)
|
||||
# rev-parse --symbolic-full-name @{-1} only prints if it is a branch
|
||||
function git_previous_branch() {
|
||||
local ref
|
||||
ref=$(__git_prompt_git rev-parse --quiet --symbolic-full-name @{-1} 2> /dev/null)
|
||||
local ret=$?
|
||||
if [[ $ret != 0 ]] || [[ -z $ref ]]; then
|
||||
return # no git repo or non-branch previous ref
|
||||
fi
|
||||
echo ${ref#refs/heads/}
|
||||
}
|
||||
|
||||
# Gets the number of commits ahead from remote
|
||||
function git_commits_ahead() {
|
||||
|
@ -227,7 +239,7 @@ function _omz_git_prompt_status() {
|
|||
prefix_constant_map=(
|
||||
'\?\? ' 'UNTRACKED'
|
||||
'A ' 'ADDED'
|
||||
'M ' 'ADDED'
|
||||
'M ' 'MODIFIED'
|
||||
'MM ' 'MODIFIED'
|
||||
' M ' 'MODIFIED'
|
||||
'AM ' 'MODIFIED'
|
||||
|
|
|
@ -38,6 +38,7 @@ One can configure a few things:
|
|||
- `bgnotify_bell` enabled or disables the terminal bell (default true)
|
||||
- `bgnotify_threshold` sets the notification threshold time (default 6 seconds)
|
||||
- `function bgnotify_formatted` lets you change the notification. You can for instance customize the message and pass in an icon.
|
||||
- `bgnotify_extraargs` appends extra args to notifier (e.g. `-e` for notify-send to create a transient notification)
|
||||
|
||||
Use these by adding a function definition before the your call to source. Example:
|
||||
|
||||
|
|
|
@ -117,15 +117,15 @@ function bgnotify {
|
|||
local icon="$3"
|
||||
if (( ${+commands[terminal-notifier]} )); then # macOS
|
||||
local term_id=$(bgnotify_programid)
|
||||
terminal-notifier -message "$message" -title "$title" ${=icon:+-appIcon "$icon"} ${=term_id:+-activate "$term_id"} &>/dev/null
|
||||
terminal-notifier -message "$message" -title "$title" ${=icon:+-appIcon "$icon"} ${=term_id:+-activate "$term_id"} ${=bgnotify_extraargs:-} &>/dev/null
|
||||
elif (( ${+commands[growlnotify]} )); then # macOS growl
|
||||
growlnotify -m "$title" "$message"
|
||||
growlnotify -m "$title" "$message" ${=bgnotify_extraargs:-}
|
||||
elif (( ${+commands[notify-send]} )); then
|
||||
notify-send "$title" "$message" ${=icon:+--icon "$icon"}
|
||||
notify-send "$title" "$message" ${=icon:+--icon "$icon"} ${=bgnotify_extraargs:-}
|
||||
elif (( ${+commands[kdialog]} )); then # KDE
|
||||
kdialog --title "$title" --passivepopup "$message" 5
|
||||
kdialog --title "$title" --passivepopup "$message" 5 ${=bgnotify_extraargs:-}
|
||||
elif (( ${+commands[notifu]} )); then # cygwin
|
||||
notifu /m "$message" /p "$title" ${=icon:+/i "$icon"}
|
||||
notifu /m "$message" /p "$title" ${=icon:+/i "$icon"} ${=bgnotify_extraargs:-}
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ plugins=(... git)
|
|||
| `gcans!` | `git commit --verbose --all --signoff --no-edit --amend` |
|
||||
| `gcann!` | `git commit --verbose --all --date=now --no-edit --amend` |
|
||||
| `gc!` | `git commit --verbose --amend` |
|
||||
| `gcn` | `git commit --verbose --no-edit` |
|
||||
| `gcn!` | `git commit --verbose --no-edit --amend` |
|
||||
| `gcs` | `git commit -S` |
|
||||
| `gcss` | `git commit -S -s` |
|
||||
|
|
|
@ -197,6 +197,7 @@ alias gcan!='git commit --verbose --all --no-edit --amend'
|
|||
alias gcans!='git commit --verbose --all --signoff --no-edit --amend'
|
||||
alias gcann!='git commit --verbose --all --date=now --no-edit --amend'
|
||||
alias gc!='git commit --verbose --amend'
|
||||
alias gcn='git commit --verbose --no-edit'
|
||||
alias gcn!='git commit --verbose --no-edit --amend'
|
||||
alias gcf='git config --list'
|
||||
alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
|
||||
|
|
|
@ -19,7 +19,7 @@ Usage is simple... just take your json data and pipe it into the appropriate jso
|
|||
|
||||
### Supports NDJSON (Newline Delimited JSON)
|
||||
|
||||
The plugin also supports [NDJSON](http://ndjson.org/) input, which means all functions
|
||||
The plugin also supports [NDJSON](https://github.com/ndjson/ndjson-spec) input, which means all functions
|
||||
have an alternative function that reads and processes the input line by line. These
|
||||
functions have the same name except using `ndjson` instead of `json`:
|
||||
|
||||
|
|
|
@ -42,6 +42,8 @@ as you want:
|
|||
zstyle ':omz:plugins:nvm' lazy-cmd eslint prettier typescript ...
|
||||
```
|
||||
|
||||
There will be a function `_omz_nvm_load` available to load `nvm` without executing any other trigger command.
|
||||
|
||||
#### `.nvmrc` autoload
|
||||
|
||||
Note: _if used at the same time as `lazy`, `autoload` will start working only after nvm has been lazy-loaded_
|
||||
|
|
|
@ -20,7 +20,7 @@ if [[ -z "$NVM_DIR" ]] || [[ ! -f "$NVM_DIR/nvm.sh" ]]; then
|
|||
return
|
||||
fi
|
||||
|
||||
function _omz_load_nvm_completion {
|
||||
function _omz_nvm_setup_completion {
|
||||
local _nvm_completion
|
||||
# Load nvm bash completion
|
||||
for _nvm_completion in "$NVM_DIR/bash_completion" "$NVM_HOMEBREW/etc/bash_completion.d/nvm"; do
|
||||
|
@ -33,12 +33,12 @@ function _omz_load_nvm_completion {
|
|||
break
|
||||
fi
|
||||
done
|
||||
unfunction _omz_load_nvm_completion
|
||||
unfunction _omz_nvm_setup_completion
|
||||
}
|
||||
|
||||
function _omz_setup_autoload {
|
||||
function _omz_nvm_setup_autoload {
|
||||
if ! zstyle -t ':omz:plugins:nvm' autoload; then
|
||||
unfunction _omz_setup_autoload
|
||||
unfunction _omz_nvm_setup_autoload
|
||||
return
|
||||
fi
|
||||
|
||||
|
@ -68,13 +68,13 @@ function _omz_setup_autoload {
|
|||
add-zsh-hook chpwd load-nvmrc
|
||||
|
||||
load-nvmrc
|
||||
unfunction _omz_setup_autoload
|
||||
unfunction _omz_nvm_setup_autoload
|
||||
}
|
||||
|
||||
if zstyle -t ':omz:plugins:nvm' lazy; then
|
||||
# Call nvm when first using nvm, node, npm, pnpm, yarn, corepack or other commands in lazy-cmd
|
||||
zstyle -a ':omz:plugins:nvm' lazy-cmd nvm_lazy_cmd
|
||||
nvm_lazy_cmd=(nvm node npm npx pnpm pnpx yarn corepack $nvm_lazy_cmd) # default values
|
||||
nvm_lazy_cmd=(_omz_nvm_load nvm node npm npx pnpm pnpx yarn corepack $nvm_lazy_cmd) # default values
|
||||
eval "
|
||||
function $nvm_lazy_cmd {
|
||||
for func in $nvm_lazy_cmd; do
|
||||
|
@ -84,14 +84,16 @@ if zstyle -t ':omz:plugins:nvm' lazy; then
|
|||
done
|
||||
# Load nvm if it exists in \$NVM_DIR
|
||||
[[ -f \"\$NVM_DIR/nvm.sh\" ]] && source \"\$NVM_DIR/nvm.sh\"
|
||||
_omz_load_nvm_completion
|
||||
_omz_setup_autoload
|
||||
\"\$0\" \"\$@\"
|
||||
_omz_nvm_setup_completion
|
||||
_omz_nvm_setup_autoload
|
||||
if [[ \"\$0\" != _omz_nvm_load ]]; then
|
||||
\"\$0\" \"\$@\"
|
||||
fi
|
||||
}
|
||||
"
|
||||
unset nvm_lazy_cmd
|
||||
else
|
||||
source "$NVM_DIR/nvm.sh"
|
||||
_omz_load_nvm_completion
|
||||
_omz_setup_autoload
|
||||
_omz_nvm_setup_completion
|
||||
_omz_nvm_setup_autoload
|
||||
fi
|
||||
|
|
|
@ -13,7 +13,6 @@ plugins=(... python)
|
|||
| Command | Description |
|
||||
| ---------------- | -------------------------------------------------------------------------------------- |
|
||||
| `py` | Runs `python3`. Only set if `py` is not installed. |
|
||||
| `ipython` | Runs the appropriate `ipython` version according to the activated virtualenv |
|
||||
| `pyfind` | Finds .py files recursively in the current directory |
|
||||
| `pyclean [dirs]` | Deletes byte-code and cache files from a list of directories or the current one |
|
||||
| `pygrep <text>` | Looks for `text` in `*.py` files in the current directory, recursively |
|
||||
|
|
|
@ -43,9 +43,6 @@ function pyuserpaths() {
|
|||
# Grep among .py files
|
||||
alias pygrep='grep -nr --include="*.py"'
|
||||
|
||||
# Run proper IPython regarding current virtualenv (if any)
|
||||
alias ipython='python3 -c "import sys; del sys.path[0]; import IPython; sys.exit(IPython.start_ipython())"'
|
||||
|
||||
# Share local directory as a HTTP server
|
||||
alias pyserver="python3 -m http.server"
|
||||
|
||||
|
|
|
@ -15,22 +15,23 @@ plugins=(... terraform)
|
|||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command |
|
||||
|--------|----------------------------|
|
||||
| `tf` | `terraform` |
|
||||
| `tfa` | `terraform apply` |
|
||||
| `tfc` | `terraform console` |
|
||||
| `tfd` | `terraform destroy` |
|
||||
| `tff` | `terraform fmt` |
|
||||
| `tffr` | `terraform fmt -recursive` |
|
||||
| `tfi` | `terraform init` |
|
||||
| `tfiu` | `terraform init -upgrade` |
|
||||
| `tfo` | `terraform output` |
|
||||
| `tfp` | `terraform plan` |
|
||||
| `tfv` | `terraform validate` |
|
||||
| `tfs` | `terraform state` |
|
||||
| `tft` | `terraform test` |
|
||||
| `tfsh` | `terraform show` |
|
||||
| Alias | Command |
|
||||
|---------|----------------------------------|
|
||||
| `tf` | `terraform` |
|
||||
| `tfa` | `terraform apply` |
|
||||
| `tfaa` | `terraform apply -auto-approve` |
|
||||
| `tfc` | `terraform console` |
|
||||
| `tfd` | `terraform destroy` |
|
||||
| `tff` | `terraform fmt` |
|
||||
| `tffr` | `terraform fmt -recursive` |
|
||||
| `tfi` | `terraform init` |
|
||||
| `tfiu` | `terraform init -upgrade` |
|
||||
| `tfo` | `terraform output` |
|
||||
| `tfp` | `terraform plan` |
|
||||
| `tfv` | `terraform validate` |
|
||||
| `tfs` | `terraform state` |
|
||||
| `tft` | `terraform test` |
|
||||
| `tfsh` | `terraform show` |
|
||||
|
||||
|
||||
## Prompt function
|
||||
|
|
|
@ -17,6 +17,7 @@ function tf_version_prompt_info() {
|
|||
|
||||
alias tf='terraform'
|
||||
alias tfa='terraform apply'
|
||||
alias tfaa='terraform apply -auto-approve'
|
||||
alias tfc='terraform console'
|
||||
alias tfd='terraform destroy'
|
||||
alias tff='terraform fmt'
|
||||
|
|
|
@ -115,9 +115,11 @@ wd() {
|
|||
|
||||
3. Install manpage (optional):
|
||||
|
||||
Move manpage into an appropriate directory, then trigger `mandb` to discover it
|
||||
|
||||
```zsh
|
||||
sudo cp ~/.local/wd/wd.1 /usr/share/man/man1/wd.1
|
||||
sudo chmod 644 /usr/share/man/man1/wd.1
|
||||
sudo install -m 644 ~/.local/wd/wd.1 /usr/share/man/man1/wd.1
|
||||
sudo mandb /usr/share/man/man1
|
||||
```
|
||||
|
||||
**Note:** when pulling and updating `wd`, you'll need to repeat step 3 should the manpage change
|
||||
|
@ -139,10 +141,11 @@ rm -f ~/.zcompdump; compinit
|
|||
|
||||
## Browse
|
||||
|
||||
If you want to make use of the `fzf`-powered browse feature to fuzzy search through all your warp points, set up a keybind in your `.zshrc`:
|
||||
`wd` comes with an `fzf`-powered browse feature to fuzzy search through all your warp points. It's available through the `wd browse` command. For quick access you can set up an alias or keybind in your `.zshrc`:
|
||||
|
||||
```zsh
|
||||
bindkey ${FZF_WD_BINDKEY:-'^B'} fuzzy_wd_widget
|
||||
# ctrl-b to open the fzf browser
|
||||
bindkey ${FZF_WD_BINDKEY:-'^B'} wd_browse_widget
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
@ -255,12 +258,6 @@ wd --version
|
|||
wd --config ./file <command>
|
||||
```
|
||||
|
||||
* Force `exit` with return code after running. This is not default, as it will *exit your terminal*, though required for testing/debugging.
|
||||
|
||||
```zsh
|
||||
wd --debug <command>
|
||||
```
|
||||
|
||||
* Silence all output:
|
||||
|
||||
```zsh
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/zsh
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
# WARP DIRECTORY
|
||||
# ==============
|
||||
|
@ -18,4 +18,3 @@ zle -N wd_browse_widget
|
|||
zle -N wd_restore_buffer
|
||||
autoload -Uz add-zle-hook-widget
|
||||
add-zle-hook-widget line-init wd_restore_buffer
|
||||
bindkey ${FZF_WD_BINDKEY:-'^B'} wd_browse_widget
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/zsh
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
# WARP DIRECTORY
|
||||
# ==============
|
||||
|
@ -8,7 +8,7 @@
|
|||
# @github.com/mfaerevaag/wd
|
||||
|
||||
# version
|
||||
readonly WD_VERSION=0.7.0
|
||||
readonly WD_VERSION=0.9.0
|
||||
|
||||
# colors
|
||||
readonly WD_BLUE="\033[96m"
|
||||
|
@ -90,7 +90,6 @@ Commands:
|
|||
clean Remove points warping to nonexistent directories (will prompt unless --force is used)
|
||||
|
||||
-v | --version Print version
|
||||
-d | --debug Exit after execution with exit codes (for testing)
|
||||
-c | --config Specify config file (default ~/.warprc)
|
||||
-q | --quiet Suppress all output
|
||||
-f | --force Allows overwriting without warning (for add & clean)
|
||||
|
@ -426,7 +425,6 @@ wd_export_static_named_directories() {
|
|||
WD_CONFIG=${WD_CONFIG:-$HOME/.warprc}
|
||||
local WD_QUIET=0
|
||||
local WD_EXIT_CODE=0
|
||||
local WD_DEBUG=0
|
||||
|
||||
# Parse 'meta' options first to avoid the need to have them before
|
||||
# other commands. The `-D` flag consumes recognized options so that
|
||||
|
@ -436,7 +434,6 @@ zparseopts -D -E \
|
|||
c:=wd_alt_config -config:=wd_alt_config \
|
||||
q=wd_quiet_mode -quiet=wd_quiet_mode \
|
||||
v=wd_print_version -version=wd_print_version \
|
||||
d=wd_debug_mode -debug=wd_debug_mode \
|
||||
f=wd_force_mode -force=wd_force_mode
|
||||
|
||||
if [[ ! -z $wd_print_version ]]
|
||||
|
@ -583,9 +580,4 @@ unset args
|
|||
unset points
|
||||
unset val &> /dev/null # fixes issue #1
|
||||
|
||||
if [[ -n $wd_debug_mode ]]
|
||||
then
|
||||
exit $WD_EXIT_CODE
|
||||
else
|
||||
unset wd_debug_mode
|
||||
fi
|
||||
return $WD_EXIT_CODE
|
||||
|
|
|
@ -51,6 +51,7 @@ Available search contexts are:
|
|||
| `packagist` | `https://packagist.org/?query=` |
|
||||
| `gopkg` | `https://pkg.go.dev/search?m=package&q=` |
|
||||
| `chatgpt` | `https://chatgpt.com/?q=` |
|
||||
| `reddit` | `https://www.reddit.com/search/?q=` |
|
||||
|
||||
Also there are aliases for bang-searching DuckDuckGo:
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ function web_search() {
|
|||
packagist "https://packagist.org/?query="
|
||||
gopkg "https://pkg.go.dev/search?m=package&q="
|
||||
chatgpt "https://chatgpt.com/?q="
|
||||
reddit "https://www.reddit.com/search/?q="
|
||||
)
|
||||
|
||||
# check whether the search engine is supported
|
||||
|
@ -85,6 +86,7 @@ alias npmpkg='web_search npmpkg'
|
|||
alias packagist='web_search packagist'
|
||||
alias gopkg='web_search gopkg'
|
||||
alias chatgpt='web_search chatgpt'
|
||||
alias reddit='web_search reddit'
|
||||
|
||||
#add your own !bang searches here
|
||||
alias wiki='web_search duckduckgo \!w'
|
||||
|
|
|
@ -30,8 +30,9 @@ local return_code="%(?..%F{red}%? ↵%f)"
|
|||
local user_host="${PR_USER}%F{cyan}@${PR_HOST}"
|
||||
local current_dir="%B%F{blue}%~%f%b"
|
||||
local git_branch='$(git_prompt_info)'
|
||||
local venv_prompt='$(virtualenv_prompt_info)'
|
||||
|
||||
PROMPT="╭─${user_host} ${current_dir} \$(ruby_prompt_info) ${git_branch}
|
||||
PROMPT="╭─${venv_prompt}${user_host} ${current_dir} \$(ruby_prompt_info) ${git_branch}
|
||||
╰─$PR_PROMPT "
|
||||
RPROMPT="${return_code}"
|
||||
|
||||
|
@ -39,5 +40,7 @@ ZSH_THEME_GIT_PROMPT_PREFIX="%F{yellow}‹"
|
|||
ZSH_THEME_GIT_PROMPT_SUFFIX="› %f"
|
||||
ZSH_THEME_RUBY_PROMPT_PREFIX="%F{red}‹"
|
||||
ZSH_THEME_RUBY_PROMPT_SUFFIX="›%f"
|
||||
ZSH_THEME_VIRTUALENV_PREFIX="%F{red}("
|
||||
ZSH_THEME_VIRTUALENV_SUFFIX=")%f "
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue