Display current checked out git branch name
Display current checked out git branch name
Many developers customize their command line (bash, etc.) to show what git branch name they have checked out when they are in a folder that's under a git repository. Example:
https://coderwall.com/p/fasnya/add-git- ... ash-prompt
See the yellow "(develop)" part on the first line? That's the name of the branch and it's there as a label at the very end of the command prompt (ignore the other parts of this image):
Is there a way to do the equivalent of this in XYplorer? When I go to a folder that's under a git repo, I'd like to know the branch name I have currently checked out (ideally somewhere at the top and distractingly visible). This is very important because depending on which git branch you have checked out, some files/folders may appear and some won't, which can be confusing if you forget about the fact that branches are in play and may affect what you're seeing.
https://coderwall.com/p/fasnya/add-git- ... ash-prompt
See the yellow "(develop)" part on the first line? That's the name of the branch and it's there as a label at the very end of the command prompt (ignore the other parts of this image):
Is there a way to do the equivalent of this in XYplorer? When I go to a folder that's under a git repo, I'd like to know the branch name I have currently checked out (ideally somewhere at the top and distractingly visible). This is very important because depending on which git branch you have checked out, some files/folders may appear and some won't, which can be confusing if you forget about the fact that branches are in play and may affect what you're seeing.
Re: Display current checked out git branch name
Never thought about this, but now that you suggested it, I think that's a really neat idea!
I think the branch name should be displayed in the tab name.
EDIT: should this be moved to Wishes? I don't think this is something we can properly do with scripting.
I think the branch name should be displayed in the tab name.
EDIT: should this be moved to Wishes? I don't think this is something we can properly do with scripting.
Re: Display current checked out git branch name
Sure it can be done with scripting but it needs to be invoked manually...I don't think this is something we can properly do with scripting.
Code: Select all
$branch = regexreplace(runret("git branch"), "\r?\n");
$tabName = tab("get", "name");
if (!$tabName) { $tabName = tab("get", "caption"); }
$tabName = regexreplace($tabName, " \[\* .+?\]$");
if (strpos($branch, "*") != -1) {
$branch = regexreplace($branch, "^(?:\* )(.+?)(?=\r?\n|$)", "$1");
tab("rename", "$tabName [* $branch]");
} else {
tab("rename", $tabName);
}
One of my scripts helped you out? Please donate via Paypal
-
- Site Admin
- Posts: 60612
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Display current checked out git branch name
Can anybody explain this to a non-GITter? I have no idea what this is about. But if it's a simple thing I'm happy to add it...
FAQ | XY News RSS | XY Twitter
Re: Display current checked out git branch name
On each folder change invoke "git branch" and if there is an entry that begins with "*",
that's the name of the current branch. Add it to the tabs name like in the script
I've posted above...
that's the name of the current branch. Add it to the tabs name like in the script
I've posted above...
One of my scripts helped you out? Please donate via Paypal
Re: Display current checked out git branch name
Ofc it does, I already said that it needs to be invoked manually...Plus once your tab is renamed, it stayed renamed, even if you browse to a different folder.
One of my scripts helped you out? Please donate via Paypal
Re: Display current checked out git branch name
https://www.atlassian.com/git/tutorials/using-branches
EDIT: this one is interesting as well without going into too much details: https://backlog.com/git-tutorial/using-branches/
-
- Site Admin
- Posts: 60612
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Display current checked out git branch name
Thanks, but no time to read this ATM. So, let's put is this way: But is the wish here?
FAQ | XY News RSS | XY Twitter
Re: Display current checked out git branch name
Basically, we use a git repository (a folder on our file system) that holds several branches. A branch represents a version of the files (and subfolders) in the repository. At a moment in time, we're always checked out to one branch (and only one). When we switch branches, it modifies the content of the folder (corresponding to the git repository). The wish here is to know to which branch (identified by its name: the default branches are usually named
My proposal is to append it to the tab name.
Ideally, XYplorer should detect if the tab is listing the content of a git repository, and if so, get the branch name and display it automatically.
master
, develop
; or any other name you wish) we are currently checked out.My proposal is to append it to the tab name.
Ideally, XYplorer should detect if the tab is listing the content of a git repository, and if so, get the branch name and display it automatically.
-
- Site Admin
- Posts: 60612
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Display current checked out git branch name
Far out. A bit exotic maybe for a general purpose file manager?
FAQ | XY News RSS | XY Twitter
Re: Display current checked out git branch name
Maybe.
But you could add support to other VCS (SVN, Mercurial...) as well (Git is the most common, so first to do), and it would be a nice feature for developers.
But you could add support to other VCS (SVN, Mercurial...) as well (Git is the most common, so first to do), and it would be a nice feature for developers.
Re: Display current checked out git branch name
Don, git is HUGE. Adding support for git status and metadata will be very attractive to a lot of potential customers!
the git executable's output structure is easily parseable by code; maybe you can just call git on location change to get necessary branch and repo status info. Git surely has some more accessible library too.
the git executable's output structure is easily parseable by code; maybe you can just call git on location change to get necessary branch and repo status info. Git surely has some more accessible library too.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
- Site Admin
- Posts: 60612
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Display current checked out git branch name
Thanks for the tip. Up to now I did not hear much from the GIT community. If that changes I will be happy to add this stuff. Looks easy enough...
FAQ | XY News RSS | XY Twitter
Re: Display current checked out git branch name
I've never been a fan of adding integration with specific third party products. I think a more general solution would be an option to run a script on directory change, so that users who want this feature can use a script like the one highend posted.