Skip to content

Commit

Permalink
add support for powershell
Browse files Browse the repository at this point in the history
  • Loading branch information
lasantosr committed May 15, 2023
1 parent 119ad43 commit 3d5b7cd
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 35 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,27 @@ jobs:
args: --release --target ${{ matrix.target }}

- name: Package
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
Compress-Archive -Path .\target\${{ matrix.target }}\release\intelli-shell.exe -DestinationPath intelli-shell-${{ matrix.target }}.zip
- name: Release
if: matrix.os == 'windows-latest'
uses: softprops/action-gh-release@v1
with:
files: intelli-shell-${{ matrix.target }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Package
if: matrix.os != 'windows-latest'
shell: bash
run: |
tar czvf intelli-shell-${{ matrix.target }}.tar.gz intelli-shell.sh intelli-shell.fish -C target/${{ matrix.target }}/release intelli-shell
- name: Release
if: matrix.os != 'windows-latest'
uses: softprops/action-gh-release@v1
with:
files: intelli-shell-${{ matrix.target }}.tar.gz
Expand Down
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
"line_length": 120,
"heading_line_length": 120,
"code_block_line_length": 120
},
"MD033": {
"allowed_elements": [
"details",
"summary"
]
}
}
}
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "intelli-shell"
description = "Like IntelliSense, but for shells"
version = "0.2.2"
version = "0.2.3"
edition = "2021"
license = "Apache-2.0"
readme = "README.md"
Expand Down
77 changes: 53 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,47 +37,68 @@ It currently works on Bash, Zsh and Fish and should be compatible with most Linu

Remember to bookmark some commands or fetch them after the installation!

### Prebuilt

To install using prebuilt binaries:
### Bash (Linux)

```sh
curl -sSf https://raw.githubusercontent.com/lasantosr/intelli-shell/main/install.sh | bash
```

### From source code
After installing it using bash, it should work in any supported shell.

If your platform is not supported, you can also install using _cargo_, which is recommended to be installed using [rustup](https://www.rust-lang.org/tools/install).
### PowerShell (Windows)

```sh
cargo install intelli-shell --locked
```powershell
New-Item -Path $env:APPDATA\IntelliShell\Intelli-Shell\bin -Type Directory
Invoke-WebRequest -UseBasicParsing -URI "https://github.com/lasantosr/intelli-shell/releases/latest/download/intelli-shell-x86_64-pc-windows-msvc.zip" -OutFile .\intelli-shell.zip
Expand-Archive -Path intelli-shell.zip -DestinationPath $env:APPDATA\IntelliShell\Intelli-Shell\bin
Remove-Item intelli-shell.zip
$Path = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($Path -NotLike "*IntelliShell*") {
$Path = $Path + [IO.Path]::PathSeparator + "$env:APPDATA\IntelliShell\Intelli-Shell\bin"
[Environment]::SetEnvironmentVariable( "Path", $Path, "User" )
}
```

You'll need to download the source script also:
After installing it using PowerShell, it should also work in cmd.

```sh
mkdir -p ~/.local/share/intelli-shell
curl -sSf https://raw.githubusercontent.com/lasantosr/intelli-shell/main/intelli-shell.sh > ~/.local/share/intelli-shell/intelli-shell.sh
```
### Source

Or, if using fish:
To install from source you'll need to have Rust installed, which is recommended to be installed using [rustup](https://www.rust-lang.org/tools/install).

```sh
mkdir -p ~/.local/share/intelli-shell
curl -sSf https://raw.githubusercontent.com/lasantosr/intelli-shell/main/intelli-shell.fish > ~/.local/share/intelli-shell/intelli-shell.fish
cargo install intelli-shell --locked
```

After that, you should edit your `~/.bashrc`, `~/.zshrc` or `~/.bash_profile` to source it:
<details>
<summary>Linux considerations</summary>

To include hotkey integrations with current line, you'll need to download the source script also:

```sh
source ~/.local/share/intelli-shell/intelli-shell.sh
```
```sh
mkdir -p ~/.local/share/intelli-shell
curl -sSf https://raw.githubusercontent.com/lasantosr/intelli-shell/main/intelli-shell.sh > ~/.local/share/intelli-shell/intelli-shell.sh
```

Or, if using fish you should edit `~/.config/fish/config.fish`:
Or, if using fish:

```sh
source ~/.local/share/intelli-shell/intelli-shell.fish
```
```sh
mkdir -p ~/.local/share/intelli-shell
curl -sSf https://raw.githubusercontent.com/lasantosr/intelli-shell/main/intelli-shell.fish > ~/.local/share/intelli-shell/intelli-shell.fish
```

After that, you should edit your `~/.bashrc`, `~/.zshrc` or `~/.bash_profile` to source it:

```sh
source ~/.local/share/intelli-shell/intelli-shell.sh
```

Or, if using fish you should edit `~/.config/fish/config.fish`:

```sh
source ~/.local/share/intelli-shell/intelli-shell.fish
```

</details>

## Usage

Expand All @@ -88,8 +109,15 @@ You can view supported actions by running `intelli-shell -h`. Most used standalo
- `intelli-shell export` to export user-bookmarked commands (won't export _tldr's_ commands)
- `intelli-shell import user_commands.txt` to import commands into the user category

Windows users, as hotkeys are not enabled, will also need those:

- `intelli-shell search` to search for stored commands
- `intelli-shell save "my command"` to save a new command

### Hotkeys

Hotkeys are only available on Linux:

- `ctrl + b` bookmark currently typed command
- `ctrl + space` show suggestions for current line
- `ctrl + l` replace labels of currently typed command
Expand All @@ -103,8 +131,9 @@ You can customize key bindings using environment variables: `INTELLI_SAVE_HOTKEY

- [x] Labels support to store most used labels and select them using a dedicated UI
- [ ] Usability improvements to manage stored commands (including aliases)
- [ ] Support for more terminals
- [x] Support for more terminals
- [x] [Fish](https://fishshell.com/)
- [x] PowerShell
- [ ] Export also labels and UI to filter what to export
- [ ] Deploy to package managers
- [ ] Sync user bookmarks using some public / private Git repo
Expand Down
9 changes: 0 additions & 9 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@

set -eo pipefail

# Retrieve default shell
shell="${SHELL##*/}"

if [[ "$shell" != 'bash' ]] && [[ "$shell" != 'bash.exe' ]] && [[ "$shell" != 'zsh' ]];
then
echo "Terminal $shell is not compatible";
exit 1;
fi

# Find target
arch=$(uname -m)
case "$OSTYPE" in
Expand Down

0 comments on commit 3d5b7cd

Please sign in to comment.