1 - VictorVG/FarUE3_x64 GitHub Wiki
Git support tools
I add partial Git support in to Git menu as sub-menu on to main UserMenu:
G: Git:
{
B: Branch:
{
D: Delete branch:
{
L: Delete local
@git branch -D !?$$Branch name?!
R: Delete remount
@git branch -D -r !?$$Branch name?!
}
L: List branch:
{
A: Botch local and remount
@git branch -a
L: Local only
@git branch
R: Remount only
@git branch -r
}
N: New branch:
{
A: Clone all
@git branch -r > "%temp%\fargtbch.txt"
@for /f %A in ('findstr /v master "%temp%\fargtbch.txt"') do (git checkout -t %A)
@del /f/q %temp%\fargtbch.txt > nul
@git checkout !?$$and switch to?!
C: Clone selected
@git checkout -t origin/!?$$Branch name?!
M: Make new
@git branch !?$$Branch name?! !?$$Start at commit or tag ((current if empty))?!
S: Make and switch
@git checkout -b !?$$Branch name?! !?$$Start at commit or tag ((current if empty))?!
}
--:
C: Copy to
git branch -C !?$$Old branch name?! !?$$New branch name?!
R: Rename to
@git branch -M !?$$Old branch name?! !?$$New branch name?!
--:
M: Merge in
@git merge !?$src$Source branch?master!
--:
S: Select branch
lua:mf.eval('Plugin.Command("BE0B1498-4234-4BE1-B257-7653CAF4F091","branch")',0)
}
C: Commit:
{
U: Undo:
{
L: Undo local to commit
lua:mf.eval('Far.DisableHistory(-1) mf.print("git reset --hard "..mf.prompt("Undo to commit",nil,1,nil)) Keys("Enter")',0)
R: Undo repository to commit
lua:mf.eval('Far.DisableHistory(-1) mf.print("git reset --hard "..mf.prompt("Undo to commit",nil,1,nil).." && @git push -f origin HEAD") Keys("Enter")',0)
Z: Undo last local commit
lua:mf.eval('Far.DisableHistory(-1) mf.print("git commit --amend") Keys("Enter")',0)
}
C: Create commit
lua:mf.eval('Plugin.Command("BE0B1498-4234-4BE1-B257-7653CAF4F091","commit")',0)
S: Select for commit
@git add !& -u
P: Upload commit
lua:mf.eval('Far.DisableHistory(-1) mf.print("git push origin HEAD "..mf.prompt("Options",nil,1,nil)) Keys("Enter")',0)
W: Show commit
edit: < git show !?$$Commit hash or tag name?!
}
H: History:
{
C: All commits
lua:mf.eval('Plugin.Command("BE0B1498-4234-4BE1-B257-7653CAF4F091","log")',0)
D: Diff
@edit: < git diff !?$$Start point ((commit or tag))?! !?$$End point ((commit or tag))?!
F: Current file
lua:mf.eval('Plugin.Command("BE0B1498-4234-4BE1-B257-7653CAF4F091","log "..APanel.Current)',0)
I: Selected date
edit: < git log --decorate=short --since="!?$$Start date and time?!" --date=iso8601 --format="[%h] %cd %an : %s"
R: Selected revisions
edit: < git log !?$$Start hash or tag name?!..!?$$End hash or tag name?! --decorate=short --date=iso8601 --format="[%h] %cd %an : %s"
S: Selected files
edit: < git log !&
}
R: Repository:
{
A: Add to index
@git add !&
--:
C: Clone
@"%FARHOME%\gtcln" -r !?$repo$Server URL?! !?$dir$Clone to Dir?! !?$branch$Switch to branch?master!
--:
W: Switch to commit
lua:mf.eval('Far.DisableHistory(-1) mf.print("git checkout "..mf.prompt("Commit",nil,1,nil)) Keys("Enter")',0)
--:
D: Delete selected
@git rm -f !?$$Options ((-r for recursive))?! !&
@git commit -m "Delete unused"
@git push -f origin HEAD
E: Delete remote selected
@git rm --cached -f !?$$Options ((-r for recursive))?! !&
@git commit -m "Delete unused"
@git push -f origin HEAD
@git add !&
L: Delete local selected
@git rm -f !?$$Options ((-r for recursive))?! !&
N: Remove selected form index
@git rm --cached -f !?$$Options ((-r for recursive))?! !&
U: Cleanup deleted
@git ls-files -d -z | xargs -0 git rm --cached
V: Move or rename selected
@git mv !?$$Options ((-f, -k, -n, -v))?! !& !?$tgt$Distantion ((dir for list))?!
--:
R: Repair detached HEAD
@git checkout HEAD@{1}
S: Check status
@git status
}
S: Release:
{
R: Upload release
@git push origin HEAD !?$key$Push: options? !
@git push origin HEAD --tag !?$keyt$Tag: options? !
S: Delete release
@set tg=!?$Name$Tag name?!
@git tag -d %tg%
@git push origin -d -f %tg% -d
@set tg=
W: Release master
@git commit -a -m "!?$Comment$Comment?!"
@git tag -a "!?$Name$Tag name?!" -m "!?$Comment$Comment?!" !?$$Commit hash ((for existing commit only))?!
@git push origin HEAD !?$key$Push: options? !
@git push origin HEAD --tag !?$keyt$Tag: options? !
edit:< sha256sum !&
}
T: Tag:
{
D: Delete remote tag
@git push -d !?$Name$Tag name?!
E: Delete local tag
@git tag -d !?$Name$Tag name?!
N: New tag
@git tag -a "!?$Name$Tag name?!" -m "!?$Comment$Comment?!" !?$$Commit hash ((for existing commit only))?!
U: Upload all tag
@git push origin --tag
V: View local tag list
edit: < git tag -l -i
}
--:
W: Release master
@git commit -a -m "!?$Comment$Comment?!"
@git tag -a "!?$Name$Tag name?!" -m "!?$Comment$Comment?!" !?$$Commit hash ((for existing commit only))?!
@git push origin HEAD !?$key$Push: options? !
@git push origin HEAD --tag !?$keyt$Tag: options? !
edit:< sha256sum !&
}
(is current code) and GitShell plug-in by MaxRusov (big thanks on this plug-in!) see examples:
Plug-in GitShell required plug-in Visual Compare v1.18 or never and use for browse Git repository. All git command whats don't include in to menu mast running on Far command prompt for prevent any errors.
Also for Git support I write as example little macros GitGs v1.0 for Far 3.0 b4400+ used hotkey AltShiftG
-- v1.0, Initial release
-- VictorVG @ Viksoft.Ru, 02.03.2018 21:53:58 +0300
--
-- v1.1, Save and restore command prompt, customize git-gc(1) parameters, refactoring
-- VictorVG @ Viksoft.Ru, 06.03.2018 04:33:21 +0300
Macro{
id="13B9E07D-B81D-458F-800E-C5E7DFCA0637";
area="Shell";
key="AltShiftG";
description="Cleanup unnecessary files and optimize the local repository";
flags="EnableOutput NoSendKeysToPlugins";
action=function()
local bcmd=mf.trim(CmdLine.Value);
if not CmdLine.Empty then bcmd=mf.trim(CmdLine.Value) Keys("Esc") end;
Far.DisableHistory(-1) mf.print("git gc"..mf.prompt("Parameters","",0x00000001,"","Prm")) Keys("Enter")
mf.print(bcmd)
end;
}
And script Plugin_GitShell.lua for use GitShell plugin:
-- VictorVG @ VikSoft.Ru, 1996 - 2018
--
-- v1.0, Initial release
-- 19.02.2018 02:01:28 +0300
--
-- v1.1, Refactoring, add macro for delete branch
-- 26.02.2018 21:01:45 +0300
--
-- v1.2, Add new macros for GitShell command, refactoring.
-- 06.03.2018 06.03.2018 06:10:12 +0300
local GSID = "BE0B1498-4234-4BE1-B257-7653CAF4F091";
local GSMID = "0B7813BD-DEC1-4866-B20E-F5C49FF4AFA0";
local GSBID = "6204962D-3F32-4D81-A39C-79D0E9315328";
Macro {
description="GitShell menu";
area="Shell";
key="CtrlAltG";
action=function()
Plugin.Menu(GSID,GSMID)
end;
}
Macro {
description="Delete branch";
area="Dialog";
key="Del";
condition=function() return Dlg.Id==GSBID end;
action=function()
Keys("F8")
end;
}
Macro{
id="C83316CF-E1E9-429E-9552-C0F295158274";
area="Shell";
key="AltShiftN";
description="GiShell branch tools";
action=function()Far.DisableHistory(-1) Plugin.Command(GSID,'branch') end;
}
Macro{
id="43EDB414-789E-4760-823E-19638DDA52D9";
area="Shell";
key="CtrlShiftC";
description="GitShell commit tools";
action=function() Far.DisableHistory(-1) Plugin.Command(GSID,'commit') end;
}
Macro{
id="8F9AA142-3456-423C-8034-325AE7ED6050";
area="Shell";
key="AltShiftH";
description="GitShell view history";
action=function() Far.DisableHistory(-1) Plugin.Command(GSID,'log') end;
}
Macro{
id="2F49ED7B-5719-45C5-B801-CDBCE32D3EF1";
area="Shell";
key="AltShiftL";
description="GitShell current file history";
action=function() Far.DisableHistory(-1) Plugin.Command(GSID,'log '..APanel.Current) end;
}
Also gtcln.cmd (used form this menu)
@echo off
setlocal enableextensions
if "%1" == "-r" (if "%3"=="" (goto usg
) else (
if "%2" == "" (goto usg)
)
set br=%4 && git clone %2 %3 && cd /d %3 && goto brnch)
if not "%1" == "-b" (goto usg)
if not "%3" == "" (set br=%3 && cd %2) else (if not "%2"=="" (if not exist %2 (set br=%2) else ((set br=) && cd %2)) else (set br=))
:brnch
git branch -r > "%temp%\fargtbch.txt"
for /f %%A in ('findstr /v master "%temp%\fargtbch.txt"') do (git checkout -t %%A)
del /f/q %temp%\fargtbch.txt > nul
if not "%br%" == "" (git checkout %br%%)
exit
:usg
echo.
echo Synopsis:
echo.
echo Clone Git repository include all branches or clone branches only for
echo existing Git repository.
echo.
echo Required:
echo.
echo Git v1.9 or never, Windows XP or never console and device "straight arms".
echo.
echo Usage:
echo.
echo gtcln -r URL DIR [BRANCH] or gtcln -b DIR [BRANCH] or gtcln -b [BRANCH]
echo.
echo Parameters:
echo.
echo URL - remout repository URL (required for -r switch)
echo DIR - local repository dir (required for -r switch)
echo BRANCH - switch local repository to BRANCH if defined
echo.
pause
exit