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
Truncate git branch name #755
Comments
Sorry, took a bit for me to add back the git segment in my prompt. Thank you very much to take the time to add this feature @JanDeDobbeleer! Unfortunately the new mkdir omp_test
cd omp_test/
git init
git config user.email test@ohmyposh.dev
git config user.name omp
git commit --allow-empty -m test
git branch some-very-long-branch-name-that-is-going-to-take-up-65-characters
git checkout some-very-long-branch-name-that-is-going-to-take-up-65-characters My git segment is configured like this: {
"type": "git",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"foreground": "#d4e157",
"background": "#546e7a",
"properties": {
"display_status": true,
"branch_max_length": "25"
}
} Here is my full theme file: {
"$schema": "https:\/\/raw.githubusercontent.com\/JanDeDobbeleer\/oh-my-posh3\/main\/themes\/schema.json",
"final_space": true,
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "os",
"style": "diamond",
"foreground": "#26c6da",
"background": "#546e7a"
},
{
"type": "session",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"foreground": "#000000",
"background": "#4e9a06"
},
{
"type": "time",
"style": "diamond",
"background": "#d3d7cf",
"foreground": "#000000",
"properties": {
"prefix": " \uf017 "
}
},
{
"type": "path",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"foreground": "#e4e4e4",
"background": "#3465a4",
"properties": {
"prefix": " \uf07c ",
"home_icon": "~",
"style": "full"
}
},
{
"type": "git",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"foreground": "#d4e157",
"background": "#546e7a",
"properties": {
"display_status": true,
"branch_max_length": "25"
}
},
{
"type": "root",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"foreground": "#100e23",
"background": "#ffe9aa"
},
{
"type": "python",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"foreground": "#100e23",
"background": "#906cff",
"properties": {
"prefix": " \ue235 "
}
},
{
"type": "exit",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"foreground": "#d3d7cf",
"background": "#000000",
"properties": {
"always_enabled": true,
"display_exit_code": true,
"error_color": "#cc2222",
"color_background": true,
"success_icon": "\u2714"
}
}
]
}
]
} |
@SunMar I take it you upgraded oh-my-posh and restarted your terminal ooh wait, it's an |
@JanDeDobbeleer yes in the screenshot you can see that I'm on the latest version 3.166.0 from yesterday and indeed I did restart the terminal just to be sure. Oh My Posh doesn't use a background service like Oops, sorry about the My updated theme is: {
"type": "git",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"foreground": "#d4e157",
"background": "#546e7a",
"properties": {
"display_status": true,
"branch_max_length": 25
}
} And the full updated JSON: {
"$schema": "https:\/\/raw.githubusercontent.com\/JanDeDobbeleer\/oh-my-posh3\/main\/themes\/schema.json",
"final_space": true,
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "os",
"style": "diamond",
"foreground": "#26c6da",
"background": "#546e7a"
},
{
"type": "session",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"foreground": "#000000",
"background": "#4e9a06"
},
{
"type": "time",
"style": "diamond",
"background": "#d3d7cf",
"foreground": "#000000",
"properties": {
"prefix": " \uf017 "
}
},
{
"type": "path",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"foreground": "#e4e4e4",
"background": "#3465a4",
"properties": {
"prefix": " \uf07c ",
"home_icon": "~",
"style": "full"
}
},
{
"type": "git",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"foreground": "#d4e157",
"background": "#546e7a",
"properties": {
"display_status": true,
"branch_max_length": 25
}
},
{
"type": "root",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"foreground": "#100e23",
"background": "#ffe9aa"
},
{
"type": "python",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"foreground": "#100e23",
"background": "#906cff",
"properties": {
"prefix": " \ue235 "
}
},
{
"type": "exit",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"foreground": "#d3d7cf",
"background": "#000000",
"properties": {
"always_enabled": true,
"display_exit_code": true,
"error_color": "#cc2222",
"color_background": true,
"success_icon": "\u2714"
}
}
]
}
]
} |
@SunMar allow me to validate this. Maybe I missed something obvious. Can you in the meantime ensure git is up-to-date as well? |
@JanDeDobbeleer Thank for taking the time to check. My WSL is running Ubuntu 21.04 and has git version 2.30.2 installed, which is the latest version available in the Ubuntu repositories. In Windows my git version is the latest 2.32.0 and in PowerShell my posh-git version is the latest 1.0.0. Let me know if there is any else I can help with. |
@SunMar fix incoming. Json parses as float. Standard "unit test succeeds, integration test fails" scenario. |
@JanDeDobbeleer it's working now, thank you very much !! 🥳 |
This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. |
Hi,
While I was setting up I ran into the problem that my git branch names are too long. They can sometimes be up to 50 characters long which takes up a lot of space. It would be nice if it's possible to set a maximum (f.ex. 20 or 30 characters) and truncate anything after that.
The text was updated successfully, but these errors were encountered: