Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add zsh plugin #14

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,36 @@ curl -sS https://raw.githubusercontent.com/chvolkmann/code-connect/main/bash/uni

Deletes the aliases from `~/.bashrc` and removes the folder `~/.code-connect`

### Zsh

#### Installing

With [Oh My Zsh](https://github.com/ohmyzsh/ohmyzsh)

1. Clones the repository into `$ZSH_CUSTOM/plugins` (by default `~/.oh-my-zsh/custom/plugins`)

```zsh
git clone https://github.com/chvolkmann/code-connect $ZSH_CUSTOM/plugins/code-connect
```

2. Add `code-connect` to the plugins array in your `.zshrc` file

```zsh
plugins=(... code-connect)
```

#### Updating

```zsh
git -C $ZSH_CUSTOM/plugins/code-connect pull
```

#### Uninstalling

```zsh
rm -rf $ZSH_CUSTOM/plugins/code-connect
```

## Usage

Use `code` as you would normally!
Expand Down
7 changes: 7 additions & 0 deletions code-connect.plugin.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Add the binary directory to user's path
PLUGIN_DIR="$(dirname $0)"
export PATH="${PATH}:${PLUGIN_DIR}/bin"

# update fpath, and then lazy autoload files in the directory as functions
fpath=($PLUGIN_DIR/zsh_functions $fpath)
autoload -U code code-connect
9 changes: 9 additions & 0 deletions zsh_functions/code
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# The $commands arrays are described in the zsh/parameter module to access the internal hash tables.
# $+param expands to 0 if param is unset, and 1 if it's set.
if [[ ${+commands[code]} -eq 1 ]] ; then
# code is a command, use that binary instead of the code-connect
command code "$@"
else
# code not locally installed, use code-connect
code_connect.py "$@"
fi
1 change: 1 addition & 0 deletions zsh_functions/code-connect
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
code_connect.py "$@"