Skip to content

Commit

Permalink
added xonsh and oil
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Sep 19, 2020
1 parent 0021568 commit 7051720
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 11 deletions.
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ RUN wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod
RUN apt-get install -y fish \
elvish \
powershell \
python3-pip \
zsh

ENV GOPATH /go
Expand Down Expand Up @@ -54,6 +55,22 @@ carapace --list | each [c]{\n\
}" \
> /root/.elvish/rc.elv

# oil
RUN curl https://www.oilshell.org/download/oil-0.8.0.tar.gz | tar -xvz \
&& cd oil-*/ \
&& ./configure \
&& make \
&& ./install

RUN mkdir -p ~/.config/oil \
&& echo "\n\
PS1=$'\e[0;36mcarapace \e[0m'\n\
source <(carapace _carapace)\n\
for c in \$(carapace --list); do\n\
source <(carapace \$c)\n\
done" \
> ~/.config/oil/oshrc

# powershell
RUN mkdir -p /root/.config/powershell \
&& echo "\n\
Expand All @@ -63,6 +80,18 @@ carapace _carapace powershell | out-string | Invoke-Expression\n\
carapace --list | foreach { carapace \$_ | Out-String | Invoke-Expression} " \
> /root/.config/powershell/Microsoft.PowerShell_profile.ps1

# xonsh
RUN pip3 install --no-cache-dir --disable-pip-version-check xonsh \
&& ln -s $(which xonsh) /usr/bin/xonsh

RUN mkdir -p ~/.config/xonsh \
&& echo "\n\
\$COMPLETIONS_CONFIRM=True\n\
exec(\$(carapace _carapace xonsh)) \n\
for \$c in \$(carapace --list).split('\\\n'):\n\
exec(\$(carapace \$c))"\
> ~/.config/xonsh/rc.xsh

