Skip to content

Commit 7bfb814

Browse files
committed
Create a docker mod to add rbenv to code-server
This mod adds rbenv to code-server, to be installed/updated during container start. rbenv is a version manager tool for the Ruby programming language on Unix-like systems. It is useful for switching between multiple Ruby versions on the same machine and for ensuring that each project you are working on always runs on the correct Ruby version. This mod includes adding shell completions for rbenv in bash and zsh.
1 parent 8b5f478 commit 7bfb814

File tree

15 files changed

+53
-86
lines changed

15 files changed

+53
-86
lines changed

.github/workflows/BuildImage.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ on:
1010
required: false
1111

1212
env:
13-
GITHUB_REPO: "linuxserver/docker-mods" #don't modify
14-
ENDPOINT: "linuxserver/mods" #don't modify
13+
GITHUB_REPO: "somewatson/docker-mods" #don't modify -- modified
14+
ENDPOINT: "somewatson/mods" #don't modify -- modified
1515
BASEIMAGE: "code-server" #replaced
16-
MODNAME: "bat" #replaced
16+
MODNAME: "rbenv-sw" #replaced
1717
MOD_VERSION: ${{ inputs.mod_version }} #don't modify
1818
MULTI_ARCH: "false" #set to false if not needed
1919

README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
# Bat - Docker mod for code-server
1+
# Rbenv - Docker mod for code-server
22

3-
This mod adds [bat](https://github.com/sharkdp/bat) to code-server, to be installed/updated during container start.
3+
This mod adds [rbenv](https://github.com/rbenv/rbenv) to code-server, to be installed/updated during container start.
44

5-
Bat is a cat(1) clone with syntax highlighting and Git integration.
5+
rbenv is a version manager tool for the Ruby programming language on Unix-like systems. It is useful for switching between multiple Ruby versions on the same machine and for ensuring that each project you are working on always runs on the correct Ruby version.
66

7-
In code-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:code-server-bat`
7+
In code-server docker arguments, set an environment variable `DOCKER_MODS=somewatson/mods:code-server-rbenv-sw`
88

9-
If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:code-server-bat|linuxserver/mods:openssh-server-mod2`
9+
If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=somewatson/mods:code-server-rbenv-sw|linuxserver/mods:openssh-server-mod2`
1010

11-
### Bat-extras and Ripgrep
11+
### Shell completions
1212

13-
This mod also includes [bat-extras](https://github.com/eth-p/bat-extras) which has a dependency of [ripgrep](https://github.com/BurntSushi/ripgrep). Ripgrep has also been included because it is a requirment of bat-extras.
13+
This mod includes adding [shell completions](https://github.com/rbenv/rbenv?tab=readme-ov-file#shell-completions) for `rbenv` in `bash` and `zsh`.
1414

15-
### Aliases
15+
The zsh completion script ships with the project, but needs to be added to FPATH in zsh before it can be discovered by the shell. So, the mod will automatically detect and update the `~/.zshrc` file:
1616

17-
This mod includes aliases for `bat` in `bash` and `zsh`. Under Ubuntu `bat` gets installed as `batcat` to avoid a name collision. So, for convenience, an alias to set `bat="batcat"` is included for both `bash` and `zsh`.
17+
```
18+
FPATH=~/.rbenv/completions:"$FPATH"
19+
autoload -U compinit
20+
compinit
21+
```

root/etc/s6-overlay/s6-rc.d/init-mod-code-server-bat-install/run

Lines changed: 0 additions & 60 deletions
This file was deleted.

root/etc/s6-overlay/s6-rc.d/init-mod-code-server-bat-add-package/dependencies.d/init-mods renamed to root/etc/s6-overlay/s6-rc.d/init-mod-code-server-rbenv-add-package/dependencies.d/init-mods

File renamed without changes.

root/etc/s6-overlay/s6-rc.d/init-mod-code-server-bat-add-package/run renamed to root/etc/s6-overlay/s6-rc.d/init-mod-code-server-rbenv-add-package/run

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,6 @@
55
# If using this, we need to make sure we set this init as a dependency of init-mods-package-install so this one runs first
66
#!/usr/bin/with-contenv bash
77

8-
if ! dpkg -s ripgrep >/dev/null 2>&1; then
9-
echo "**** Adding ripgrep to package install list ****"
10-
echo "ripgrep" >> /mod-repo-packages-to-install.list
11-
else
12-
echo "**** ripgrep already installed, skipping ****"
13-
fi
14-
15-
if ! dpkg -s bat >/dev/null 2>&1; then
16-
echo "**** Adding bat to package install list ****"
17-
echo "bat" >> /mod-repo-packages-to-install.list
18-
else
19-
echo "**** bat already installed, skipping ****"
20-
fi
21-
228
if ! dpkg -s git >/dev/null 2>&1; then
239
echo "**** Adding git to package install list ****"
2410
echo "git" >> /mod-repo-packages-to-install.list

root/etc/s6-overlay/s6-rc.d/init-mod-code-server-bat-add-package/type renamed to root/etc/s6-overlay/s6-rc.d/init-mod-code-server-rbenv-add-package/type

File renamed without changes.

root/etc/s6-overlay/s6-rc.d/init-mod-code-server-bat-add-package/up renamed to root/etc/s6-overlay/s6-rc.d/init-mod-code-server-rbenv-add-package/up

File renamed without changes.

root/etc/s6-overlay/s6-rc.d/init-mod-code-server-bat-install/dependencies.d/init-mods-package-install renamed to root/etc/s6-overlay/s6-rc.d/init-mod-code-server-rbenv-install/dependencies.d/init-mods-package-install

File renamed without changes.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
# This is an install script that is designed to run after init-mods-package-install
4+
# so it can take advantage of packages installed
5+
# init-mods-end depends on this script so that later init and services wait until this script exits
6+
7+
if [ -d ~/.rbenv ]; then
8+
echo 'rbenv already cloned, skipping'
9+
else
10+
echo 'Cloning rbenv repo'
11+
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
12+
fi
13+
14+
# Needs the - because it's being run in a script
15+
~/.rbenv/bin/rbenv init -
16+
17+
if ! command -v zsh >/dev/null 2>&1; then
18+
echo "**** zsh not installed, skipping shell completions setup ****"
19+
else
20+
if [ -f ~/.zshrc ]; then
21+
if ! grep -q 'FPATH=~/.rbenv/completions:"$FPATH"' ~/.zshrc; then
22+
echo 'Adding shell completions to zsh for rbenv'
23+
24+
echo 'FPATH=~/.rbenv/completions:"$FPATH"' >> ~/.zshrc
25+
echo 'autoload -U compinit' >> ~/.zshrc
26+
echo 'compinit' >> ~/.zshrc
27+
else
28+
echo 'rbenv shell completions already exist in zsh, skipping'
29+
fi
30+
else
31+
echo '~/.zshrc not found, creating one with the shell completions'
32+
33+
echo 'FPATH=~/.rbenv/completions:"$FPATH"' >> ~/.zshrc
34+
echo 'autoload -U compinit' >> ~/.zshrc
35+
echo 'compinit' >> ~/.zshrc
36+
fi
37+
fi

root/etc/s6-overlay/s6-rc.d/init-mod-code-server-bat-install/type renamed to root/etc/s6-overlay/s6-rc.d/init-mod-code-server-rbenv-install/type

File renamed without changes.

0 commit comments

Comments
 (0)