Skip to content

Commit

Permalink
Merge branch 'ohmyzsh:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mahinthjoe authored May 28, 2024
2 parents e658976 + 5e59d21 commit 46efd74
Show file tree
Hide file tree
Showing 14 changed files with 207 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies:
plugins/wd:
repo: mfaerevaag/wd
branch: master
version: tag:v0.6.1
version: tag:v0.7.0
precopy: |
set -e
rm -r test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Update dependencies
on:
workflow_dispatch: {}
schedule:
- cron: "34 3 * * */8"
- cron: "0 6 * * 0"

jobs:
check:
Expand Down
72 changes: 41 additions & 31 deletions .github/workflows/dependencies/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,21 +228,22 @@ def update_or_notify(self):
self.__apply_upstream_changes()

# Add all changes and commit
Git.add_and_commit(self.name, short_sha)
has_new_commit = Git.add_and_commit(self.name, short_sha)

# Push changes to remote
Git.push(branch)
if has_new_commit:
# Push changes to remote
Git.push(branch)

# Create GitHub PR
GitHub.create_pr(
branch,
f"feat({self.name}): update to version {new_version}",
f"""## Description
# Create GitHub PR
GitHub.create_pr(
branch,
f"feat({self.name}): update to version {new_version}",
f"""## Description
Update for **{self.desc}**: update to version [{new_version}]({status['head_url']}).
Check out the [list of changes]({status['compare_url']}).
""",
)
)

# Clean up repository
Git.clean_repo()
Expand Down Expand Up @@ -377,7 +378,21 @@ def checkout_or_create_branch(branch_name: str):
return branch_name

@staticmethod
def add_and_commit(scope: str, version: str):
def add_and_commit(scope: str, version: str) -> bool:
"""
Returns `True` if there were changes and were indeed commited.
Returns `False` if the repo was clean and no changes were commited.
"""
# check if repo is clean (clean => no error, no commit)
try:
CommandRunner.run_or_fail(
["git", "diff", "--exit-code"], stage="CheckRepoClean"
)
return False
except CommandRunner.Exception:
# if it's other kind of error just throw!
pass

user_name = os.environ.get("GIT_APP_NAME")
user_email = os.environ.get("GIT_APP_EMAIL")

Expand All @@ -390,27 +405,22 @@ def add_and_commit(scope: str, version: str):
clean_env["GIT_CONFIG_GLOBAL"] = "/dev/null"
clean_env["GIT_CONFIG_NOSYSTEM"] = "1"

# check if repo is clean (clean => no error, no commit)
try:
CommandRunner.run_or_fail(
["git", "diff", "--exit-code"], stage="CheckRepoClean", env=clean_env
)
except CommandRunner.Exception:
# Commit with settings above
CommandRunner.run_or_fail(
[
"git",
"-c",
f"user.name={user_name}",
"-c",
f"user.email={user_email}",
"commit",
"-m",
f"feat({scope}): update to {version}",
],
stage="CreateCommit",
env=clean_env,
)
# Commit with settings above
CommandRunner.run_or_fail(
[
"git",
"-c",
f"user.name={user_name}",
"-c",
f"user.email={user_email}",
"commit",
"-m",
f"feat({scope}): update to {version}",
],
stage="CreateCommit",
env=clean_env,
)
return True

@staticmethod
def push(branch: str):
Expand Down
2 changes: 1 addition & 1 deletion plugins/git/git.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function git_develop_branch() {
function git_main_branch() {
command git rev-parse --git-dir &>/dev/null || return
local ref
for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default,master}; do
for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default,stable,master}; do
if command git show-ref -q --verify $ref; then
echo ${ref:t}
return 0
Expand Down
4 changes: 4 additions & 0 deletions plugins/laravel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ plugins=(... laravel)
| `pamj` | `php artisan make:job` |
| `paml` | `php artisan make:listener` |
| `pamn` | `php artisan make:notification` |
| `pamcl` | `php artisan make:class` |
| `pamen` | `php artisan make:enum` |
| `pami` | `php artisan make:interface` |
| `pamtr` | `php artisan make:trait` |

## Clears

Expand Down
4 changes: 4 additions & 0 deletions plugins/laravel/laravel.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ alias pamj='php artisan make:job'
alias paml='php artisan make:listener'
alias pamn='php artisan make:notification'
alias pampp='php artisan make:provider'
alias pamcl='php artisan make:class'
alias pamen='php artisan make:enum'
alias pami='php artisan make:interface'
alias pamtr='php artisan make:trait'


# Clears
Expand Down
10 changes: 8 additions & 2 deletions plugins/macos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ To start using it, add the `macos` plugin to your plugins array in `~/.zshrc`:
plugins=(... macos)
```

Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
## Supported Terminals
- [iTerm](https://iterm.sourceforge.net/)
- [iTerm2](https://iterm2.com/)
- [Hyper](https://hyper.is/)
- [Tabby](https://tabby.sh/)

## Commands

Expand Down Expand Up @@ -37,7 +41,9 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)

## Acknowledgements

This application makes use of the following third party scripts:
Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)

This application makes use of the following third-party scripts:

[shpotify](https://github.com/hnarayanan/shpotify)

Expand Down
19 changes: 19 additions & 0 deletions plugins/macos/macos.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ EOF
key code 36 #(presses enter)
end tell
EOF

elif [[ "$the_app" == 'Tabby' ]]; then
osascript >/dev/null <<EOF
tell application "System Events"
tell process "Tabby" to keystroke "t" using command down
end tell
EOF
else
echo "$0: unsupported terminal app: $the_app" >&2
return 1
Expand Down Expand Up @@ -126,6 +133,12 @@ EOF
delay 1
keystroke "${command} \n"
end tell
EOF
elif [[ "$the_app" == 'Tabby' ]]; then
osascript >/dev/null <<EOF
tell application "System Events"
tell process "Tabby" to keystroke "D" using command down
end tell
EOF
else
echo "$0: unsupported terminal app: $the_app" >&2
Expand Down Expand Up @@ -175,6 +188,12 @@ EOF
delay 1
keystroke "${command} \n"
end tell
EOF
elif [[ "$the_app" == 'Tabby' ]]; then
osascript >/dev/null <<EOF
tell application "System Events"
tell process "Tabby" to keystroke "d" using command down
end tell
EOF
else
echo "$0: unsupported terminal app: $the_app" >&2
Expand Down
15 changes: 15 additions & 0 deletions plugins/tldr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# tldr plugin

This plugin adds a shortcut to insert tldr before the previous command.
Heavily inspired from [Man plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/man).

To use it, add `tldr` to the plugins array in your zshrc file:

```zsh
plugins=(... tldr)
```

# Keyboard Shortcuts
| Shortcut | Description |
|------------------------------------|----------------------------------------------------------------------------|
| <kbd>Esc</kbd> + tldr | add tldr before the previous command to see the tldr page for this command |
19 changes: 19 additions & 0 deletions plugins/tldr/tldr.plugin.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
tldr-command-line() {
# if there is no command typed, use the last command
[[ -z "$BUFFER" ]] && zle up-history

# if typed command begins with tldr, do nothing
[[ "$BUFFER" = tldr\ * ]] && return

# get command and possible subcommand
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
local -a args
args=(${${(Az)BUFFER}[1]} ${${(Az)BUFFER}[2]})

BUFFER="tldr ${args[1]}"
}

zle -N tldr-command-line
# Defined shortcut keys: [Esc]tldr
bindkey "\e"tldr tldr-command-line

15 changes: 14 additions & 1 deletion plugins/wd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ rm -f ~/.zcompdump; compinit
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`:
```zsh
bindkey '^G' wd_browse
bindkey ${FZF_WD_BINDKEY:-'^B'} fuzzy_wd_widget
```
## Usage
Expand All @@ -158,6 +158,19 @@ If a warp point with the same name exists, use `wd add foo --force` to overwrite
**Note:** a warp point cannot contain colons, or consist of only spaces and dots.
The first will conflict in how `wd` stores the warp points, and the second will conflict with other features, as below.
* Add warp point to any directory with default name:
```zsh
wd addcd /foo/ bar
```
* Add warp point to any directory with a custom name:
```zsh
wd addcd /foo/
```
You can omit point name to automatically use the current directory's name instead.
* From any directory, warp to `foo` with:
Expand Down
4 changes: 4 additions & 0 deletions plugins/wd/_wd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function _wd() {

commands=(
'add:Adds the current working directory to your warp points'
'addcd:Adds a directory to your warp points'
'add!:Overwrites existing warp point'
'export:Export warp points as static named directories'
'rm:Removes the given warp point'
Expand Down Expand Up @@ -63,6 +64,9 @@ function _wd() {
add)
_message 'Write the name of your warp point' && ret=0
;;
addcd)
_message 'Write the name of your path' && ret=0
;;
show)
_describe -t points "Warp points" warp_points && ret=0
;;
Expand Down
9 changes: 5 additions & 4 deletions plugins/wd/wd.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

eval "wd() { source '${0:A:h}/wd.sh' }"
wd > /dev/null
# Register the function as a Zsh widget
zle -N wd_browse
# Bind the widget to a key combination
bindkey '^G' wd_browse
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
Loading

0 comments on commit 46efd74

Please sign in to comment.