Skip to content

Conversation

@somewatson
Copy link

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.

linuxserver.io


  • I have read the contributing guideline and understand that I have made the correct modifications

Description:

This mod includes the following features:

  1. Installs the bat and ripgrep packges
  2. It includes an alias for bat since the package will install it under batcat in Ubuntu due to a name collision with another package. It will include the alias in bash and zsh if it's not already included by checking for an existing alias.
  3. It also installed bat-extras which are helper functions for integrating into tools like git
  4. Lastly, it grants appropriate permissions to the bat-extras folder to make sure it can execute it properly

Benefits 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.

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.
@LinuxServer-CI
Copy link

PR build pushed to ghcr.io/linuxserver/mods:pull_request_1073

@somewatson somewatson mentioned this pull request Oct 27, 2025
1 task
@somewatson
Copy link
Author

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 BuildImage.yml file, like so:

Screenshot 2025-10-27 at 3 59 49 AM

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
@LinuxServer-CI
Copy link

PR build pushed to ghcr.io/linuxserver/mods:pull_request_1073

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
@LinuxServer-CI
Copy link

PR build pushed to ghcr.io/linuxserver/mods:pull_request_1073

Set MULTI_ARCH to false, since it's not needed
@LinuxServer-CI
Copy link

PR build pushed to ghcr.io/linuxserver/mods:pull_request_1073

@somewatson
Copy link
Author

@aptalca ty for the comments, I've made all the changes requested so far 👍

- 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
@LinuxServer-CI
Copy link

PR build pushed to ghcr.io/linuxserver/mods:pull_request_1073

@somewatson
Copy link
Author

@aptalca ty for the comments. I made the following changes:

  • Use absolute paths
  • Update bat-extras if it has already been cloned
  • Fix symlink command to not error if the links already exist

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.

@LinuxServer-CI
Copy link

PR build pushed to ghcr.io/linuxserver/mods:pull_request_1073

@LinuxServer-CI
Copy link

PR build pushed to ghcr.io/linuxserver/mods:pull_request_1073

@aptalca
Copy link
Member

aptalca commented Nov 4, 2025

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.

@somewatson
Copy link
Author

Ty for your patience. Was a bit busy over the holidays, but I found some time to work on this and I'm following up now.

I recreated the error you're describing, which occurs after a restart:

code-server | Bat-extras already cloned, updating
code-server | fatal: detected dubious ownership in repository at '/config/.bat-extras'
code-server | To add an exception for this directory, call:
code-server | 
code-server | 	git config --global --add safe.directory /config/.bat-extras

I'll work on this and let you know once I have a fix.

Make the bat-extras folder safe to pull when root doesn't own it

That way we can automate pulling the latest updates on restart
@LinuxServer-CI
Copy link

PR build pushed to ghcr.io/linuxserver/mods:pull_request_1073

@somewatson
Copy link
Author

@aptalca I can confirm that the latest commit addresses the issue. I followed the prompt from the error message in order to apply the fix.

The new logs look like this now:

code-server | Bat-extras already cloned, updating
code-server | Already up to date.
code-server | Installing bat-extras
code-server | Setting permissions for bat-extras

This should be ready to merge. Thank you for your help during this process. 🚀

@github-project-automation github-project-automation bot moved this from PRs to PRs Approved in Issue & PR Tracker Dec 1, 2025
@aptalca aptalca merged commit eca958d into linuxserver:code-server-bat Dec 1, 2025
4 checks passed
@LinuxServer-CI LinuxServer-CI moved this from PRs Approved to Done in Issue & PR Tracker Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants