-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
# zoxide | ||
|
||
Install [zoxide](https://github.com/ajeetdsouza/zoxide) | ||
|
||
## Example Usage | ||
|
||
```json | ||
"features": { | ||
"ghcr.io/devcontainers-contrib/features/zoxide:0": {} | ||
} | ||
``` | ||
|
||
## Options | ||
|
||
| Options Id | Description | Type | Default Value | | ||
|-----|-----|-----|-----| | ||
| replaceCd | Use zoxide when calling cd (see ZOXIDE_CMD_OVERRIDE) | bool | true | | ||
| username | For which user to setup zoxide, by default uses 'remoteUser' or 'containerUser' from config | string | - | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "zoxide", | ||
"id": "zoxide", | ||
"version": "0.1.0", | ||
"description": "Install zoxide", | ||
"documentationURL": "http://github.com/devcontainers-contrib/features/tree/main/src/zoxide", | ||
"installsAfter": [], | ||
"options": { | ||
"replaceCd": { | ||
"type": "bool", | ||
"default": "true", | ||
"proposals": [], | ||
"description": "Use zoxide when calling cd (see ZOXIDE_CMD_OVERRIDE)" | ||
}, | ||
"username": { | ||
"type": "string", | ||
"default": "", | ||
"proposals": [ | ||
"root", | ||
"node", | ||
"vscode" | ||
], | ||
"description": "For which user to setup zoxide, by default uses 'remoteUser' or 'containerUser' from config" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
set -x | ||
REPLACE_CD=${REPLACECD:-""} | ||
USERNAME=${USERNAME:-$_REMOTE_USER} | ||
|
||
prefix=/usr/local | ||
shells="bash zsh" | ||
|
||
install_zoxide() { | ||
curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh -s -- --bin-dir ${prefix}/bin --man-dir ${prefix}/share/man | ||
} | ||
|
||
# Install zoxide | ||
install_zoxide | ||
|
||
if [ "$USERNAME" = "root" ]; then | ||
USER_LOCATION="/root" | ||
else | ||
USER_LOCATION="/home/$USERNAME" | ||
fi | ||
|
||
# Check available shells | ||
for s in $shells; do | ||
if ! command -v "$s" > /dev/null; then | ||
shells=${shells/$s/} | ||
fi | ||
done | ||
|
||
# Configure available shells | ||
for shell in $shells; do | ||
[ $shell = zsh ] && dest=${ZDOTDIR:-$USER_LOCATION}/.zshrc || dest=$USER_LOCATION/.bashrc | ||
# Set ZOXIDE_CMD_OVERRIDE | ||
if [ "${REPLACE_CD}" = "true" ]; then | ||
echo -e '\n# Replace cd with zoxide\nexport ZOXIDE_CMD_OVERRIDE="cd"' >> $dest | ||
fi | ||
|
||
echo -e "\n# Enable zoxide\neval \"\$(zoxide init $shell)\"" >> $dest | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"test": { | ||
"image": "mcr.microsoft.com/devcontainers/base:debian", | ||
"features": { | ||
"zoxide": { | ||
"replaceCd": true | ||
} | ||
} | ||
}, | ||
"test_no_cd": { | ||
"image": "mcr.microsoft.com/devcontainers/base:debian", | ||
"features": { | ||
"zoxide": { | ||
"replaceCd": false | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
source dev-container-features-test-lib | ||
|
||
# Test zoxide installed | ||
check "zoxide installed" command -v zoxide &>/dev/null | ||
|
||
# Test zsh shell configured | ||
check "ZOXIDE_CMD_OVERRIDE is set" zsh -i -c "[[ -n \"\${ZOXIDE_CMD_OVERRIDE+1}\" ]]" | ||
check "zoxide is enabled" zsh -i -c "command -v z &>/dev/null" | ||
|
||
# Test bash shell configured | ||
check "ZOXIDE_CMD_OVERRIDE is set" bash -i -c "[[ -n \"\${ZOXIDE_CMD_OVERRIDE+1}\" ]]" | ||
check "zoxide is enabled" bash -i -c "command -v z &>/dev/null" | ||
|
||
reportResults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
source dev-container-features-test-lib | ||
|
||
# Test zoxide installed | ||
check "zoxide installed" command -v zoxide | ||
|
||
# Test zsh shell configured | ||
check "ZOXIDE_CMD_OVERRIDE is set" zsh -i -c "[[ -z \"\${ZOXIDE_CMD_OVERRIDE+1}\" ]]" | ||
check "zoxide is enabled" zsh -i -c "command -v z &>/dev/null" | ||
|
||
# Test bash shell configured | ||
check "ZOXIDE_CMD_OVERRIDE is set" bash -i -c "[[ -z \"\${ZOXIDE_CMD_OVERRIDE+1}\" ]]" | ||
check "zoxide is enabled" bash -i -c "command -v z &>/dev/null" | ||
|
||
reportResults |