Skip to content

nberlette/gitpod-enhanced

Repository files navigation

Open in Gitpod: Ready to Code GNU Bash: Bourne Again Shell PNPM: Performant Node Package Management PNPM: Performant Node Package Management

Turbocharged Gitpod.io workspace image (built on-top of the official gitpod/workspace-full) with some tasteful enhancements to improve developer experience.


Getting Started

# add to .gitpod.yml

image: nberlette/gitpod-enhanced

Features

Git Enhancements

Package Management

Other terminal addons

  • Installs sensible defaults for ls, diff, grep - all with color
  • Bundled with many useful aliases, tools, and various other functional upgrades
  • Removes duplicate entries from $PATH variable

Configuration

For more details on builtin workspace features, see the Gitpod documentation.

GitHub CLI Authentication

I'm currently working (on minimal bandwidth) to integrate the newly-released dotfiles support with gitpod-enhanced, which will allow for a lot more streamlined configuration for settings such as this.

Until then, however, we have only the finest of janky solutions!

GITHUB_TOKEN="ghp_2ed23idj023ijmdjqkfewjdsnfe"

# set with gitpod's CLI:
eval $(gp env -e GITHUB_TOKEN=$GITHUB_TOKEN)

Setting the $GITHUB_TOKEN variable with a properly-scoped PAT (personal access token), will direct gitpod-enhanced to automatically authenticate your account with the GitHub CLI.

This means you'll be able to use the full list of features as soon as you fire up your workspaces!


GPG Support

I've recently included (experimental) support for GPG commit signatures, via the command line or Visual Studio Code UI.

If you create a new PGP key within a Gitpod workspace using the GitHub CLI (gh), it's pretty straightforward:

# find <key-id> using gpg (or in output of `gh keys`)
gpg --list-secret-keys --keyid-format LONG

# save as $GPG_KEY_ID
GPG_KEY_ID="<key-id>"

# export to gitpod
gp env GPG_KEY=$(gpg --export-secret-keys $GPG_KEY_ID | base64 -w 0)

# saves key-id; exports all gp vars to current workspace
eval $(gp env -e GPG_KEY_ID=$GPG_KEY_ID)

# source our .bashrc file for changes to take effect
source ~/.bashrc

Formatting PS1 and GIT_PS1

The GIT_PS1_ environment variables control the functions and display of the git-integrated shell prompt.

These are the currently available options and their default:

GIT_PS1_SHOWCOLORHINTS="1"
GIT_PS1_SHOWDIRTYSTATE="1"
GIT_PS1_SHOWSTASHSTATE=""
GIT_PS1_SHOWUNTRACKEDFILES=""
GIT_PS1_SHOWUPSTREAM="auto"
GIT_PS1_OMITSPARSESTATE="1"
GIT_PS1_STATESEPARATOR=""
GIT_PS1_DESCRIBE_STYLE="tag"
GIT_PS1_HIDE_IF_PWD_IGNORED="1"

The last three options are GIT_PS1_PREFIX, GIT_PS1_SUFFIX, GIT_PS1_FORMAT. These allow you to change the colors and format of the surrounding PS1 prompt string.

GIT_PS1_PREFIX="\[\e]0;\u \W\e\]\[\e[1;7;33m\] \u \[\e[0;7;36m\] \w \[\e[0;1m\] git:("
GIT_PS1_SUFFIX="\[\e[1m\])\[\e[0m\]\n\[\e[1;32;6m\]\$\[\e[0m\] "
GIT_PS1_FORMAT="%s"

They have no git config equivalent, and must be set in settings.json, the Gitpod Dashboard, or through the command gp env in the terminal:

eval $(gp env -e GIT_PS1_PREFIX="\[\e[1m\] \w \[\e[0m\] ... ")

You may change/remove any of these (with scope!) in Dashboard > Settings > Variables.

Override via .vscode/settings.json

// .vscode/settings.json
{
  "terminal.integrated.env.linux": {
    "GIT_PS1_SHOWUPSTREAM": "auto verbose name",
    "GIT_PS1_SHOWUNTRACKEDFILES": ""
  }
}

Override via .gitpod.yml

# .gitpod.yml
gitConfig:
  bash.showUpstream: "false"
  bash.hideIfPwdIgnored: "false"

Note: only some of the variables have an equivalent git config value, which allows you to override them on a per-repository level, right from the .gitpod.yml configuration file.


Contributing

Community contributions are paramount to the success of Open Source projects such as this, and maintainers like me rely on people like you to help keep the code alive. You are more than welcome to make any contributions, and I highly encourage you to make a pull request - regardless of whether you're adding, editing, or deleting code. It's all welcome here.


Code of Conduct

Please read the guidelines for contributing, as well as our community code of conduct before you make any contributions. Once you feel familiar with them, if you have any questions just open an issue or contact me.


License

MIT © 2022 Nicholas Berlette • all rights reserved