mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-25 02:54:03 -08:00
feat(devcontainer): deploy OMP to all shells,
This commit is contained in:
parent
a71d1f7454
commit
9bba2bf909
|
@ -8,16 +8,74 @@ FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT}
|
|||
ARG NODE_VERSION="none"
|
||||
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
|
||||
|
||||
# Download the Microsoft repository GPG keys
|
||||
RUN wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb
|
||||
# Register the Microsoft repository GPG keys
|
||||
RUN dpkg -i packages-microsoft-prod.deb
|
||||
# Download and register the Microsoft repository GPG keys
|
||||
RUN wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb && \
|
||||
dpkg -i packages-microsoft-prod.deb && \
|
||||
rm -f packages-microsoft-prod.deb
|
||||
|
||||
# [Optional] Uncomment this section to install additional OS packages.
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
&& apt-get install -y --no-install-recommends fish\
|
||||
&& apt-get install -y --no-install-recommends powershell
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
fish \
|
||||
powershell \
|
||||
tmux \
|
||||
&& apt-get clean
|
||||
|
||||
# Deploy latest stable oh-my-posh as a starting point:
|
||||
RUN pwsh -Command Install-Module oh-my-posh -Scope AllUsers -Force && \
|
||||
chmod 777 -R /usr/local/share/powershell
|
||||
# If you recompile the prompt in the devcontainer you may overwrite the executables at:
|
||||
# /usr/local/share/powershell/Modules/oh-my-posh/<version>/bin/
|
||||
|
||||
# Deploy symlink of binary under /usr/bin/oh-my-posh for convenience access from non-Powershell shells:
|
||||
RUN export ARCH=`uname -m`;\
|
||||
if [[ "$ARCH" -eq "aarch64" ]]; then \
|
||||
export POSH_BIN="$(find /usr/local/share/powershell/Modules/oh-my-posh/*/bin/posh-linux-arm64)";\
|
||||
elif [[ "$ARCH" -eq "armv7l" ]]; then \
|
||||
export POSH_BIN="$(find /usr/local/share/powershell/Modules/oh-my-posh/*/bin/posh-linux-arm)";\
|
||||
else \
|
||||
export POSH_BIN="$(find /usr/local/share/powershell/Modules/oh-my-posh/*/bin/posh-linux-amd64)";\
|
||||
fi;\
|
||||
ln -sf $POSH_BIN /usr/bin/oh-my-posh
|
||||
# NOTE: devcontainers are Linux-only at this time but when
|
||||
# Windows or Darwin is supported someone will need to improve
|
||||
# the code logic above.
|
||||
|
||||
# Deploy all latest oh-my-posh themes at devcontainer build time:
|
||||
ARG USERNAME=vscode
|
||||
ARG POSHTHEMES_ROOT=/home/${USERNAME}/.poshthemes
|
||||
ENV POSHTHEMES_ROOT=${POSHTHEMES_ROOT}
|
||||
RUN mkdir -m=777 -p ${POSHTHEMES_ROOT} && \
|
||||
wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/themes.zip -O ${POSHTHEMES_ROOT}/themes.zip && \
|
||||
unzip ${POSHTHEMES_ROOT}/themes.zip -d ${POSHTHEMES_ROOT} && \
|
||||
chmod 777 ${POSHTHEMES_ROOT}/*.json && \
|
||||
rm ${POSHTHEMES_ROOT}/themes.zip
|
||||
|
||||
# Can be used to override the devcontainer prompt default theme:
|
||||
ARG DEFAULT_POSH_THEME=jandedobbeleer
|
||||
ENV DEFAULT_POSH_THEME=${DEFAULT_POSH_THEME}
|
||||
|
||||
# Deploy oh-my-posh prompt to Powershell:
|
||||
COPY Microsoft.PowerShell_profile.ps1 /home/${USERNAME}/.config/powershell/Microsoft.PowerShell_profile.ps1
|
||||
|
||||
# Deploy oh-my-posh prompt to Fish:
|
||||
COPY config.fish /home/${USERNAME}/.config/fish/config.fish
|
||||
|
||||
# Everything runs as root during build time, so we want
|
||||
# to make sure the vscode user can edit these paths too:
|
||||
RUN chmod 777 -R /home/${USERNAME}/.config
|
||||
|
||||
# Override vscode's own Bash prompt with oh-my-posh:
|
||||
RUN sed -i 's/^__bash_prompt$/#&/' /home/${USERNAME}/.bashrc && \
|
||||
echo "eval \"\$(oh-my-posh --init --shell bash --config ${POSHTHEMES_ROOT}/${DEFAULT_POSH_THEME}.omp.json)\"" >> /home/${USERNAME}/.bashrc
|
||||
|
||||
# Override vscode's own ZSH prompt with oh-my-posh:
|
||||
RUN sed -i 's/^source \$ZSH/oh-my-zsh.sh$/# source \$ZSH/oh-my-zsh.sh&/' /home/${USERNAME}/.zshrc && \
|
||||
echo "eval \"\$(oh-my-posh --init --shell zsh --config ${POSHTHEMES_ROOT}/${DEFAULT_POSH_THEME}.omp.json)\"" >> /home/${USERNAME}/.zshrc
|
||||
|
||||
# Set container timezone:
|
||||
ARG TZ="UTC"
|
||||
RUN ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime
|
||||
|
||||
# [Optional] Uncomment the next line to use go get to install anything else you need
|
||||
# RUN go get -x github.com/JanDeDobbeleer/battery
|
||||
|
|
5
.devcontainer/Microsoft.PowerShell_profile.ps1
Normal file
5
.devcontainer/Microsoft.PowerShell_profile.ps1
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Activate oh-my-posh prompt:
|
||||
Import-Module oh-my-posh
|
||||
Set-PoshPrompt -Theme ${env:POSHTHEMES_ROOT}/${env:DEFAULT_POSH_THEME}.omp.json
|
||||
|
||||
# NOTE: You can override the above env vars from the devcontainer.json "args" under the "build" key.
|
4
.devcontainer/config.fish
Normal file
4
.devcontainer/config.fish
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Activate oh-my-posh prompt:
|
||||
oh-my-posh --init --shell fish --config $POSHTHEMES_ROOT/$DEFAULT_POSH_THEME.omp.json | source
|
||||
|
||||
# NOTE: You can override the above env vars from the devcontainer.json "args" under the "build" key.
|
|
@ -1,7 +1,7 @@
|
|||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
||||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.177.0/containers/go
|
||||
{
|
||||
"name": "Go",
|
||||
"name": "oh-my-posh",
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile",
|
||||
"args": {
|
||||
|
@ -9,7 +9,16 @@
|
|||
// Append -bullseye or -buster to pin to an OS version.
|
||||
// Use -bullseye variants on local arm64/Apple Silicon.
|
||||
"VARIANT": "1.17-bullseye",
|
||||
// Options
|
||||
|
||||
// Options:
|
||||
|
||||
"DEFAULT_POSH_THEME": "jandedobbeleer",
|
||||
|
||||
// Override me with your own timezone:
|
||||
"TZ": "UTC",
|
||||
// Use one of the "TZ database name" entries from:
|
||||
// https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||
|
||||
"NODE_VERSION": "lts/*"
|
||||
}
|
||||
},
|
||||
|
@ -43,19 +52,22 @@
|
|||
"terminal.integrated.defaultProfile.linux": "pwsh",
|
||||
"terminal.integrated.defaultProfile.windows": "pwsh",
|
||||
"terminal.integrated.defaultProfile.osx": "pwsh",
|
||||
"tasks.statusbar.default.hide": true
|
||||
},
|
||||
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
"extensions": [
|
||||
"actboy168.tasks",
|
||||
"eamodio.gitlens",
|
||||
"github.vscode-pull-request-github",
|
||||
"esbenp.prettier-vscode",
|
||||
"davidanson.vscode-markdownlint",
|
||||
"yzhang.markdown-all-in-one",
|
||||
"bungcip.better-toml",
|
||||
"redhat.vscode-yaml",
|
||||
"davidanson.vscode-markdownlint",
|
||||
"editorconfig.editorconfig",
|
||||
"esbenp.prettier-vscode",
|
||||
"github.vscode-pull-request-github",
|
||||
"golang.go",
|
||||
"ms-vscode.powershell"
|
||||
"ms-vscode.powershell",
|
||||
"redhat.vscode-yaml",
|
||||
"yzhang.markdown-all-in-one"
|
||||
],
|
||||
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
|
|
21
.vscode/tasks.json
vendored
21
.vscode/tasks.json
vendored
|
@ -17,6 +17,27 @@
|
|||
},
|
||||
"problemMatcher": "$go",
|
||||
"args": ["build", "-v"]
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "go",
|
||||
"label": "devcontainer: build omp",
|
||||
"options": {
|
||||
"cwd": "${workspaceRoot}/src",
|
||||
"shell": {
|
||||
"executable": "bash",
|
||||
"args": ["-c"]
|
||||
},
|
||||
"statusbar": {
|
||||
"hide": false,
|
||||
"color" : "#22C1D6",
|
||||
"label" : "$(beaker) devcontainer: build omp",
|
||||
"tooltip": "Compiles *oh-my-posh* from this repo while **overwriting** your preinstalled stable release."
|
||||
}
|
||||
},
|
||||
"group": "build",
|
||||
"problemMatcher": "$go",
|
||||
"args": ["build", "-v", "-o", "`readlink", "/usr/bin/oh-my-posh`"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -14,6 +14,42 @@ can be a good starting point.
|
|||
or core functionality.
|
||||
4. Pull Requests are merged once all checks pass and a project maintainer has approved it.
|
||||
|
||||
## Codespaces / Devcontainer Development Environment
|
||||
|
||||
Arguably the easiest way to contribute anything is to use our prepared development environment.
|
||||
|
||||
We have a `.devcontainer/devcontainer.json` file, meaning we are compatible with:
|
||||
|
||||
- [Github Codespaces][codespaces], or
|
||||
- the [Visual Studio Code Remote - Containers][devcontainer-ext] extension.
|
||||
|
||||
This Linux environment includes all shells supported by oh-my-posh, including Bash, ZSH,
|
||||
Fish and PowerShell, the latter of which is the default.
|
||||
|
||||
### Configuring Devcontainer's Timezone & Theme
|
||||
|
||||
1. Open the `.devcontainer/devcontainer.json` file and in the "*build*" section modify:
|
||||
|
||||
- `TZ`: with [your own timezone][timezones]
|
||||
- `DEFAULT_POSH_THEME`: with [your preferred theme][themes]
|
||||
|
||||
2. Summon the Command Panel (Ctrl+Shift+P) and select `Codespaces: Rebuild Container`
|
||||
to rebuild your devcontainer. (This should take just a few seconds.)
|
||||
|
||||
### Recompiling oh-my-posh within
|
||||
|
||||
The devcontainer definition preinstalls the latest stable oh-my-posh release at build time.
|
||||
|
||||
To overwrite the installation's version inside the running devcontainer, you may use the
|
||||
VSCode *task* `devcontainer: build omp` to rebuild your oh-my-posh with that of
|
||||
your running repository's state. (You might see a button for this in your statusbar.)
|
||||
|
||||
If the compile succeeds, `oh-my-posh --version` should reply:
|
||||
`development`
|
||||
|
||||
Should you somehow mess up your devcontainer's OMP install catastrophically, remember that
|
||||
if you do `Codespaces: Rebuild Container` again, you'll be back to the latest stable release.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
### Our Pledge
|
||||
|
@ -33,23 +69,23 @@ diverse, inclusive, and healthy community.
|
|||
Examples of behavior that contributes to a positive environment for the
|
||||
project include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
- Demonstrating empathy and kindness toward other people
|
||||
- Being respectful of differing opinions, viewpoints, and experiences
|
||||
- Giving and gracefully accepting constructive feedback
|
||||
- Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the
|
||||
- Focusing on what is best not just for us as individuals, but for the
|
||||
project
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
- The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
- Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
- Public or private harassment
|
||||
- Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
- Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
### Enforcement Responsibilities
|
||||
|
@ -142,3 +178,7 @@ enforcement ladder](https://github.com/mozilla/diversity).
|
|||
[homepage]: https://www.contributor-covenant.org
|
||||
[conduct]: mailto:conduct@ohmyposh.dev
|
||||
[coc]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
|
||||
[codespaces]: https://github.com/features/codespaces
|
||||
[devcontainer-ext]: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers
|
||||
[timezones]: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||
[themes]: https://ohmyposh.dev/docs/themes
|
||||
|
|
Loading…
Reference in a new issue