-
-
Notifications
You must be signed in to change notification settings - Fork 310
Create mod to include bat in code-server #1073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: code-server-bat
Are you sure you want to change the base?
Create mod to include bat in code-server #1073
Conversation
This mod adds bat to code-server, to be installed/updated during container start. Bat is a cat clone with syntax highlighting and Git integration. It also includes bat-extras, ripgrep, and aliases for bat in bash and zsh.
|
PR build pushed to |
|
I've done my best to follow the documentation in the README for submitting a PR. One question I have is, in order for it to work for myself on my own dockerhub, I have to update the
However, how do we ensure the correct values are merged in here in the official repo? |
- Make sure that linuxserver is the endpoint - Restore BuildImage.yml env vars that are labeled "don't modify" to the original values
|
PR build pushed to |
Separate the git clone step from the installation step It doesn't need to be cloned every time, but it should be installed every time
|
PR build pushed to |
Set MULTI_ARCH to false, since it's not needed
|
PR build pushed to |
|
@aptalca ty for the comments, I've made all the changes requested so far 👍 |
| if ! command -v zsh >/dev/null 2>&1; then | ||
| echo "**** zsh not installed, skipping alias setup ****" | ||
| else | ||
| if [ -f ~/.zshrc ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use absolute paths. The home folder for the abc user is /config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, in the next commit I'll fix that
| echo 'Installing bat-extras' | ||
| cd ~/.bat-extras/src | ||
| chmod +x ~/.bat-extras/src/*.sh | ||
| ln -s ~/.bat-extras/src/*.sh /usr/local/bin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this fail on a restart since the symlinks already exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks for pointing that out. Here's the logs I found on restart:
code-server-somewatson | Installing bat-extras
code-server-somewatson | ln: failed to create symbolic link '/usr/local/bin/batdiff.sh': File exists
code-server-somewatson | ln: failed to create symbolic link '/usr/local/bin/batgrep.sh': File exists
code-server-somewatson | ln: failed to create symbolic link '/usr/local/bin/batman.sh': File exists
code-server-somewatson | ln: failed to create symbolic link '/usr/local/bin/bat-modules.sh': File exists
code-server-somewatson | ln: failed to create symbolic link '/usr/local/bin/batpipe.sh': File exists
code-server-somewatson | ln: failed to create symbolic link '/usr/local/bin/batwatch.sh': File exists
code-server-somewatson | ln: failed to create symbolic link '/usr/local/bin/prettybat.sh': File exists
code-server-somewatson | Setting permissions for bat-extras
Notably, it still moves onto the next step and doesn't exit. But I will fix it so it doesn't error like this.
| echo 'Bat-extras already cloned, skipping' | ||
| else | ||
| echo 'Cloning bat-extras repo' | ||
| git clone https://github.com/eth-p/bat-extras.git ~/.bat-extras |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it only gets cloned once on first start, does it need to be updated later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Let me look into updating that.
- Use absolute paths - Update bat-extras if it has already been cloned - Fix symlink to not error if it already exists Chose to force the symlink because there might be new symlinks after a pull So I want an update to behave the same every time, which is to install all the scripts
|
PR build pushed to |
|
@aptalca ty for the comments. I made the following changes:
I chose to force the symlink because there might be new symlinks after a pull. I want an update to behave the same every time, which is to install all the scripts included in the update. |
|
PR build pushed to |
6445268 to
190ffd3
Compare
|
PR build pushed to |
|
Looks good to me, but please test the pr build above and test multiple container restarts and recreation to make sure it works as expected. I vaguely remember an issue with a git pull failing when run as root after a restart. |

This mod adds bat to code-server, to be installed/updated during container start.
Bat is a cat clone with syntax highlighting and Git integration.
It also includes bat-extras, ripgrep, and aliases for bat in bash and zsh.
Description:
This mod includes the following features:
batandripgreppackgesbatsince the package will install it underbatcatin Ubuntu due to a name collision with another package. It will include the alias inbashandzshif it's not already included by checking for an existing alias.bat-extraswhich are helper functions for integrating into tools likegitbat-extrasfolder to make sure it can execute it properlyBenefits of this PR and context:
This is in response to an issue I created #1072.
Bat is useful for viewing files in terminal since it's an improved version of cat and offers a lot of useful syntax highlighting and integration with other tools, like git.
There are tools built into the IDE for viewing git diffs and so on, but when you're already typing in the terminal, I have often found myself using bat since I'm already typing commands in terminal to begin with and I've started including this mod in every instance of code-server I run.
I think it would be nice to have it as an option for other developers as well.
How Has This Been Tested?
Yes, I'm running it on all of my instances of code-server.
I tested to make sure it works properly on a fresh install. I also ensured it is idempotent and works on an existing home folder
/config.Source / References:
Ripgrep has also been included because it is a requirment of bat-extras.