File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ dotnet tool install --global termix
148148```
149149
150150::: info Version Info
151- ** Current stable version:** 2.2 .0
151+ ** Current stable version:** 2.3 .0
152152
153153** Minimum .NET:** 9.0
154154
Original file line number Diff line number Diff line change 1+ namespace termix . Services ;
2+
3+ public static class GitService
4+ {
5+ public static string ? GetBranchName ( string path )
6+ {
7+ try
8+ {
9+ var repoPath = FindGitRepository ( path ) ;
10+ if ( repoPath == null )
11+ {
12+ return null ;
13+ }
14+
15+ var headFile = Path . Combine ( repoPath , ".git" , "HEAD" ) ;
16+ if ( ! File . Exists ( headFile ) )
17+ {
18+ return null ;
19+ }
20+
21+ var headContent = File . ReadAllText ( headFile ) . Trim ( ) ;
22+
23+ const string refPrefix = "ref: refs/heads/" ;
24+ if ( headContent . StartsWith ( refPrefix ) )
25+ {
26+ return headContent [ refPrefix . Length ..] ;
27+ }
28+
29+ return headContent . Length > 7 ? headContent [ ..7 ] : headContent ;
30+ }
31+ catch
32+ {
33+ return null ;
34+ }
35+ }
36+
37+ private static string ? FindGitRepository ( string startPath )
38+ {
39+ var currentDirectory = new DirectoryInfo ( startPath ) ;
40+ while ( currentDirectory != null )
41+ {
42+ if ( Directory . Exists ( Path . Combine ( currentDirectory . FullName , ".git" ) ) )
43+ {
44+ return currentDirectory . FullName ;
45+ }
46+ currentDirectory = currentDirectory . Parent ;
47+ }
48+ return null ;
49+ }
50+ }
Original file line number Diff line number Diff line change 99 <ToolCommandName >termix</ToolCommandName >
1010 <PackageOutputPath >./nupkg</PackageOutputPath >
1111 <PackageId >Termix</PackageId >
12- <Version >2.2 .0</Version >
12+ <Version >2.3 .0</Version >
1313 <Authors >amrohan</Authors >
1414 <Company >amrohan</Company >
1515 <Description >An elegant and powerful file navigator that makes command-line file management
3333 <None Include =" README.md" Pack =" true" PackagePath =" \" />
3434 </ItemGroup >
3535 <ItemGroup >
36- <Folder Include =" docs\" />
36+ <Folder Include =" docs\" />
3737 </ItemGroup >
3838
39- </Project >
39+ </Project >
Original file line number Diff line number Diff line change @@ -49,8 +49,16 @@ private static IRenderable CreateSortMenuBody(
4949
5050 private static Panel CreateHeader ( string currentPath )
5151 {
52+ var branchName = GitService . GetBranchName ( currentPath ) ;
53+ var branchInfo = "" ;
54+ if ( ! string . IsNullOrEmpty ( branchName ) )
55+ {
56+ const string branchIcon = "\uE725 " ;
57+ branchInfo = $ " ([yellow]{ branchIcon } { branchName . EscapeMarkup ( ) } [/])";
58+ }
59+
5260 var displayPath = currentPath . Length > 80 ? "..." + currentPath [ ^ 77 ..] : currentPath ;
53- var headerContent = new Markup ( $ "[bold cyan3]\uE5FF { displayPath . EscapeMarkup ( ) } [/]") ;
61+ var headerContent = new Markup ( $ "[bold cyan3]\uE5FF { displayPath . EscapeMarkup ( ) } [/]{ branchInfo } ") ;
5462 return new Panel ( headerContent ) { Border = BoxBorder . Rounded , BorderStyle = new Style ( Color . Cyan1 ) } ;
5563 }
5664
You can’t perform that action at this time.
0 commit comments