This commit is contained in:
abc 2023-08-07 11:32:36 +08:00
commit 2a5ec9028a
16 changed files with 49 additions and 45 deletions

View file

@ -15,14 +15,14 @@ Requirements: Python needs to be installed.
## Usage ## Usage
- `acs`: show all aliases by group - `als`: show all aliases by group
- `acs -h/--help`: print help mesage - `als -h/--help`: print help mesage
- `acs <keyword(s)>`: filter and highlight aliases by `<keyword>` - `als <keyword(s)>`: filter and highlight aliases by `<keyword>`
- `acs -g <group>/--group <group>`: show only aliases for group `<group>`. Multiple uses of the flag show all groups - `als -g <group>/--group <group>`: show only aliases for group `<group>`. Multiple uses of the flag show all groups
- `acs --groups`: show only group names - `als --groups`: show only group names
![screenshot](https://cloud.githubusercontent.com/assets/3602957/11581913/cb54fb8a-9a82-11e5-846b-5a67f67ad9ad.png) ![screenshot](https://cloud.githubusercontent.com/assets/3602957/11581913/cb54fb8a-9a82-11e5-846b-5a67f67ad9ad.png)

View file

@ -4,7 +4,7 @@
0="${${(M)0:#/*}:-$PWD/$0}" 0="${${(M)0:#/*}:-$PWD/$0}"
eval ' eval '
function acs(){ function als(){
(( $+commands[python3] )) || { (( $+commands[python3] )) || {
echo "[error] No python executable detected" echo "[error] No python executable detected"
return return

View file

@ -57,7 +57,7 @@ def pretty_print(cheatsheet, wfilter, group_list=None, groups_only=False):
pretty_print_group(key, [ alias for alias in aliases if alias[0].find(wfilter)>-1 or alias[1].find(wfilter)>-1], wfilter) pretty_print_group(key, [ alias for alias in aliases if alias[0].find(wfilter)>-1 or alias[1].find(wfilter)>-1], wfilter)
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Pretty print aliases.", prog="acs") parser = argparse.ArgumentParser(description="Pretty print aliases.", prog="als")
parser.add_argument('filter', nargs="*", metavar="<keyword>", help="search aliases matching keywords") parser.add_argument('filter', nargs="*", metavar="<keyword>", help="search aliases matching keywords")
parser.add_argument('-g', '--group', dest="group_list", action='append', help="only print aliases in given groups") parser.add_argument('-g', '--group', dest="group_list", action='append', help="only print aliases in given groups")
parser.add_argument('--groups', dest='groups_only', action='store_true', help="only print alias groups") parser.add_argument('--groups', dest='groups_only', action='store_true', help="only print alias groups")

View file

@ -21,7 +21,7 @@ Set `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh
| ------ | ---------------------------------------------------------------------- | ---------------------------------------------------------- | | ------ | ---------------------------------------------------------------------- | ---------------------------------------------------------- |
| `age` | `apt-get` | Command line tool for handling packages | | `age` | `apt-get` | Command line tool for handling packages |
| `api` | `aptitude` | Same functionality as `apt-get`, provides extra options | | `api` | `aptitude` | Same functionality as `apt-get`, provides extra options |
| `acse` | `apt-cache search` | Command line tool for searching apt software package cache | | `acs` | `apt-cache search` | Command line tool for searching apt software package cache |
| `aps` | `aptitude search` | Searches installed packages using aptitude | | `aps` | `aptitude search` | Searches installed packages using aptitude |
| `as` | `aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search` | Print searched packages using a custom format | | `as` | `aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search` | Print searched packages using a custom format |
| `afs` | `apt-file search --regexp` | Search file in packages | | `afs` | `apt-file search --regexp` | Search file in packages |

View file

@ -26,7 +26,7 @@ alias age='apt-get'
alias api='aptitude' alias api='aptitude'
# Some self-explanatory aliases # Some self-explanatory aliases
alias acse="apt-cache search" alias acs="apt-cache search"
alias aps='aptitude search' alias aps='aptitude search'
alias as="aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search" alias as="aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search"

View file

@ -30,6 +30,15 @@ file**, but be aware of the side effects:
> zstyle ':completion:*:*:docker-*:*' option-stacking yes > zstyle ':completion:*:*:docker-*:*' option-stacking yes
> ``` > ```
### Use old-style completion
If the current completion does not work well for you, you can enable legacy completion instead with the
following setting. See https://github.com/ohmyzsh/ohmyzsh/issues/11789 for more information.
```zsh
zstyle ':omz:plugins:docker' legacy-completion yes
```
## Aliases ## Aliases
| Alias | Command | Description | | Alias | Command | Description |
@ -58,7 +67,7 @@ file**, but be aware of the side effects:
| drm | `docker container rm` | Remove the specified container(s) | | drm | `docker container rm` | Remove the specified container(s) |
| drm! | `docker container rm -f` | Force the removal of a running container (uses SIGKILL) | | drm! | `docker container rm -f` | Force the removal of a running container (uses SIGKILL) |
| dst | `docker container start` | Start one or more stopped containers | | dst | `docker container start` | Start one or more stopped containers |
| drs | `docker container restart` | Restart one or more containers | drs | `docker container restart` | Restart one or more containers |
| dsta | `docker stop $(docker ps -q)` | Stop all running containers | | dsta | `docker stop $(docker ps -q)` | Stop all running containers |
| dstp | `docker container stop` | Stop one or more running containers | | dstp | `docker container stop` | Stop one or more running containers |
| dtop | `docker top` | Display the running processes of a container | | dtop | `docker top` | Display the running processes of a container |

View file

@ -41,12 +41,6 @@ fi
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}" 0="${${(M)0:#/*}:-$PWD/$0}"
{
# docker version returns `Docker version 24.0.2, build cb74dfcd85`
# with `s:,:` remove the comma after the version, and select third word of it
local _docker_version=${${(s:,:z)"$(command docker --version)"}[3]}
# `docker completion` is only available from 23.0.0 on
if is-at-least 23.0.0 $_docker_version; then
# If the completion file doesn't exist yet, we need to autoload it and # If the completion file doesn't exist yet, we need to autoload it and
# bind it to `docker`. Otherwise, compinit will have already done that. # bind it to `docker`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_docker" ]]; then if [[ ! -f "$ZSH_CACHE_DIR/completions/_docker" ]]; then
@ -54,8 +48,15 @@ fi
autoload -Uz _docker autoload -Uz _docker
_comps[docker]=_docker _comps[docker]=_docker
fi fi
command docker completion zsh >| "$ZSH_CACHE_DIR/completions/_docker"
else {
# `docker completion` is only available from 23.0.0 on
# docker version returns `Docker version 24.0.2, build cb74dfcd85`
# with `s:,:` remove the comma after the version, and select third word of it
if zstyle -t ':omz:plugins:docker' legacy-completion || \
! is-at-least 23.0.0 ${${(s:,:z)"$(command docker --version)"}[3]}; then
command cp "${0:h}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker" command cp "${0:h}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker"
else
command docker completion zsh >| "$ZSH_CACHE_DIR/completions/_docker"
fi fi
} &| } &|

View file

@ -52,12 +52,7 @@ version to load. This can be done, similar as previous options, adding:
```zsh ```zsh
zstyle ':omz:plugins:nvm' autoload yes zstyle ':omz:plugins:nvm' autoload yes
``` zstyle ':omz:plugins:nvm' silent-autoload yes # optionally remove the output generated by NVM when autoloading
To remove the output generated by NVM when autoloading, you can set the following option:
```zsh
zstyle ':omz:plugins:nvm' silent-autoload yes
``` ```
Note: _this will not remove regular `nvm` output_ Note: _this will not remove regular `nvm` output_

View file

@ -16,13 +16,7 @@ fi
# Note: nvm is a function so we need to use `which` # Note: nvm is a function so we need to use `which`
which nvm &>/dev/null && return which nvm &>/dev/null && return
if [[ -z "$NVM_DIR" ]]; then if [[ -z "$NVM_DIR" ]] || [[ ! -f "$NVM_DIR/nvm.sh" ]]; then
echo "[oh-my-zsh] nvm installation cannot be found"
echo "[oh-my-zsh] set NVM_DIR to your installation"
return
fi
if [[ ! -f "$NVM_DIR/nvm.sh" ]]; then
echo "[oh-my-zsh] nvm.sh does not exist in $NVM_DIR"
return return
fi fi

View file

@ -81,6 +81,7 @@ function per-directory-history-toggle-history() {
autoload per-directory-history-toggle-history autoload per-directory-history-toggle-history
zle -N per-directory-history-toggle-history zle -N per-directory-history-toggle-history
bindkey $PER_DIRECTORY_HISTORY_TOGGLE per-directory-history-toggle-history bindkey $PER_DIRECTORY_HISTORY_TOGGLE per-directory-history-toggle-history
bindkey -M vicmd $PER_DIRECTORY_HISTORY_TOGGLE per-directory-history-toggle-history
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# implementation details # implementation details

View file

@ -1,3 +1,5 @@
alias tis='tig status' alias tis='tig status'
alias til='tig log' alias til='tig log'
alias tib='tig blame -C' alias tib='tig blame -C'
alias tif='tig reflog'
alias tia='tig --all'

View file

@ -15,7 +15,7 @@ Commands that use `$APT` will use `apt` if installed or defer to `apt-get` other
| Alias | Command | Description | | Alias | Command | Description |
|---------|--------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------| |---------|--------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
| age | `sudo $APT` | Run apt-get with sudo | | age | `sudo $APT` | Run apt-get with sudo |
| acse | `apt-cache search` | Search the apt-cache with the specified criteria | | acs | `apt-cache search` | Search the apt-cache with the specified criteria |
| acsp | `apt-cache showpkg` | Shows information about the listed packages | | acsp | `apt-cache showpkg` | Shows information about the listed packages |
| acp | `apt-cache policy` | Display the package source priorities | | acp | `apt-cache policy` | Display the package source priorities |
| afs | `apt-file search --regexp` | Perform a regular expression apt-file search | | afs | `apt-file search --regexp` | Perform a regular expression apt-file search |

View file

@ -1,6 +1,6 @@
(( $+commands[apt] )) && APT=apt || APT=apt-get (( $+commands[apt] )) && APT=apt || APT=apt-get
alias acse='apt-cache search' alias acs='apt-cache search'
alias afs='apt-file search --regexp' alias afs='apt-file search --regexp'

View file

@ -109,7 +109,9 @@ prompt_git() {
if [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then if [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then
repo_path=$(git rev-parse --git-dir 2>/dev/null) repo_path=$(git rev-parse --git-dir 2>/dev/null)
dirty=$(parse_git_dirty) dirty=$(parse_git_dirty)
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" ref=$(git symbolic-ref HEAD 2> /dev/null) || \
ref="◈ $(git describe --exact-match --tags HEAD 2> /dev/null)" || \
ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
if [[ -n $dirty ]]; then if [[ -n $dirty ]]; then
prompt_segment yellow black prompt_segment yellow black
else else

View file

@ -12,6 +12,7 @@
# Also borrowing from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/ # Also borrowing from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
function virtualenv_info { function virtualenv_info {
[ $CONDA_DEFAULT_ENV ] && echo "($CONDA_DEFAULT_ENV) "
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') ' [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
} }

View file

@ -29,14 +29,13 @@ local cyan="%{$fg_bold[cyan]%}"
local yellow="%{$fg_bold[yellow]%}" local yellow="%{$fg_bold[yellow]%}"
local blue="%{$fg_bold[blue]%}" local blue="%{$fg_bold[blue]%}"
local magenta="%{$fg_bold[magenta]%}" local magenta="%{$fg_bold[magenta]%}"
local white="%{$fg_bold[white]%}"
local reset="%{$reset_color%}" local reset="%{$reset_color%}"
local -a color_array local -a color_array
color_array=($green $red $cyan $yellow $blue $magenta $white) color_array=($green $red $cyan $yellow $blue $magenta)
local username_color=$white local username_color=$blue
local hostname_color=$color_array[$[((#HOST))%7+1]] # choose hostname color based on first character local hostname_color=$color_array[$[((#HOST))%6+1]] # choose hostname color based on first character
local current_dir_color=$blue local current_dir_color=$blue
local username="%n" local username="%n"
@ -66,10 +65,10 @@ function michelebologna_git_prompt {
local out=$(git_prompt_info)$(git_prompt_status)$(git_remote_status) local out=$(git_prompt_info)$(git_prompt_status)$(git_remote_status)
[[ -n $out ]] || return [[ -n $out ]] || return
printf " %s(%s%s%s)%s" \ printf " %s(%s%s%s)%s" \
"%{$fg_bold[white]%}" \ "%{$fg_bold[blue]%}" \
"%{$fg_bold[green]%}" \ "%{$fg_bold[green]%}" \
"$out" \ "$out" \
"%{$fg_bold[white]%}" \ "%{$fg_bold[blue]%}" \
"%{$reset_color%}" "%{$reset_color%}"
} }