Skip to content

Commit e69bba3

Browse files
authored
Merge pull request #137 from thin-edge/feat-enable-tab-completions
feat: enable tedge tab completions
2 parents 310c352 + ab41315 commit e69bba3

File tree

4 files changed

+51
-2
lines changed

4 files changed

+51
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ Once you have [just](https://github.com/casey/just) installed, you can proceed w
8181
8282
You will be prompted for the required details. You can hit `<enter>` to accept the default values. The default values are provided via the `.env` file from the first step.
8383
84+
Alternatively, if you're a [go-c8y-cli](https://goc8ycli.netlify.app/) user, and have the [c8y-tedge](https://github.com/thin-edge/c8y-tedge) extension installed, then you can bootstrap the device using:
85+
86+
```sh
87+
just bootstrap-c8y
88+
```
89+
8490
4. Click on the device link shown on your console
8591

8692
5. That's it 🚀

images/common/optional-installer.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,42 @@ configure_services() {
5656
fi
5757
}
5858

59+
set_zsh_defaults() {
60+
cat <<EOT >> "$1"
61+
autoload -U compinit; compinit
62+
# zsh styling to make the completion menu easier to read and use
63+
zstyle ':completion:*' menu select
64+
# bind shift+tab to reverse menu complete
65+
zmodload zsh/complist
66+
bindkey -M menuselect '^[[Z' reverse-menu-complete
67+
EOT
68+
}
69+
70+
configure_shells() {
71+
# Enable tab completions (note: fish does not require any changes)
72+
73+
# bash
74+
echo '[ -f /etc/bash_completion ] && source /etc/bash_completion' >> /etc/profile.d/load_completions.sh
75+
echo '. /etc/profile' >> ~/.bashrc
76+
echo '. /etc/profile' >> "/home/$TEST_USER/.bashrc"
77+
if [ ! -e /etc/bash_completion ]; then
78+
ln -sf /usr/share/bash-completion/bash_completion /etc/bash_completion
79+
fi
80+
81+
# zsh
82+
set_zsh_defaults ~/.zshrc
83+
set_zsh_defaults "/home/$TEST_USER/.zshrc"
84+
85+
# set default shell to zsh
86+
# echo "/usr/bin/zsh" >> /etc/shells
87+
if command -V zsh >/dev/null 2>&1; then
88+
chsh -s "$(which zsh)"
89+
fi
90+
}
91+
5992
main() {
6093
configure_users
94+
configure_shells
6195
configure_services
6296
install_container_management
6397
}

images/debian-systemd/debian-systemd.dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ENV INSTALL="false"
77
# ENV BOOTSTRAP="false"
88

99
# Install
10-
RUN apt-get -y update \
10+
RUN apt-get -y update --allow-releaseinfo-change \
1111
&& DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends install \
1212
wget \
1313
curl \
@@ -18,6 +18,11 @@ RUN apt-get -y update \
1818
systemd \
1919
systemd-sysv \
2020
ssh \
21+
# shells
22+
bash \
23+
bash-completion \
24+
zsh \
25+
fish \
2126
collectd-core \
2227
# extra collectd shared libraries
2328
libmnl0 \

justfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,16 @@ down-all:
8585
bootstrap *ARGS:
8686
@docker compose --env-file {{DEV_ENV}} -f images/{{IMAGE}}/docker-compose.yaml exec tedge env C8Y_USER=${C8Y_USER:-} C8Y_PASSWORD=${C8Y_PASSWORD:-} DEVICE_ID=${DEVICE_ID:-} bootstrap.sh {{ARGS}}
8787

88+
# Configure and register the device to the cloud using go-c8y- c8y-tedge extension
89+
bootstrap-c8y *ARGS:
90+
cd "images/{{IMAGE}}" && c8y tedge bootstrap-container tedge {{ARGS}}
91+
8892
# Bootstrap container using the go-c8y-cli c8y-tedge extension
8993
bootstrap-container *ARGS="":
9094
cd "images/{{IMAGE}}" && c8y tedge bootstrap-container bootstrap {{ARGS}}
9195

9296
# Start a shell on the main device
93-
shell *args='bash':
97+
shell *args='zsh':
9498
docker compose -f images/{{IMAGE}}/docker-compose.yaml exec tedge {{args}}
9599

96100
# Start a shell on the child device

0 commit comments

Comments
 (0)