From 7afaee858a4ae5a8d0d8c1f5fe150979842ebefc Mon Sep 17 00:00:00 2001 From: Larson Carter Date: Sun, 5 Jul 2020 10:59:12 -0500 Subject: Bug and Feature Request Templates + MLH Theme + Readme (#9068) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà Co-authored-by: Bartek Pacia --- .github/ISSUE_TEMPLATE/bug_report.md | 8 +++++ .github/ISSUE_TEMPLATE/feature_request.md | 11 +++--- README.md | 24 +++++++------ themes/mlh.zsh-theme | 59 +++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 15 deletions(-) create mode 100644 themes/mlh.zsh-theme diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 7c1cb8967..024231531 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -26,8 +26,16 @@ A brief description of what should happen. If applicable, add screenshots to help explain your problem. You can also record an asciinema session: https://asciinema.org/ +**Self Check** +Have you tried reaching out on the [Discord server](discord.gg/ohmyzsh)? +This can help cut down on filling up issues. We always have a few people +online that are in a variety of timezones that are willing to help you! +Also searching existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=) +might help you get quicker support + **Desktop (please complete the following information):** - OS / Distro: [e.g. Arch Linux, macOS] + - If on Windows what version of WSL: [e.g. WSL1, WSL2] - Latest ohmyzsh Update?: [e.g. Yes/No] - ZSH Version: [e.g. 5.6] - Terminal emulator [e.g. iTerm2] diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 346eabaea..0a8a588db 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -11,16 +11,19 @@ an issue where no sections have been filled will be deleted without comment. --> **Is your feature request related to a particular plugin or theme? If so, specify it.** -The name of the plugin or theme that you would like us to improve. [...] +The name of the plugin, theme or alias that you would like us to improve. [...] **Is your feature request related to a problem? Please describe.** A description of what the problem is. Ex. I'm always frustrated when [...] **Describe the solution you'd like** -A description of what you want to happen. +A description of what you want to happen. [...] **Describe alternatives you've considered** -A description of any alternative solutions or features you've considered. This can also include other plugins or aliases. +A description of any alternative solutions or features you've considered. This can also include other plugins or themes. **Additional context** -Add any other context or screenshots about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at. +Add any other context, screenshots or discord conversations about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at. + +**Related Issues** +Is there any open or closed issues that is related to this feature request? If so please link them below! [...] diff --git a/README.md b/README.md index 9fa0c2049..329eff178 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Once installed, your terminal shell will become the talk of the town _or your mo Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll use the time that you're saving to start flossing more often. 😬 -To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter, and/or join us on Discord. +To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter, and/or join us on [Discord](https://discord.gg/ohmyzsh). [![CI](https://github.com/ohmyzsh/ohmyzsh/workflows/CI/badge.svg)](https://github.com/ohmyzsh/ohmyzsh/actions?query=workflow%3ACI) [![Follow @ohmyzsh](https://img.shields.io/twitter/follow/ohmyzsh?label=Follow+@ohmyzsh&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh) @@ -22,14 +22,14 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi ### Prerequisites -* A Unix-like operating system: macOS, Linux, BSD. On Windows: WSL is preferred, but cygwin or msys also mostly work. -* [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent). If not pre-installed (run `zsh --version` to confirm), check the following instructions here: [Installing ZSH](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH) +* A Unix-like operating system: macOS, Linux, BSD. On Windows: WSL2 is preferred, but cygwin or msys also mostly work. +* [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent is fine but we prefer 5.0.8 and newer). If not pre-installed (run `zsh --version` to confirm), check the following wiki instructions here: [Installing ZSH](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH) * `curl` or `wget` should be installed -* `git` should be installed (recommended v1.7.2 or higher) +* `git` should be installed (recommended v2.4.11 or higher) ### Basic Installation -Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl` or `wget`. +Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl` or `wget`, whichever is installed on your machine. #### via curl @@ -58,7 +58,7 @@ sh install.sh ### Plugins -Oh My Zsh comes with a shitload of plugins to take advantage of. You can take a look in the [plugins](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins) directory and/or the [wiki](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins) to see what's currently available. +Oh My Zsh comes with a shitload of plugins for you to take advantage of. You can take a look in the [plugins](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins) directory and/or the [wiki](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins) to see what's currently available. #### Enabling Plugins @@ -82,15 +82,15 @@ plugins=( ) ``` -_Note that the plugins are separated by whitespace. **Do not** use commas between them._ +_Note that the plugins are separated by whitespace (spaces, tabs, new lines...). **Do not** use commas between them or it will break._ #### Using Plugins -Most plugins (should! we're working on this) include a __README__, which documents how to use them. +Each plugin includes a __README__, documenting it. This README should show the aliases (if the plugin adds any) and extra goodies that are inclued in that particular plugin. ### Themes -We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes) on the wiki. Check them out! +We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred and fifty themes now bundled. Most of them have [screenshots](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes) on the wiki (We are working on updating this!). Check them out! #### Selecting a Theme @@ -154,7 +154,7 @@ the installer accepts (these settings are also documented at the top of the inst #### Custom Directory -The default location is `~/.oh-my-zsh` (hidden in your home directory) +The default location is `~/.oh-my-zsh` (hidden in your home directory, you can access it with `cd ~/.oh-my-zsh`) If you'd like to change the install directory with the `ZSH` environment variable, either by running `export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline @@ -303,7 +303,9 @@ Thank you so much! We're on the social media. * [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. You should follow it. -* [Oh My Zsh](https://www.facebook.com/Oh-My-Zsh-296616263819290/) on Facebook. +* [FaceBook](https://www.facebook.com/Oh-My-Zsh-296616263819290/) poke us. +* [Instagram](https://www.instagram.com/_ohmyzsh/) tag us in your post showing Oh My Zsh! +* [Discord](https://discord.gg/ohmyzsh) to chat with us! ## Merchandise diff --git a/themes/mlh.zsh-theme b/themes/mlh.zsh-theme new file mode 100644 index 000000000..a21a546bc --- /dev/null +++ b/themes/mlh.zsh-theme @@ -0,0 +1,59 @@ +# The Official Theme of +## ## ## ## ## +### ### ## ## ## +#### #### ## ## ## +## ### ## ## ######### +## ## ## ## ## +## ## ## ## ## +## ## ######## ## ## + +# # # # # # # # # # # # # # # # # # +# # # Feel free to customize! # # # +# # # # # # # # # # # # # # # # # # + +# To easily discover colors and their codes, type `spectrum_ls` in the terminal + +AT_SYMBOL=" @ " +IN_SYMBOL=" in " +ON_SYMBOL=" on " +SYMBOL="$" + +USER_COLOR="%F{001}" +DEVICE_COLOR="%F{033}" +DIR_COLOR="%F{220}" +BRANCH_COLOR="%F{001}" +TIME_COLOR="%F{033}" + +username() { + echo "$USER_COLOR%n%f" +} + +# Returns device name +device() { + echo "$DEVICE_COLOR%m%f" +} + +# The current directory +directory() { + echo "$DIR_COLOR%1~%f" +} + +# Current time with milliseconds +current_time() { + echo "$TIME_COLOR%*%f" +} + +# Return status of the last command +return_status() { + echo "%(?..%F{001}out %?)%f" +} + +# Set the git_prompt_info text +ZSH_THEME_GIT_PROMPT_PREFIX="${ON_SYMBOL}${BRANCH_COLOR}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%f" +ZSH_THEME_GIT_PROMPT_DIRTY="" +ZSH_THEME_GIT_PROMPT_CLEAN="" + +# %B and %b make the text bold +PROMPT='%b$(username)$AT_SYMBOL$(device)$IN_SYMBOL$(directory)$(git_prompt_info)%b $SYMBOL ' +RPROMPT="$(return_status) $(current_time)" -- cgit v1.2.3-70-g09d2 From a8fee4036be264bd21ddf7fbe35f2a2e40eed412 Mon Sep 17 00:00:00 2001 From: Jethro Lee Date: Tue, 7 Jul 2020 00:12:00 +0900 Subject: Edit for better consistency in template (#8593) --- templates/zshrc.zsh-template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template index 0fa6d809e..307618104 100644 --- a/templates/zshrc.zsh-template +++ b/templates/zshrc.zsh-template @@ -33,7 +33,7 @@ ZSH_THEME="robbyrussell" # export UPDATE_ZSH_DAYS=13 # Uncomment the following line if pasting URLs and other text is messed up. -# DISABLE_MAGIC_FUNCTIONS=true +# DISABLE_MAGIC_FUNCTIONS="true" # Uncomment the following line to disable colors in ls. # DISABLE_LS_COLORS="true" -- cgit v1.2.3-70-g09d2 From fd9781b4c7036a3ef0a62744b9ecae327f9f2f24 Mon Sep 17 00:00:00 2001 From: MDHD Date: Mon, 6 Jul 2020 10:13:49 -0500 Subject: sudo: make the behavior more in line with expectations (#9047) --- plugins/sudo/sudo.plugin.zsh | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh index f405b025f..51579377d 100644 --- a/plugins/sudo/sudo.plugin.zsh +++ b/plugins/sudo/sudo.plugin.zsh @@ -13,15 +13,28 @@ # ------------------------------------------------------------------------------ sudo-command-line() { - [[ -z $BUFFER ]] && zle up-history - if [[ $BUFFER == sudo\ * ]]; then - LBUFFER="${LBUFFER#sudo }" - elif [[ $BUFFER == $EDITOR\ * ]]; then - LBUFFER="${LBUFFER#$EDITOR }" - LBUFFER="sudoedit $LBUFFER" + [[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)" + if [[ -n $EDITOR && $BUFFER == $EDITOR\ * ]]; then + if [[ ${#LBUFFER} -le ${#EDITOR} ]]; then + RBUFFER=" ${BUFFER#$EDITOR }" + LBUFFER="sudoedit" + else + LBUFFER="sudoedit ${LBUFFER#$EDITOR }" + fi elif [[ $BUFFER == sudoedit\ * ]]; then - LBUFFER="${LBUFFER#sudoedit }" - LBUFFER="$EDITOR $LBUFFER" + if [[ ${#LBUFFER} -le 8 ]]; then + RBUFFER=" ${BUFFER#sudoedit }" + LBUFFER="$EDITOR" + else + LBUFFER="$EDITOR ${LBUFFER#sudoedit }" + fi + elif [[ $BUFFER == sudo\ * ]]; then + if [[ ${#LBUFFER} -le 4 ]]; then + RBUFFER="${BUFFER#sudo }" + LBUFFER="" + else + LBUFFER="${LBUFFER#sudo }" + fi else LBUFFER="sudo $LBUFFER" fi -- cgit v1.2.3-70-g09d2 From d0d01c0bbf32ffe1dc22a66620ca85669c77e6b8 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 6 Jul 2020 17:17:40 +0200 Subject: lib: prefix diff call with command to bypass diff aliases See https://github.com/ohmyzsh/ohmyzsh/pull/8807#issuecomment-652697704 --- lib/theme-and-appearance.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 5c1b6db12..0b71de372 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -40,7 +40,7 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then fi # enable diff color if possible. -if diff --color . . &>/dev/null; then +if command diff --color . . &>/dev/null; then alias diff='diff --color' fi -- cgit v1.2.3-70-g09d2 From 1c58a746af7a67f311ee47f97285a855eaf18b5e Mon Sep 17 00:00:00 2001 From: Robert Estelle Date: Mon, 6 Jul 2020 08:31:40 -0700 Subject: lib: safety fix and speed-ups for git.zsh prompt functions (#7804) --- lib/git.zsh | 93 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index f7d4738ca..ffc7c01a1 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -1,9 +1,20 @@ +# The git prompt's git commands are read-only and should not interfere with +# other processes. This environment variable is equivalent to running with `git +# --no-optional-locks`, but falls back gracefully for older versions of git. +# See git(1) for and git-status(1) for a description of that flag. +# +# We wrap in a local function instead of exporting the variable directly in +# order to avoid interfering with manually-run git commands by the user. +function __git_prompt_git() { + GIT_OPTIONAL_LOCKS=0 command git "$@" +} + # Outputs current branch info in prompt format function git_prompt_info() { local ref - if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then - ref=$(command git symbolic-ref HEAD 2> /dev/null) || \ - ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0 + if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then + ref=$(__git_prompt_git symbolic-ref HEAD 2> /dev/null) || \ + ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) || return 0 echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" fi } @@ -13,7 +24,7 @@ function parse_git_dirty() { local STATUS local -a FLAGS FLAGS=('--porcelain') - if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then + if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then FLAGS+='--untracked-files=no' fi @@ -27,7 +38,7 @@ function parse_git_dirty() { FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}" ;; esac - STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1) + STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n1) fi if [[ -n $STATUS ]]; then echo "$ZSH_THEME_GIT_PROMPT_DIRTY" @@ -39,10 +50,10 @@ function parse_git_dirty() { # Gets the difference between the local and remote branches function git_remote_status() { local remote ahead behind git_remote_status git_remote_status_detailed - remote=${$(command git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/} + remote=${$(__git_prompt_git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/} if [[ -n ${remote} ]]; then - ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) - behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) + ahead=$(__git_prompt_git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) + behind=$(__git_prompt_git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) if [[ $ahead -eq 0 ]] && [[ $behind -eq 0 ]]; then git_remote_status="$ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE" @@ -71,11 +82,11 @@ function git_remote_status() { # it's not a symbolic ref, but in a Git repo. function git_current_branch() { local ref - ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null) + ref=$(__git_prompt_git symbolic-ref --quiet HEAD 2> /dev/null) local ret=$? if [[ $ret != 0 ]]; then [[ $ret == 128 ]] && return # no git repo. - ref=$(command git rev-parse --short HEAD 2> /dev/null) || return + ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) || return fi echo ${ref#refs/heads/} } @@ -83,8 +94,8 @@ function git_current_branch() { # Gets the number of commits ahead from remote function git_commits_ahead() { - if command git rev-parse --git-dir &>/dev/null; then - local commits="$(git rev-list --count @{upstream}..HEAD 2>/dev/null)" + if __git_prompt_git rev-parse --git-dir &>/dev/null; then + local commits="$(__git_prompt_git rev-list --count @{upstream}..HEAD 2>/dev/null)" if [[ -n "$commits" && "$commits" != 0 ]]; then echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" fi @@ -93,8 +104,8 @@ function git_commits_ahead() { # Gets the number of commits behind remote function git_commits_behind() { - if command git rev-parse --git-dir &>/dev/null; then - local commits="$(git rev-list --count HEAD..@{upstream} 2>/dev/null)" + if __git_prompt_git rev-parse --git-dir &>/dev/null; then + local commits="$(__git_prompt_git rev-list --count HEAD..@{upstream} 2>/dev/null)" if [[ -n "$commits" && "$commits" != 0 ]]; then echo "$ZSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$ZSH_THEME_GIT_COMMITS_BEHIND_SUFFIX" fi @@ -103,21 +114,21 @@ function git_commits_behind() { # Outputs if current branch is ahead of remote function git_prompt_ahead() { - if [[ -n "$(command git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then + if [[ -n "$(__git_prompt_git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then echo "$ZSH_THEME_GIT_PROMPT_AHEAD" fi } # Outputs if current branch is behind remote function git_prompt_behind() { - if [[ -n "$(command git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then + if [[ -n "$(__git_prompt_git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then echo "$ZSH_THEME_GIT_PROMPT_BEHIND" fi } # Outputs if current branch exists on remote or not function git_prompt_remote() { - if [[ -n "$(command git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then + if [[ -n "$(__git_prompt_git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then echo "$ZSH_THEME_GIT_PROMPT_REMOTE_EXISTS" else echo "$ZSH_THEME_GIT_PROMPT_REMOTE_MISSING" @@ -127,62 +138,50 @@ function git_prompt_remote() { # Formats prompt string for current git commit short SHA function git_prompt_short_sha() { local SHA - SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" + SHA=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" } # Formats prompt string for current git commit long SHA function git_prompt_long_sha() { local SHA - SHA=$(command git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" + 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 + local INDEX STATUS - INDEX=$(command git status --porcelain -b 2> /dev/null) + INDEX=$(__git_prompt_git status --porcelain -b 2> /dev/null) || return 0 STATUS="" - if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then + if [[ "${INDEX}" =~ $'(^|\n)\\?\\? ' ]]; then STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" fi - if $(echo "$INDEX" | grep '^A ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" - elif $(echo "$INDEX" | grep '^M ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" - elif $(echo "$INDEX" | grep '^MM ' &> /dev/null); then + if [[ "${INDEX}" =~ $'(^|\n)(A |M |MM) ' ]]; then STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" fi - if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" - elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" - elif $(echo "$INDEX" | grep '^MM ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" - elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then + if [[ "${INDEX}" =~ $'(^|\n)([ AM]M| T) ' ]]; then STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" fi - if $(echo "$INDEX" | grep '^R ' &> /dev/null); then + if [[ "${INDEX}" =~ $'(^|\n)R ' ]]; then STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS" fi - if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" - elif $(echo "$INDEX" | grep '^D ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" - elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then + if [[ "${INDEX}" =~ $'(^|\n)([A ]D|D ) ' ]]; then STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" fi - if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then + if $(__git_prompt_git rev-parse --verify refs/stash >/dev/null 2>&1); then STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS" fi - if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then + if [[ "${INDEX}" =~ $'(^|\n)UU ' ]]; then STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" fi - if $(echo "$INDEX" | grep '^## [^ ]\+ .*ahead' &> /dev/null); then + if [[ "${INDEX}" =~ $'(^|\n)## [^ ]\+ .*ahead' ]]; then STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS" fi - if $(echo "$INDEX" | grep '^## [^ ]\+ .*behind' &> /dev/null); then + if [[ "${INDEX}" =~ $'(^|\n)## [^ ]\+ .*behind' ]]; then STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS" fi - if $(echo "$INDEX" | grep '^## [^ ]\+ .*diverged' &> /dev/null); then + if [[ "${INDEX}" =~ $'(^|\n)## [^ ]\+ .*diverged' ]]; then STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS" fi echo $STATUS @@ -191,20 +190,20 @@ function git_prompt_status() { # Outputs the name of the current user # Usage example: $(git_current_user_name) function git_current_user_name() { - command git config user.name 2>/dev/null + __git_prompt_git config user.name 2>/dev/null } # Outputs the email of the current user # Usage example: $(git_current_user_email) function git_current_user_email() { - command git config user.email 2>/dev/null + __git_prompt_git config user.email 2>/dev/null } # Output the name of the root directory of the git repository # Usage example: $(git_repo_name) function git_repo_name() { local repo_path - if repo_path="$(git rev-parse --show-toplevel 2>/dev/null)" && [[ -n "$repo_path" ]]; then + if repo_path="$(__git_prompt_git rev-parse --show-toplevel 2>/dev/null)" && [[ -n "$repo_path" ]]; then echo ${repo_path:t} fi } -- cgit v1.2.3-70-g09d2 From d79941b78997f7c11e247c08678fd57827db3b42 Mon Sep 17 00:00:00 2001 From: Lutz Horn Date: Thu, 9 Jul 2020 10:43:59 +0200 Subject: aws: allow @ in AWS profiles (#9099) Fixes #9060 by matching a `@` in the AWS profile name. --- plugins/aws/aws.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 4b5446407..d00c2e56c 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -41,7 +41,7 @@ function aws_change_access_key() { function aws_profiles() { [[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1 - grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/' + grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9@_\.-]*\).*/\1/' } function _aws_profiles() { -- cgit v1.2.3-70-g09d2 From 1db79f97f5523cd2c76b5dfb8185a6d3b7a789d9 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 9 Jul 2020 11:16:16 +0200 Subject: git: use `master` if it exists, otherwise use `main` See https://github.com/ohmyzsh/ohmyzsh/pull/9049#issuecomment-654537347 Co-authored-by: Yufan You --- plugins/git/README.md | 6 +++--- plugins/git/git.plugin.zsh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index b7f216813..e809e1bcd 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -183,8 +183,8 @@ plugins=(... git) Following the recent push for removing racially-charged words from our technical vocabulary, the git plugin favors using a branch name other than `master`. In this case, we favor the shorter, neutral and descriptive term `main`. This means -that any aliases and functions that previously used `master`, will use `main` if that branch exists. We do this via the -function `git_main_branch`. +that any aliases and functions that previously used `master`, will use `main` if `master` doesn't exist. We do this via +the function `git_main_branch`. ### Deprecated aliases @@ -214,7 +214,7 @@ These are aliases that have been removed, renamed, or otherwise modified in a wa | current_branch | Return the name of the current branch | | git_current_user_name | Returns the `user.name` config value | | git_current_user_email | Returns the `user.email` config value | -| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise | +| git_main_branch | Returns the name of the main branch: `master` if it exists, `main` otherwise | ### Work in Progress (WIP) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 5a9ccff5c..6cae3dac2 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -27,10 +27,10 @@ function work_in_progress() { # Check if main exists and use instead of master function git_main_branch() { - if [[ -n "$(git branch --list main)" ]]; then - echo main - else + if [[ -n "$(git branch --list master)" ]]; then echo master + else + echo main fi } -- cgit v1.2.3-70-g09d2 From 327ac697c7542f03c69edca1515656a653f23656 Mon Sep 17 00:00:00 2001 From: Veit Lehmann Date: Thu, 9 Jul 2020 11:23:49 +0200 Subject: mix-fast: add decriptions to mix-fast completions (#8561) * feat(mix-fast): include desctiptions (#8561) * feat(mix-fast): improve _mix_generate (no tail, better matching) --- plugins/mix-fast/mix-fast.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/mix-fast/mix-fast.plugin.zsh b/plugins/mix-fast/mix-fast.plugin.zsh index e27e30d64..564c50561 100644 --- a/plugins/mix-fast/mix-fast.plugin.zsh +++ b/plugins/mix-fast/mix-fast.plugin.zsh @@ -12,7 +12,7 @@ _mix_does_task_list_need_generating () { } _mix_generate () { - mix help | grep -v 'iex -S' | tail -n +2 | cut -d " " -f 2 > .mix_tasks + mix help | grep '^mix [^ ]' | sed -E "s/mix ([^ ]*) *# (.*)/\1:\2/" > .mix_tasks } _mix () { @@ -21,7 +21,8 @@ _mix () { echo "\nGenerating .mix_tasks..." > /dev/stderr _mix_generate fi - compadd `cat .mix_tasks` + local tasks=(${(f)"$(cat .mix_tasks)"}) + _describe 'tasks' tasks fi } -- cgit v1.2.3-70-g09d2 From 7deaff71a2be08145d83f0177edbf2dfb3e91262 Mon Sep 17 00:00:00 2001 From: Emilien Escalle Date: Thu, 9 Jul 2020 15:29:26 +0200 Subject: yarn: add alias for upgrade-interactive to the latest version (#8764) --- plugins/yarn/README.md | 65 ++++++++++++++++++++++---------------------- plugins/yarn/yarn.plugin.zsh | 1 + 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/plugins/yarn/README.md b/plugins/yarn/README.md index 05f18a499..fd748b742 100644 --- a/plugins/yarn/README.md +++ b/plugins/yarn/README.md @@ -11,35 +11,36 @@ plugins=(... yarn) ## Aliases -| Alias | Command | Description | -|-------|-------------------------------------------|-------------------------------------------------------------| -| y | `yarn` | The Yarn command | -| ya | `yarn add` | Install a package in dependencies (`package.json`) | -| yad | `yarn add --dev` | Install a package in devDependencies (`package.json`) | -| yap | `yarn add --peer` | Install a package in peerDependencies (`package.json`) | -| yb | `yarn build` | Run the build script defined in `package.json` | -| ycc | `yarn cache clean` | Clean yarn's global cache of packages | -| yd | `yarn dev` | Run the dev script defined in `package.json` | -| yga | `yarn global add` | Install packages globally on your operating system | -| ygls | `yarn global list` | Lists global installed packages | -| ygrm | `yarn global remove` | Remove global installed packages from your OS | -| ygu | `yarn global upgrade` | Upgrade packages installed globally to their latest version | -| yh | `yarn help` | Show help for a yarn command | -| yi | `yarn init` | Interactively creates or updates a package.json file | -| yin | `yarn install` | Install dependencies defined in `package.json` | -| yln | `yarn lint` | Run the lint script defined in `package.json` | -| yls | `yarn list` | List installed packages | -| yout | `yarn outdated` | Check for outdated package dependencies | -| yp | `yarn pack` | Create a compressed gzip archive of package dependencies | -| yrm | `yarn remove` | Remove installed packages | -| yrun | `yarn run` | Run a defined package script | -| ys | `yarn serve` | Start the dev server | -| yst | `yarn start` | Run the start script defined in `package.json` | -| yt | `yarn test` | Run the test script defined in `package.json` | -| ytc | `yarn test --coverage` | Run the test script defined in `package.json` with coverage | -| yuc | `yarn global upgrade && yarn cache clean` | Upgrade global packages and clean yarn's global cache | -| yui | `yarn upgrade-interactive` | Prompt for which outdated packages to upgrade | -| yup | `yarn upgrade` | Upgrade packages to their latest version | -| yv | `yarn version` | Update the version of your package | -| yw | `yarn workspace` | Run a command within a single workspace. | -| yws | `yarn workspaces` | Run a command within all defined workspaces. | +| Alias | Command | Description | +| ----- | ----------------------------------------- | ----------------------------------------------------------------------------- | +| y | `yarn` | The Yarn command | +| ya | `yarn add` | Install a package in dependencies (`package.json`) | +| yad | `yarn add --dev` | Install a package in devDependencies (`package.json`) | +| yap | `yarn add --peer` | Install a package in peerDependencies (`package.json`) | +| yb | `yarn build` | Run the build script defined in `package.json` | +| ycc | `yarn cache clean` | Clean yarn's global cache of packages | +| yd | `yarn dev` | Run the dev script defined in `package.json` | +| yga | `yarn global add` | Install packages globally on your operating system | +| ygls | `yarn global list` | Lists global installed packages | +| ygrm | `yarn global remove` | Remove global installed packages from your OS | +| ygu | `yarn global upgrade` | Upgrade packages installed globally to their latest version | +| yh | `yarn help` | Show help for a yarn command | +| yi | `yarn init` | Interactively creates or updates a package.json file | +| yin | `yarn install` | Install dependencies defined in `package.json` | +| yln | `yarn lint` | Run the lint script defined in `package.json` | +| yls | `yarn list` | List installed packages | +| yout | `yarn outdated` | Check for outdated package dependencies | +| yp | `yarn pack` | Create a compressed gzip archive of package dependencies | +| yrm | `yarn remove` | Remove installed packages | +| yrun | `yarn run` | Run a defined package script | +| ys | `yarn serve` | Start the dev server | +| yst | `yarn start` | Run the start script defined in `package.json` | +| yt | `yarn test` | Run the test script defined in `package.json` | +| ytc | `yarn test --coverage` | Run the test script defined in `package.json` with coverage | +| yuc | `yarn global upgrade && yarn cache clean` | Upgrade global packages and clean yarn's global cache | +| yui | `yarn upgrade-interactive` | Prompt for which outdated packages to upgrade | +| yuil | `yarn upgrade-interactive --latest` | Prompt for which outdated packages to upgrade to the latest available version | +| yup | `yarn upgrade` | Upgrade packages to their latest version | +| yv | `yarn version` | Update the version of your package | +| yw | `yarn workspace` | Run a command within a single workspace. | +| yws | `yarn workspaces` | Run a command within all defined workspaces. | diff --git a/plugins/yarn/yarn.plugin.zsh b/plugins/yarn/yarn.plugin.zsh index 9cfcb7539..4a5192c61 100644 --- a/plugins/yarn/yarn.plugin.zsh +++ b/plugins/yarn/yarn.plugin.zsh @@ -24,6 +24,7 @@ alias yt="yarn test" alias ytc="yarn test --coverage" alias yuc="yarn global upgrade && yarn cache clean" alias yui="yarn upgrade-interactive" +alias yuil="yarn upgrade-interactive --latest" alias yup="yarn upgrade" alias yv="yarn version" alias yw="yarn workspace" -- cgit v1.2.3-70-g09d2 From 9cdc2764967f9255fa343e77217d62d2703d5549 Mon Sep 17 00:00:00 2001 From: Jakob Hellermann Date: Sat, 11 Jul 2020 17:34:24 +0200 Subject: dotenv: add never option to confirmation prompt (#9102) --- plugins/dotenv/README.md | 24 +++++++++++++++--------- plugins/dotenv/dotenv.plugin.zsh | 12 ++++++++++-- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/plugins/dotenv/README.md b/plugins/dotenv/README.md index f66124731..ab9d329f6 100644 --- a/plugins/dotenv/README.md +++ b/plugins/dotenv/README.md @@ -53,24 +53,30 @@ Set `ZSH_DOTENV_PROMPT=false` in your zshrc file if you don't want the confirmat You can also choose the `Always` option when prompted to always allow sourcing the .env file in that directory. See the next section for more details. -### ZSH_DOTENV_ALLOWED_LIST +### ZSH_DOTENV_ALLOWED_LIST, ZSH_DOTENV_DISALLOWED_LIST The default behavior of the plugin is to always ask whether to source a dotenv file. There's -a **Y**es, **N**o, and **A**lways option. If you choose Always, the directory of the .env file -will be added to an allowed list. If a directory is found in this list, the plugin won't ask -for confirmation and will instead source the .env file directly. +a **Y**es, **N**o, **A**lways and N**e**ver option. If you choose Always, the directory of the .env file +will be added to an allowed list; if you choose Never, it will be added to a disallowed list. +If a directory is found in either of those lists, the plugin won't ask for confirmation and will +instead either source the .env file or proceed without action respectively. -This allowed list is saved by default in `$ZSH_CACHE_DIR/dotenv-allowed.list`. If you want -to change that location, change the `$ZSH_DOTENV_ALLOWED_LIST` variable, like so: +The allowed and disallowed lists are saved by default in `$ZSH_CACHE_DIR/dotenv-allowed.list` and +`$ZSH_CACHE_DIR/dotenv-disallowed.list` respectively. If you want to change that location, +change the `$ZSH_DOTENV_ALLOWED_LIST` and `$ZSH_DOTENV_DISALLOWED_LIST` variables, like so: ```zsh # in ~/.zshrc, before Oh My Zsh is sourced: ZSH_DOTENV_ALLOWED_LIST=/path/to/dotenv/allowed/list +ZSH_DOTENV_DISALLOWED_LIST=/path/to/dotenv/disallowed/list ``` -This file is just a list of directories allowed, separated by a newline character. If you want -to disallow a directory, just edit this file and remove the line for the directory you want to -disallow. +The file is just a list of directories, separated by a newline character. If you want +to change your decision, just edit the file and remove the line for the directory you want to +change. + +NOTE: if a directory is found in both the allowed and disallowed lists, the disallowed list +takes preference, _i.e._ the .env file will never be sourced. ## Version Control diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh index ac3210d7f..24f285df5 100644 --- a/plugins/dotenv/dotenv.plugin.zsh +++ b/plugins/dotenv/dotenv.plugin.zsh @@ -5,6 +5,7 @@ # Path to the file containing allowed paths : ${ZSH_DOTENV_ALLOWED_LIST:="${ZSH_CACHE_DIR:-$ZSH/cache}/dotenv-allowed.list"} +: ${ZSH_DOTENV_DISALLOWED_LIST:="${ZSH_CACHE_DIR:-$ZSH/cache}/dotenv-disallowed.list"} ## Functions @@ -14,19 +15,26 @@ source_env() { if [[ "$ZSH_DOTENV_PROMPT" != false ]]; then local confirmation dirpath="${PWD:A}" - # make sure there is an allowed file + # make sure there is an (dis-)allowed file touch "$ZSH_DOTENV_ALLOWED_LIST" + touch "$ZSH_DOTENV_DISALLOWED_LIST" + + # early return if disallowed + if grep -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then + return; + fi # check if current directory's .env file is allowed or ask for confirmation if ! grep -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then # print same-line prompt and output newline character if necessary - echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([Y]es/[n]o/[a]lways) " + echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([Y]es/[n]o/[a]lways/n[e]ver) " read -k 1 confirmation; [[ "$confirmation" != $'\n' ]] && echo # check input case "$confirmation" in [nN]) return ;; [aA]) echo "$dirpath" >> "$ZSH_DOTENV_ALLOWED_LIST" ;; + [eE]) echo "$dirpath" >> "$ZSH_DOTENV_DISALLOWED_LIST"; return ;; *) ;; # interpret anything else as a yes esac fi -- cgit v1.2.3-70-g09d2 From 55a98fc06d9ea9d003683dec5aae6cb6b0130ab0 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 11 Jul 2020 20:02:06 +0200 Subject: git: better algorithm to decide what's the main branch Fixes #9103 Co-authored-by: Yufan You --- plugins/git/git.plugin.zsh | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 6cae3dac2..7284cd121 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -25,13 +25,30 @@ function work_in_progress() { fi } -# Check if main exists and use instead of master +# Get the default 'main' branch +# Marc(2020-07-11): I hope to be able to remove this someday function git_main_branch() { - if [[ -n "$(git branch --list master)" ]]; then - echo master - else - echo main + # Get default branch from the origin remote + local branch + branch="${$(command git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null)#refs/remotes/origin/}" + + if [[ -n "$branch" ]]; then + echo "$branch" + return fi + + # Look up list of local branches and return the first one that exists + local -a branches + branches=(${(@f)"$(command git for-each-ref --format='%(refname:short)' refs/heads 2>/dev/null)"}) + for branch in master main; do + if (( ${branches[(Ie)$branch]} )); then + echo "$branch" + return + fi + done + + echo master + return 1 } # -- cgit v1.2.3-70-g09d2 From 83f61949292b865a7962f1f0a4a8c0fc6350f313 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 11 Jul 2020 20:18:05 +0200 Subject: git: change docs for git_main_branch Also remove unnecesary dramatic remark --- plugins/git/README.md | 14 +++++++------- plugins/git/git.plugin.zsh | 3 +-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index e809e1bcd..b92d0bf02 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -208,13 +208,13 @@ These are aliases that have been removed, renamed, or otherwise modified in a wa ### Current -| Command | Description | -|:-----------------------|:-----------------------------------------------------------------------------| -| `grename ` | Rename `old` branch to `new`, including in origin remote | -| current_branch | Return the name of the current branch | -| git_current_user_name | Returns the `user.name` config value | -| git_current_user_email | Returns the `user.email` config value | -| git_main_branch | Returns the name of the main branch: `master` if it exists, `main` otherwise | +| Command | Description | +|:-----------------------|:---------------------------------------------------------------------------------------| +| `grename ` | Rename `old` branch to `new`, including in origin remote | +| current_branch | Return the name of the current branch | +| git_current_user_name | Returns the `user.name` config value | +| git_current_user_email | Returns the `user.email` config value | +| git_main_branch | Returns the name of the main branch: from origin or from local branches, else 'master' | ### Work in Progress (WIP) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 7284cd121..8f8edcd23 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -25,8 +25,7 @@ function work_in_progress() { fi } -# Get the default 'main' branch -# Marc(2020-07-11): I hope to be able to remove this someday +# Get the default 'main' branch: from origin, from local branches, or else just 'master' function git_main_branch() { # Get default branch from the origin remote local branch -- cgit v1.2.3-70-g09d2 From 71f0189ed57911360b19883cb6211fe621292086 Mon Sep 17 00:00:00 2001 From: Džiugas Eiva Date: Sat, 11 Jul 2020 21:59:58 +0100 Subject: vscode: add support for VSCodium (#9080) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Babak K. Shandiz Co-authored-by: Marc Cornellà --- plugins/vscode/README.md | 32 +++++++++++++++++++++++--------- plugins/vscode/vscode.plugin.zsh | 27 +++++++++++++++++++-------- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/plugins/vscode/README.md b/plugins/vscode/README.md index 469c57ea8..e95ed5d4f 100644 --- a/plugins/vscode/README.md +++ b/plugins/vscode/README.md @@ -1,6 +1,6 @@ # VS Code -This plugin makes interaction between the command line and the VS Code editor easier. +This plugin provides useful aliases to simplify the interaction between the command line and VS Code or VSCodium editor. To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc`: @@ -10,23 +10,37 @@ plugins=(... vscode) ## Requirements -To use VS Code in the terminal **in macOS**, first you need to install the `code` command in the PATH, -otherwise you might receive this message: `zsh: command not found: code`. +This plugin requires to have a flavour of VS Code installed and it's executable available in PATH. -[As the docs say](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line), open +You can install either: + +* VS Code (code) +* VS Code Insiders (code-insiders) +* VSCodium (codium) + +### MacOS +While Linux installations will add the executable to PATH, MacOS users might still have to do this manually: + +[For VS Code and VS Code Insiders](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line), open the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell Command: -> Install 'code' command in PATH +> Shell Command: Install 'code' command in PATH -## VS Code Insiders +[For VSCodium](https://github.com/VSCodium/vscodium/blob/master/DOCS.md#how-do-i-open-vscodium-from-the-terminal), open +the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell Command: +> Shell Command: Install 'codium' command in PATH -🍏 **If you are only using [VS Code Insiders](https://code.visualstudio.com/insiders/), the plugin will automatically bind to your Insiders installation.** +## Using multiple flavours -But, if you have both Stable and Insiders versions and want to configure the plugin to just use the Insiders version, add the following line in the oh-my-zsh settings section (between the `ZSH_THEME` and the `plugins=()` line). This will make the plugin use the Insiders version instead. +If for any reason, you ever require to use multiple flavours of VS Code i.e. VS Code (stable) and VS Code Insiders, you can +manually specify the flavour's executable. Add the following line to the .zshrc file (between the `ZSH_THEME` and the `plugins=()` lines). +This will make the plugin use your manually defined executable. ```zsh ZSH_THEME=... -# Add this line to use code-insiders instead of code +# Choose between one [code, code-insiders or codium] +# The following line will make the plugin to open VS Code Insiders +# Invalid entries will be ignored, no aliases will be added VSCODE=code-insiders plugins=(... vscode) diff --git a/plugins/vscode/vscode.plugin.zsh b/plugins/vscode/vscode.plugin.zsh index 0144e0baa..48d904377 100644 --- a/plugins/vscode/vscode.plugin.zsh +++ b/plugins/vscode/vscode.plugin.zsh @@ -1,17 +1,28 @@ -# VScode zsh plugin +# VS Code (stable / insiders) / VSCodium zsh plugin # Authors: # https://github.com/MarsiBarsi (original author) # https://github.com/babakks +# https://github.com/SteelShot -# Use the stable VS Code release, unless the Insiders version is the only -# available installation -if ! which code > /dev/null && which code-insiders > /dev/null; then - : ${VSCODE:=code-insiders} -else - : ${VSCODE:=code} +# Verify if any manual user choice of VS Code exists first. +if [[ -n "$VSCODE" ]] && ! which $VSCODE &>/dev/null; then + echo "'$VSCODE' flavour of VS Code not detected." + unset VSCODE +fi + +# Otherwise, try to detect a flavour of VS Code. +if [[ -z "$VSCODE" ]]; then + if which code &>/dev/null; then + VSCODE=code + elif which code-insiders &>/dev/null; then + VSCODE=code-insiders + elif which codium &>/dev/null; then + VSCODE=codium + else + return + fi fi -# Define aliases alias vsc="$VSCODE ." alias vsca="$VSCODE --add" alias vscd="$VSCODE --diff" -- cgit v1.2.3-70-g09d2 From e3131d98aa056145ed34ef19dfe77efff87be21b Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sun, 12 Jul 2020 16:37:49 +0200 Subject: Fix self check link --- .github/ISSUE_TEMPLATE/bug_report.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 024231531..b7f5460c1 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -27,18 +27,20 @@ If applicable, add screenshots to help explain your problem. You can also record an asciinema session: https://asciinema.org/ **Self Check** -Have you tried reaching out on the [Discord server](discord.gg/ohmyzsh)? -This can help cut down on filling up issues. We always have a few people -online that are in a variety of timezones that are willing to help you! -Also searching existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=) -might help you get quicker support + +- Have you tried reaching out on the [Discord server](https://discord.gg/ohmyzsh)? + This can help cut down on filling up issues. We always have a few people + online that are in a variety of timezones that are willing to help you! + +- Also searching existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=) might help you get quicker support **Desktop (please complete the following information):** + - OS / Distro: [e.g. Arch Linux, macOS] - If on Windows what version of WSL: [e.g. WSL1, WSL2] - - Latest ohmyzsh Update?: [e.g. Yes/No] + - Latest ohmyzsh update?: [e.g. Yes/No] - ZSH Version: [e.g. 5.6] - - Terminal emulator [e.g. iTerm2] + - Terminal emulator: [e.g. iTerm2] **Additional context** Add any other context about the problem here. This can be themes, plugins, custom configs. -- cgit v1.2.3-70-g09d2 From 5c1a5c6ce924755095020fd829b08f0ee205a723 Mon Sep 17 00:00:00 2001 From: "M. Yas. Davoodeh" <30480116+MYDavoodeh@users.noreply.github.com> Date: Mon, 13 Jul 2020 14:22:28 +0430 Subject: update: prefix rm call with command in trap (#9107) * Suppress the problematic trap output in check_upg The newly added trap, in systems where `rm` is aliased to `rm="rm -v"`, shows a message stating that "update.lock" has been removed each time `zsh` is called. I simply suppressed it with directing the output to `/dev/null`. * Use `command` instead of >/dev/null to suppress --- tools/check_for_upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index c91431c25..cadd5fe49 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -51,7 +51,7 @@ function update_ohmyzsh() { # The return status from the function is handled specially. If it is zero, the signal is # assumed to have been handled, and execution continues normally. Otherwise, the shell # will behave as interrupted except that the return status of the trap is retained. - trap "rm -rf '$ZSH/log/update.lock'; return 1" EXIT INT QUIT + trap "command rm -rf '$ZSH/log/update.lock'; return 1" EXIT INT QUIT # Create or update .zsh-update file if missing or malformed if ! source "${ZSH_CACHE_DIR}/.zsh-update" 2>/dev/null || [[ -z "$LAST_EPOCH" ]]; then -- cgit v1.2.3-70-g09d2 From 93e9b80d3ff160c7d7f5be4c2c1862da97b273dc Mon Sep 17 00:00:00 2001 From: Alexander Schaber Date: Tue, 14 Jul 2020 16:50:18 +0200 Subject: httpie: add alias for https (#8032) --- plugins/httpie/README.md | 6 ++++++ plugins/httpie/httpie.plugin.zsh | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 plugins/httpie/httpie.plugin.zsh diff --git a/plugins/httpie/README.md b/plugins/httpie/README.md index 25bdd0c7d..40d60c47d 100644 --- a/plugins/httpie/README.md +++ b/plugins/httpie/README.md @@ -11,4 +11,10 @@ plugins=(... httpie) It uses completion from [zsh-completions](https://github.com/zsh-users/zsh-completions). +## Aliases + +| Alias | Command | +| ------------ | ---------------------------------------------------------------- | +| `https` | `http --default-scheme=https` | + **Maintainer:** [lululau](https://github.com/lululau) diff --git a/plugins/httpie/httpie.plugin.zsh b/plugins/httpie/httpie.plugin.zsh new file mode 100644 index 000000000..088a1f1cf --- /dev/null +++ b/plugins/httpie/httpie.plugin.zsh @@ -0,0 +1,7 @@ +# +# Aliases +# (sorted alphabetically) +# + +alias https='http --default-scheme=https' + -- cgit v1.2.3-70-g09d2 From 8260005dc7bba42d82edd8e606c10d9e7a9bb26e Mon Sep 17 00:00:00 2001 From: Joaquín Moreira Date: Tue, 14 Jul 2020 11:39:33 -0400 Subject: kubectl: add alias to list pods by namespace (#8604) --- plugins/kubectl/README.md | 3 ++- plugins/kubectl/kubectl.plugin.zsh | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/kubectl/README.md b/plugins/kubectl/README.md index c0db59362..ee05a8af1 100644 --- a/plugins/kubectl/README.md +++ b/plugins/kubectl/README.md @@ -33,7 +33,8 @@ plugins=(... kubectl) | kep | `kubectl edit pods` | Edit pods from the default editor | | kdp | `kubectl describe pods` | Describe all pods | | kdelp | `kubectl delete pods` | Delete all pods matching passed arguments | -| kgpl | `kgp -l` | Get pod by label. Example: `kgpl "app=myapp" -n myns` | +| kgpl | `kgp -l` | Get pods by label. Example: `kgpl "app=myapp" -n myns` | +| kgpn | `kgp -n` | Get pods by namespace. Example: `kgpn kube-system` | | | | **Service management** | | kgs | `kubectl get svc` | List all services in ps output format | | kgsw | `kgs --watch` | After listing all services, watch for changes | diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index 92688c53c..647d029c1 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -47,6 +47,9 @@ alias kdelp='kubectl delete pods' # get pod by label: kgpl "app=myapp" -n myns alias kgpl='kgp -l' +# get pod by namespace: kgpn kube-system" +alias kgpn='kgp -n' + # Service management. alias kgs='kubectl get svc' alias kgsa='kubectl get svc --all-namespaces' -- cgit v1.2.3-70-g09d2 From 68b98c9d53a4dd0c53d25a9595305e2318af0e2b Mon Sep 17 00:00:00 2001 From: Piotr Zając Date: Tue, 14 Jul 2020 17:40:23 +0200 Subject: docker-compose: add alias for `docker-compose kill` (#8997) --- plugins/docker-compose/README.md | 1 + plugins/docker-compose/docker-compose.plugin.zsh | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/docker-compose/README.md b/plugins/docker-compose/README.md index 1105e03f6..a81c2c78e 100644 --- a/plugins/docker-compose/README.md +++ b/plugins/docker-compose/README.md @@ -28,3 +28,4 @@ plugins=(... docker-compose) | dclf | `docker-compose logs -f` | Show logs and follow output | | dcpull | `docker-compose pull` | Pull image of a service | | dcstart | `docker-compose start` | Start a container | +| dck | `docker-compose kill` | Kills containers | diff --git a/plugins/docker-compose/docker-compose.plugin.zsh b/plugins/docker-compose/docker-compose.plugin.zsh index 9ffe1edf6..5b25b63b9 100644 --- a/plugins/docker-compose/docker-compose.plugin.zsh +++ b/plugins/docker-compose/docker-compose.plugin.zsh @@ -24,3 +24,4 @@ alias dcl='docker-compose logs' alias dclf='docker-compose logs -f' alias dcpull='docker-compose pull' alias dcstart='docker-compose start' +alias dck='docker-compose kill' -- cgit v1.2.3-70-g09d2 From ff7618cf744a289a9ba9c332be08ed5304d2f45f Mon Sep 17 00:00:00 2001 From: Frederick Zhang Date: Wed, 15 Jul 2020 02:53:37 +1000 Subject: timer: threshold to show timers only for time-consuming commands (#8151) --- plugins/timer/README.md | 1 + plugins/timer/timer.plugin.zsh | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/timer/README.md b/plugins/timer/README.md index 321307e59..30b0bd00e 100644 --- a/plugins/timer/README.md +++ b/plugins/timer/README.md @@ -3,6 +3,7 @@ This plugin allows to display command's execution time in a very nonintrusive wa Timer can be tuned by these two variables: * `TIMER_PRECISION` allows to control number of decimal places (default `1`) * `TIMER_FORMAT` allows to adjust display format (default `'/%d'`) +* `TIMER_THRESHOLD` allows to set the minimum execution time that causes the timer to be shown (default `0`) Sample session: diff --git a/plugins/timer/timer.plugin.zsh b/plugins/timer/timer.plugin.zsh index 728377c5c..1be7516a3 100644 --- a/plugins/timer/timer.plugin.zsh +++ b/plugins/timer/timer.plugin.zsh @@ -19,9 +19,11 @@ __timer_display_timer_precmd() { local cmd_end_time=$(__timer_current_time) local tdiff=$((cmd_end_time - __timer_cmd_start_time)) unset __timer_cmd_start_time - local tdiffstr=$(__timer_format_duration ${tdiff}) - local cols=$((COLUMNS - ${#tdiffstr} - 1)) - echo -e "\033[1A\033[${cols}C ${tdiffstr}" + if [[ -z "${TIMER_THRESHOLD}" || ${tdiff} -ge "${TIMER_THRESHOLD}" ]]; then + local tdiffstr=$(__timer_format_duration ${tdiff}) + local cols=$((COLUMNS - ${#tdiffstr} - 1)) + echo -e "\033[1A\033[${cols}C ${tdiffstr}" + fi fi } -- cgit v1.2.3-70-g09d2 From c99f3c50fa46a93be28be88632889404fff3b958 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 15 Jul 2020 17:02:49 +0200 Subject: git: go back to previous main branch detection logic Fixes #9114 --- plugins/git/README.md | 18 +++++++++--------- plugins/git/git.plugin.zsh | 26 +++++--------------------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index b92d0bf02..b7f216813 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -183,8 +183,8 @@ plugins=(... git) Following the recent push for removing racially-charged words from our technical vocabulary, the git plugin favors using a branch name other than `master`. In this case, we favor the shorter, neutral and descriptive term `main`. This means -that any aliases and functions that previously used `master`, will use `main` if `master` doesn't exist. We do this via -the function `git_main_branch`. +that any aliases and functions that previously used `master`, will use `main` if that branch exists. We do this via the +function `git_main_branch`. ### Deprecated aliases @@ -208,13 +208,13 @@ These are aliases that have been removed, renamed, or otherwise modified in a wa ### Current -| Command | Description | -|:-----------------------|:---------------------------------------------------------------------------------------| -| `grename ` | Rename `old` branch to `new`, including in origin remote | -| current_branch | Return the name of the current branch | -| git_current_user_name | Returns the `user.name` config value | -| git_current_user_email | Returns the `user.email` config value | -| git_main_branch | Returns the name of the main branch: from origin or from local branches, else 'master' | +| Command | Description | +|:-----------------------|:-----------------------------------------------------------------------------| +| `grename ` | Rename `old` branch to `new`, including in origin remote | +| current_branch | Return the name of the current branch | +| git_current_user_name | Returns the `user.name` config value | +| git_current_user_email | Returns the `user.email` config value | +| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise | ### Work in Progress (WIP) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 8f8edcd23..5a9ccff5c 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -25,29 +25,13 @@ function work_in_progress() { fi } -# Get the default 'main' branch: from origin, from local branches, or else just 'master' +# Check if main exists and use instead of master function git_main_branch() { - # Get default branch from the origin remote - local branch - branch="${$(command git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null)#refs/remotes/origin/}" - - if [[ -n "$branch" ]]; then - echo "$branch" - return + if [[ -n "$(git branch --list main)" ]]; then + echo main + else + echo master fi - - # Look up list of local branches and return the first one that exists - local -a branches - branches=(${(@f)"$(command git for-each-ref --format='%(refname:short)' refs/heads 2>/dev/null)"}) - for branch in master main; do - if (( ${branches[(Ie)$branch]} )); then - echo "$branch" - return - fi - done - - echo master - return 1 } # -- cgit v1.2.3-70-g09d2 From 322e592c38da2ade0e0db168bb6fdcd3f298600c Mon Sep 17 00:00:00 2001 From: Thi Doãn Date: Sat, 18 Jul 2020 23:32:50 +0900 Subject: extract: add IPA to extractable filetypes (#9117) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/extract/README.md | 1 + plugins/extract/_extract | 2 +- plugins/extract/extract.plugin.zsh | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/extract/README.md b/plugins/extract/README.md index 81e8e1d23..b2b731e39 100644 --- a/plugins/extract/README.md +++ b/plugins/extract/README.md @@ -23,6 +23,7 @@ plugins=(... extract) | `bz2` | Bzip2 file | | `deb` | Debian package | | `gz` | Gzip file | +| `ipa` | iOS app package | | `ipsw` | iOS firmware file | | `jar` | Java Archive | | `lrz` | LRZ archive | diff --git a/plugins/extract/_extract b/plugins/extract/_extract index 1a263a744..f96f0d450 100644 --- a/plugins/extract/_extract +++ b/plugins/extract/_extract @@ -3,5 +3,5 @@ _arguments \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \ - "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \ + "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \ && return 0 diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index a5594b81a..46e69f08d 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -55,7 +55,7 @@ extract() { (*.lz4) lz4 -d "$1" ;; (*.lzma) unlzma "$1" ;; (*.z) uncompress "$1" ;; - (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;; + (*.zip|*.war|*.jar|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;; (*.rar) unrar x -ad "$1" ;; (*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;; (*.7z) 7za x "$1" ;; -- cgit v1.2.3-70-g09d2 From a3740c34148a7a44d82683d2aa31c98f32b21a96 Mon Sep 17 00:00:00 2001 From: Samuel Terra Date: Sat, 18 Jul 2020 13:45:59 -0300 Subject: battery: add acpi requirement to README (#9116) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/battery/README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/battery/README.md b/plugins/battery/README.md index b7a13a7ec..c2554a36d 100644 --- a/plugins/battery/README.md +++ b/plugins/battery/README.md @@ -9,5 +9,14 @@ To use, add `battery` to the list of plugins in your `.zshrc` file: Then, add the `battery_pct_prompt` function to your custom theme. For example: ``` -RPROMPT='$(battery_pct_prompt)' +RPROMPT='$(battery_pct_prompt) ...' +``` + +## Requirements + +On Linux, you must have the `acpi` tool installed on your operating system. + +Here's an example of how to install with apt: +``` +sudo apt-get install acpi ``` -- cgit v1.2.3-70-g09d2 From db3d05fe7184a523fe4aba120bea962114424573 Mon Sep 17 00:00:00 2001 From: Amir Tahvildaran Date: Sat, 18 Jul 2020 13:06:08 -0400 Subject: aws: improve check for aws_completer - unhardcode path (#9123) Closes #9122 The current check is assuming that the aws_completer is installed globally, it then runs the command without that path I have aws_completer in ~/.local/bin/aws_completer This changes the check to see if the command exists instead of concerning itself with where it in installed. This test matches the behavior of just running the command. --- plugins/aws/aws.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index d00c2e56c..7994963c3 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -63,7 +63,7 @@ fi # Load awscli completions # AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back -if [[ -x /usr/local/bin/aws_completer ]]; then +if command -v aws_completer &> /dev/null; then autoload -Uz bashcompinit && bashcompinit complete -C aws_completer aws else -- cgit v1.2.3-70-g09d2 From 95218372402afc9aeafc89c0984310387ce79599 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 23 Jul 2020 12:55:22 +0200 Subject: lib: support mlterm-256color Co-authored-by: Peter J. Schroeder --- lib/termsupport.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 069b7f328..682925211 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -17,7 +17,7 @@ function title { : ${2=$1} case "$TERM" in - cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm) + cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*) print -Pn "\e]2;$2:q\a" # set window name print -Pn "\e]1;$1:q\a" # set tab name ;; -- cgit v1.2.3-70-g09d2