# zsh
RUN echo "\n\
PS1=$'%{\e[0;36m%}carapace %{\e[0m%}'\n\
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Supported shells:
- [Bash](https://www.gnu.org/software/bash/)
- [Elvish](https://elv.sh/)
- [Fish](https://fishshell.com/)
- [Oil](http://www.oilshell.org/) *broken* ([carapace#86](https://github.com/rsteube/carapace/issues/86))
- [Powershell](https://microsoft.com/powershell)
- [Xonsh](https://xon.sh/) *experimental*
- [Zsh](https://www.zsh.org/)

## Status
Expand All @@ -26,7 +28,7 @@ Notable shortcomings:

```
docker-compose run --rm build
docker-compose run --rm [bash|elvish|fish|powershell|zsh]
docker-compose run --rm [bash|elvish|fish|oil|powershell|xonsh|zsh]
[ln|mkdir|chown...] <TAB>
```

Expand All @@ -40,7 +42,7 @@ For smallest file size (300kb instead of 6mb) use gccgo with flags "-s -w" and u
Completers can also be built separately:
```sh
cd completers/ln_completer && go build -ldflags="-s -w"
./ln_completer _carapace [bash|elvish|fish|powershell|zsh]
./ln_completer _carapace [bash|elvish|fish|oil|powershell|xonsh|zsh]
```

## Generate completion
Expand All @@ -49,11 +51,11 @@ Ensure carapace is added to PATH.

- completion for carapace itself
```sh
carapace _carapace [bash|elvish|fish|powershell|zsh]
carapace _carapace [bash|elvish|fish|oil|powershell|xonsh|zsh]
```
- completion for commands
```sh
carapace [ln|mkdir|...] [bash|elvish|fish|powershell|zsh]
carapace [ln|mkdir|...] [bash|elvish|fish|oil|powershell|xonsh|zsh]
```
- list completions
```sh
Expand Down Expand Up @@ -92,7 +94,7 @@ cd carapace/cmd && ./generate.sh > completers.go
- build & test
```sh
docker-compose run --rm build
docker-compose run --rm [bash|elvish|fish|powershell|zsh]
docker-compose run --rm [bash|elvish|fish|oil|powershell|xonsh|zsh]
```

[![asciicast](https://asciinema.org/a/357895.svg)](https://asciinema.org/a/357895)
4 changes: 3 additions & 1 deletion carapace/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ var rootCmd = &cobra.Command{
w.Close()
out := <-outC
os.Stdout = old
fmt.Print(strings.Replace(string(out), "carapace _carapace", "carapace "+completer, -1))
patched := strings.Replace(string(out), "carapace _carapace", "carapace "+completer, -1) // general callback
patched = strings.Replace(patched, "'carapace', '_carapace'", "'carapace', '"+completer+"'", -1) // xonsh callback
fmt.Print(patched)
}
},
FParseErrWhitelist: cobra.FParseErrWhitelist{
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,24 @@ services:
command: fish
volumes:
- '.:/carapace-bin/'

oil:
build: .
command: osh
volumes:
- '.:/carapace-bin/'

powershell:
build: .
command: pwsh
volumes:
- '.:/carapace-bin/'

xonsh:
build: .
command: xonsh
volumes:
- '.:/carapace-bin/'

zsh:
build: .
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.12
require (
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/go-ps v1.0.0
github.com/rsteube/carapace v0.0.20
github.com/rsteube/carapace v0.0.23
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/spf13/cobra v1.0.0
gopkg.in/ini.v1 v1.60.2
Expand Down
28 changes: 24 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,30 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rsteube/carapace v0.0.18 h1:P+yvRgd42qSetJwDcwie8kbj2+6q/8ggJ/qbglyAcWQ=
github.com/rsteube/carapace v0.0.18/go.mod h1:MW6dtBU0/zTdivRaQzlCHyceSHKzZP0xHqjXmgeSN5Y=
github.com/rsteube/carapace v0.0.20 h1:j7d7GOdmVOq6G0C1r7SyEMoi5676LN82bvlPKjuKVls=
github.com/rsteube/carapace v0.0.20/go.mod h1:MW6dtBU0/zTdivRaQzlCHyceSHKzZP0xHqjXmgeSN5Y=
github.com/rsteube/carapace v0.0.23-0.20200919192629-da616d59ab3e h1:yvKWbN/S3PJBVLe75hJUNsfGKwVA2xZWphKbXDFuXUE=
github.com/rsteube/carapace v0.0.23-0.20200919192629-da616d59ab3e/go.mod h1:MW6dtBU0/zTdivRaQzlCHyceSHKzZP0xHqjXmgeSN5Y=
github.com/rsteube/carapace v0.0.23-0.20200919194745-f1db8222df1f h1:biRRIbYk/8VFmAfZTOjTSilEx6cy4jbBGUVpzpIdy30=
github.com/rsteube/carapace v0.0.23-0.20200919194745-f1db8222df1f/go.mod h1:MW6dtBU0/zTdivRaQzlCHyceSHKzZP0xHqjXmgeSN5Y=
github.com/rsteube/carapace v0.0.23-0.20200919204756-9b01aeb1d51d h1:+6kiJGXs3AwPIr1PS1ky19NR/hT4AimHzkxca8XKrhE=
github.com/rsteube/carapace v0.0.23-0.20200919204756-9b01aeb1d51d/go.mod h1:MW6dtBU0/zTdivRaQzlCHyceSHKzZP0xHqjXmgeSN5Y=
github.com/rsteube/carapace v0.0.23-0.20200919205347-fb81878b7190 h1:r81T8FiihjnCkDDUq7mbQzJ5Z+fBxl3XXOGw0vxx79k=
github.com/rsteube/carapace v0.0.23-0.20200919205347-fb81878b7190/go.mod h1:MW6dtBU0/zTdivRaQzlCHyceSHKzZP0xHqjXmgeSN5Y=
github.com/rsteube/carapace v0.0.23-0.20200919205525-1e9ac3cd6800 h1:n4O7YrBv0/ulVl5/Pqo1cpurNOmg+GY3/U4P01/VEsg=
github.com/rsteube/carapace v0.0.23-0.20200919205525-1e9ac3cd6800/go.mod h1:MW6dtBU0/zTdivRaQzlCHyceSHKzZP0xHqjXmgeSN5Y=
github.com/rsteube/carapace v0.0.23-0.20200919210107-5ab7cfc52dd4 h1:QlqaE9sXWeY8/0C/nqf8e5lE2ceOxMl6hRqYzGbCiNU=
github.com/rsteube/carapace v0.0.23-0.20200919210107-5ab7cfc52dd4/go.mod h1:MW6dtBU0/zTdivRaQzlCHyceSHKzZP0xHqjXmgeSN5Y=
github.com/rsteube/carapace v0.0.23-0.20200919210929-9e0deb50a55b h1:8RrFJ/qxuN8SpCnHlBU2moQr0I0wenN57j2ybbFWMqc=
github.com/rsteube/carapace v0.0.23-0.20200919210929-9e0deb50a55b/go.mod h1:MW6dtBU0/zTdivRaQzlCHyceSHKzZP0xHqjXmgeSN5Y=
github.com/rsteube/carapace v0.0.23-0.20200919214710-abb00effddbf h1:wjaDiT3UBUqiZ58uqr6jicdWOkzCnIyRBjuOatlwD0I=
github.com/rsteube/carapace v0.0.23-0.20200919214710-abb00effddbf/go.mod h1:MW6dtBU0/zTdivRaQzlCHyceSHKzZP0xHqjXmgeSN5Y=
github.com/rsteube/carapace v0.0.23-0.20200919220847-c24a2ebbc308 h1:ooJo9CguoOQ+2FBY/RhSsiH7J2NvNPpFvhrr0ZnxCzA=
github.com/rsteube/carapace v0.0.23-0.20200919220847-c24a2ebbc308/go.mod h1:MW6dtBU0/zTdivRaQzlCHyceSHKzZP0xHqjXmgeSN5Y=
github.com/rsteube/carapace v0.0.23-0.20200919222008-44141a6727be h1:aGcKMiNGNGQaVlZ8u67+PR3kukVjJ3REtRC4N7u2mWM=
github.com/rsteube/carapace v0.0.23-0.20200919222008-44141a6727be/go.mod h1:MW6dtBU0/zTdivRaQzlCHyceSHKzZP0xHqjXmgeSN5Y=
github.com/rsteube/carapace v0.0.23-0.20200919223558-28d50da55e24 h1:5BFZYRJhun9oo4N9Xf5zxv47PJbkBUVGWoJAVZtU518=
github.com/rsteube/carapace v0.0.23-0.20200919223558-28d50da55e24/go.mod h1:MW6dtBU0/zTdivRaQzlCHyceSHKzZP0xHqjXmgeSN5Y=
github.com/rsteube/carapace v0.0.23 h1:2j+lphtg6ob5V4yEWYisDOalpaYyBT4htnZwawhuAS4=
github.com/rsteube/carapace v0.0.23/go.mod h1:MW6dtBU0/zTdivRaQzlCHyceSHKzZP0xHqjXmgeSN5Y=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
Expand Down

0 comments on commit 7051720

Please sign in to comment.