Skip to content

Commit 8c60489

Browse files
authored
feat: expand shell plugins to all shells except cmd (#230)
Signed-off-by: Chapman Pendery <cpendery@vt.edu>
1 parent 7557064 commit 8c60489

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,24 @@ If you'd like to automatically start inshellisense when you open your shell, run
2727
```shell
2828
# bash
2929
is init bash >> ~/.bashrc
30+
31+
# zsh
32+
is init zsh >> ~/.zshrc
33+
34+
# fish
35+
is init fish >> ~/.config/fish/config.fish
36+
37+
# pwsh
38+
is init pwsh >> $profile
39+
40+
# powershell
41+
is init powershell >> $profile
42+
43+
# xonsh
44+
is init xonsh >> ~/.xonshrc
45+
46+
# nushell
47+
is init nu >> $nu.env-path
3048
```
3149

3250
### Usage

src/utils/shell.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const supportedShells = [
3333
Shell.Nushell,
3434
].filter((shell) => shell != null) as Shell[];
3535

36-
export const initSupportedShells = [Shell.Bash];
36+
export const initSupportedShells = supportedShells.filter((shell) => shell != Shell.Cmd);
3737

3838
export const userZdotdir = process.env?.ZDOTDIR ?? os.homedir() ?? `~`;
3939
export const zdotdir = path.join(os.tmpdir(), `is-zsh`);
@@ -124,10 +124,31 @@ export const getShellPromptRewrites = (shell: Shell) => shell == Shell.Nushell;
124124

125125
export const getShellConfig = (shell: Shell): string => {
126126
switch (shell) {
127+
case Shell.Zsh:
127128
case Shell.Bash:
128129
return `if [[ -z "\${ISTERM}" && $- = *i* && $- != *c* ]]; then
129-
is -s bash ; exit
130+
is -s ${shell} ; exit
130131
fi`;
132+
case Shell.Powershell:
133+
case Shell.Pwsh:
134+
return `$__IsCommandFlag = ([Environment]::GetCommandLineArgs() | ForEach-Object { $_.contains("-Command") }) -contains $true
135+
$__IsNoExitFlag = ([Environment]::GetCommandLineArgs() | ForEach-Object { $_.contains("-NoExit") }) -contains $true
136+
$__IsInteractive = -not $__IsCommandFlag -or ($__IsCommandFlag -and $__IsNoExitFlag)
137+
if ([string]::IsNullOrEmpty($env:ISTERM) -and [Environment]::UserInteractive -and $__IsInteractive) {
138+
is -s ${shell}
139+
Stop-Process -Id $pid
140+
}`;
141+
case Shell.Fish:
142+
return `if test -z "$ISTERM" && status --is-interactive
143+
is -s fish ; kill %self
144+
end`;
145+
case Shell.Xonsh:
146+
return `if 'ISTERM' not in \${...} and $XONSH_INTERACTIVE:
147+
is -s xonsh ; exit`;
148+
case Shell.Nushell:
149+
return `if "ISTERM" not-in $env and $nu.is-interactive {
150+
is -s nu ; exit
151+
}`;
131152
}
132153
return "";
133154
};

0 commit comments

Comments
 (0)