mirror of
https://github.com/wavetermdev/inshellisense.git
synced 2026-08-05 13:43:30 -07:00
refactor: rename project
Signed-off-by: Chapman Pendery <cpendery@vt.edu>
This commit is contained in:
@@ -1,25 +1,27 @@
|
||||
# sa
|
||||
# inshellisense
|
||||
|
||||
`sa` provides IDE style autocomplete, `inshellisense`, for shells. It's a terminal native runtime of for [autocomplete](https://github.com/withfig/autocomplete) which has support for 600+ command line tools. `sa` supports Windows, Linux, & MacOS.
|
||||
`inshellisense` provides IDE style autocomplete for shells. It's a terminal native runtime of for [autocomplete](https://github.com/withfig/autocomplete) which has support for 600+ command line tools. `inshellisense` supports Windows, Linux, & MacOS.
|
||||
|
||||
<p align="center"><img alt="demo of sa working" src="/docs/demo.gif" height="450px"/></p>
|
||||
<p align="center"><img alt="demo of inshellisense working" src="/docs/demo.gif" height="450px"/></p>
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Installation
|
||||
|
||||
```shell
|
||||
npm install -g @microsoft/sa
|
||||
npm install -g @microsoft/inshellisense
|
||||
```
|
||||
|
||||
### Quickstart
|
||||
|
||||
After completing the installation, you can already run `sa --shell <shell>` to start the autocomplete session for your desired shell. Additionally, you can bind `sa` to a keybinding of `CTRL+a` by running the below command. This brings the added advantages of automatically starting the autocomplete session with your current shell and injecting any accepted command into your shell's history.
|
||||
After completing the installation, you can already run `inshellisense --shell <shell>` to start the autocomplete session for your desired shell. Additionally, you can bind `inshellisense` to a keybinding of `CTRL+a` by running the below command. This brings the added advantages of automatically starting the autocomplete session with your current shell and injecting any accepted command into your shell's history.
|
||||
|
||||
```shell
|
||||
sa bind
|
||||
inshellisense bind
|
||||
```
|
||||
|
||||
Additionally, inshellisense is also aliased under `is` after install for convenience.
|
||||
|
||||
## Contributing
|
||||
|
||||
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
||||
|
||||
Generated
+4
-3
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "@microsoft/sa",
|
||||
"name": "@microsoft/inshellisense",
|
||||
"version": "0.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@microsoft/sa",
|
||||
"name": "@microsoft/inshellisense",
|
||||
"version": "0.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -17,7 +17,8 @@
|
||||
"wrap-ansi": "^8.1.0"
|
||||
},
|
||||
"bin": {
|
||||
"sa": "build/index.js"
|
||||
"inshellisense": "build/index.js",
|
||||
"is": "build/index.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsconfig/node18": "^18.2.2",
|
||||
|
||||
+7
-6
@@ -1,10 +1,11 @@
|
||||
{
|
||||
"name": "@microsoft/sa",
|
||||
"name": "@microsoft/inshellisense",
|
||||
"version": "0.0.0",
|
||||
"description": "IDE style command line auto complete",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"sa": "./build/index.js"
|
||||
"inshellisense": "./build/index.js",
|
||||
"is": "./build/index.js"
|
||||
},
|
||||
"files": [
|
||||
"build/**",
|
||||
@@ -21,16 +22,16 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/microsoft/sa.git"
|
||||
"url": "git+https://github.com/microsoft/inshellisense.git"
|
||||
},
|
||||
"author": {
|
||||
"name": "Microsoft Corporation"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/microsoft/sa/issues"
|
||||
"url": "https://github.com/microsoft/inshellisense/issues"
|
||||
},
|
||||
"homepage": "https://github.com/microsoft/sa#readme",
|
||||
"homepage": "https://github.com/microsoft/inshellisense#readme",
|
||||
"dependencies": {
|
||||
"@withfig/autocomplete": "^2.633.0",
|
||||
"chalk": "^5.3.0",
|
||||
@@ -55,4 +56,4 @@
|
||||
"ts-jest": "^29.1.1",
|
||||
"typescript": "^5.2.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,15 +12,15 @@ Set-PSReadLineKeyHandler -Chord 'Ctrl+a' -ScriptBlock {
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::KillLine()
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
|
||||
|
||||
$sa = "$env:USERPROFILE\AppData\Roaming\npm\node_modules\@microsoft\sa\build\index.js"
|
||||
$inshellisense = "$env:USERPROFILE\AppData\Roaming\npm\node_modules\@microsoft\inshellisense\build\index.js"
|
||||
if ($command) {
|
||||
Start-Process -NoNewWindow -Wait "node" "$sa -c $command -s powershell"
|
||||
Start-Process -NoNewWindow -Wait "node" "$inshellisense -c $command -s powershell"
|
||||
}
|
||||
else {
|
||||
Start-Process -NoNewWindow -Wait "node" "$sa -s powershell"
|
||||
Start-Process -NoNewWindow -Wait "node" "$inshellisense -s powershell"
|
||||
}
|
||||
|
||||
$executedCommand = node $sa --history
|
||||
$executedCommand = node $inshellisense --history
|
||||
if ($executedCommand) {
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::AddToHistory($executedCommand)
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@ Set-PSReadLineKeyHandler -Chord 'Ctrl+a' -ScriptBlock {
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::BeginningOfLine()
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::KillLine()
|
||||
|
||||
$sa = "$env:USERPROFILE\AppData\Roaming\npm\node_modules\@microsoft\sa\build\index.js"
|
||||
$inshellisense = "$env:USERPROFILE\AppData\Roaming\npm\node_modules\@microsoft\inshellisense\build\index.js"
|
||||
if ($command) {
|
||||
Start-Process -NoNewWindow -Wait "node" "$sa -c $command -s pwsh"
|
||||
Start-Process -NoNewWindow -Wait "node" "$inshellisense -c $command -s pwsh"
|
||||
}
|
||||
else {
|
||||
Start-Process -NoNewWindow -Wait "node" "$sa -s pwsh"
|
||||
Start-Process -NoNewWindow -Wait "node" "$inshellisense -s pwsh"
|
||||
}
|
||||
|
||||
$executedCommand = node $sa --history
|
||||
$executedCommand = node $inshellisense --history
|
||||
if ($executedCommand) {
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::AddToHistory($executedCommand)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
__sa__() {
|
||||
sa -c "$READLINE_LINE" -s bash
|
||||
history -s $(sa --history)
|
||||
__inshellisense__() {
|
||||
inshellisense -c "$READLINE_LINE" -s bash
|
||||
history -s $(inshellisense --history)
|
||||
READLINE_LINE=
|
||||
}
|
||||
|
||||
bind -x '"\C-a": __sa__'
|
||||
bind -x '"\C-a": __inshellisense__'
|
||||
+1
-1
@@ -13,7 +13,7 @@ import { action, supportedShells } from "./commands/root.js";
|
||||
const program = new Command();
|
||||
|
||||
program
|
||||
.name("sa")
|
||||
.name("inshellisense")
|
||||
.description("IDE style command line auto complete")
|
||||
.version("0.0.0", "-v, --version", "output the current version")
|
||||
.option("-s, --shell <shell>", `shell to use for command execution, supported shells: ${supportedShells}`)
|
||||
|
||||
+13
-12
@@ -10,6 +10,7 @@ import url from "node:url";
|
||||
|
||||
const __filename = url.fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const cacheFolder = ".inshellisense";
|
||||
|
||||
export enum Shell {
|
||||
Bash = "bash",
|
||||
@@ -20,16 +21,16 @@ export enum Shell {
|
||||
export const supportedShells = [Shell.Bash, Shell.Powershell, Shell.Pwsh];
|
||||
|
||||
const bashScriptCommand = (): string => {
|
||||
return `[ -f ~/.sa/key-bindings.bash ] && source ~/.sa/key-bindings.bash`;
|
||||
return `[ -f ~/${cacheFolder}/key-bindings.bash ] && source ~/${cacheFolder}/key-bindings.bash`;
|
||||
};
|
||||
|
||||
const powershellScriptCommand = (): string => {
|
||||
const bindingsPath = path.join(os.homedir(), ".sa", "key-bindings-powershell.ps1");
|
||||
const bindingsPath = path.join(os.homedir(), cacheFolder, "key-bindings-powershell.ps1");
|
||||
return `if(Test-Path '${bindingsPath}' -PathType Leaf){. ${bindingsPath}}`;
|
||||
};
|
||||
|
||||
const pwshScriptCommand = (): string => {
|
||||
const bindingsPath = path.join(os.homedir(), ".sa", "key-bindings-pwsh.ps1");
|
||||
const bindingsPath = path.join(os.homedir(), cacheFolder, "key-bindings-pwsh.ps1");
|
||||
return `if(Test-Path '${bindingsPath}' -PathType Leaf){. ${bindingsPath}}`;
|
||||
};
|
||||
|
||||
@@ -46,9 +47,9 @@ const pwshConfigPath = (): string => {
|
||||
};
|
||||
|
||||
export const availableBindings = async (): Promise<Shell[]> => {
|
||||
const saConfigPath = path.join(os.homedir(), ".sa");
|
||||
if (!fs.existsSync(saConfigPath)) {
|
||||
await fsAsync.mkdir(saConfigPath);
|
||||
const cliConfigPath = path.join(os.homedir(), cacheFolder);
|
||||
if (!fs.existsSync(cliConfigPath)) {
|
||||
await fsAsync.mkdir(cliConfigPath);
|
||||
}
|
||||
|
||||
const bindings = [];
|
||||
@@ -85,15 +86,15 @@ export const availableBindings = async (): Promise<Shell[]> => {
|
||||
};
|
||||
|
||||
export const bind = async (shell: Shell): Promise<void> => {
|
||||
const saConfigPath = path.join(os.homedir(), ".sa");
|
||||
if (!fs.existsSync(saConfigPath)) {
|
||||
await fsAsync.mkdir(saConfigPath);
|
||||
const cliConfigPath = path.join(os.homedir(), cacheFolder);
|
||||
if (!fs.existsSync(cliConfigPath)) {
|
||||
await fsAsync.mkdir(cliConfigPath);
|
||||
}
|
||||
switch (shell) {
|
||||
case Shell.Bash: {
|
||||
const bashConfigPath = path.join(os.homedir(), ".bashrc");
|
||||
await fsAsync.appendFile(bashConfigPath, `\n${bashScriptCommand()}`);
|
||||
await fsAsync.copyFile(path.join(__dirname, "..", "..", "shell", "key-bindings.bash"), path.join(os.homedir(), ".sa", "key-bindings.bash"));
|
||||
await fsAsync.copyFile(path.join(__dirname, "..", "..", "shell", "key-bindings.bash"), path.join(os.homedir(), cacheFolder, "key-bindings.bash"));
|
||||
break;
|
||||
}
|
||||
case Shell.Powershell: {
|
||||
@@ -101,13 +102,13 @@ export const bind = async (shell: Shell): Promise<void> => {
|
||||
await fsAsync.appendFile(powershellConfigPath, `\n${powershellScriptCommand()}`);
|
||||
await fsAsync.copyFile(
|
||||
path.join(__dirname, "..", "..", "shell", "key-bindings-powershell.ps1"),
|
||||
path.join(os.homedir(), ".sa", "key-bindings-powershell.ps1"),
|
||||
path.join(os.homedir(), cacheFolder, "key-bindings-powershell.ps1"),
|
||||
);
|
||||
break;
|
||||
}
|
||||
case Shell.Pwsh: {
|
||||
await fsAsync.appendFile(pwshConfigPath(), `\n${pwshScriptCommand()}`);
|
||||
await fsAsync.copyFile(path.join(__dirname, "..", "..", "shell", "key-bindings-pwsh.ps1"), path.join(os.homedir(), ".sa", "key-bindings-pwsh.ps1"));
|
||||
await fsAsync.copyFile(path.join(__dirname, "..", "..", "shell", "key-bindings-pwsh.ps1"), path.join(os.homedir(), cacheFolder, "key-bindings-pwsh.ps1"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -6,8 +6,9 @@ import path from "node:path";
|
||||
import fsAsync from "node:fs/promises";
|
||||
import fs from "node:fs";
|
||||
|
||||
const folderPath = path.join(os.homedir(), ".sa");
|
||||
const cachePath = path.join(os.homedir(), ".sa", "sa.cache");
|
||||
const cacheFolder = ".inshellisense";
|
||||
const folderPath = path.join(os.homedir(), cacheFolder);
|
||||
const cachePath = path.join(os.homedir(), cacheFolder, "inshellisense.cache");
|
||||
|
||||
export const saveCommand = async (command: string) => {
|
||||
if (!fs.existsSync(folderPath)) {
|
||||
|
||||
Reference in New Issue
Block a user