MAC OSX, Beyond compare as Perforce's merge tool - macos

As described in the title, I want to config Beyond compare as Perforce merge tool.
reference to the following link
(http://www.scootersoftware.com/support.php?zz=kb_vcs), I tried these steps:
Choose Preferences from the Edit menu.
Switch to the Diff tab.
Change the Default Diff Application option to "Other application".
Enter the path to BComp.exe in the Location edit.
Switch to the Merge tab.
Change the Default merge application to "Other application".
Enter the path to BComp.exe in the Location edit.
In the Arguments edit, enter: %1 %2 %b %r
But it can not work, anyone has successfully configured this?
beyond compare version: 4.0.7.
p4client version: DARWIN90X86_64/2015.1/1227227 (2015/08/27).

The instructions you listed are for Beyond Compare for Windows.
To configure Beyond Compare as the diff and merge tool in Perforce on Mac:
Launch Beyond Compare, go to the Beyond Compare menu and run Install
Command Line Tools.
Diff:
Go to the P4V menu and select Preferences.
Go to the Diff section and select Other application.
Location: /usr/local/bin/bcomp
Arguments: %1 %2
Merge
Go to the P4V menu and select Preferences.
Go to the Merge section and select Other application.
Location: /usr/local/bin/bcomp
Arguments: %1 %2 %b %r
Reference: Using Beyond Compare with Version Control Systems under OS X

Related

How do I change my VS Code terminal to cmd.exe instead of powershell?

For some reason my VS Code terminal is Powershell instead of cmd.exe. In my Terminal > External: Windows Exec is set to C:\WINDOWS\System32\cmd.exe. However, when I open the Terminal in VS Code I see PS C:...>. Also, in the terminal drop-down I only see powershell as an option.
How do I switch the Terminal to CMD.exe? Or maybe my better option would be to add cmd.exe to the list of available terminals so I can switch between them?
Open File -> Preferences -> Settings
Select User Settings in upper right corner.
Add the following line
"terminal.integrated.shell.windows": "cmd.exe"
Source: https://blog.jongallant.com/2017/02/vs-code-integrated-terminal-powershell-default-change-to-cmd/
To version
First step:
Second step: select the desired option:
Or
"terminal.integrated.defaultProfile.windows": "Command Prompt"
You can use View / Command Palete / Terminal: select default terminal to select from the range of detected terminals. Mine shows PS and cmd.exe which had to be changed as PS is disabled as a security policy in our environment.
In a recent VS Code upgrade the command prompt path in the profile config was updated as well - terminal.integrated.profiles.windows
This article mentioned how you can reset that.
https://dev.to/andrewriveradev/how-to-set-git-bash-as-integrated-terminal-in-vscode-2k31
Open command palette (CMD + Shift + P)
Search "Preferences: Open User Settings (JSON)"
Delete the terminal.integrated.profiles.windows object from the config
Create a new field by typing "" (double quotation key). Inside the quotation type "terminal." a list of options will appear.
Select terminal.integrated.profiles.windows. When you select terminal.integrated.profiles.windows it will be expanded
Add or replace "terminal.integrated.shell.windows": "cmd.exe"
To add onto LeSchlongLong's answer, which is now deprecated, you can simply follow these steps to change the default profile:
Ctrl+Shift+P (Windows) / Cmd+Shift+P (Mac)
Search for "Terminal: Select Default Profile"
Select whichever profile you would like to use

goland how to use gofmt?

I started learning go and installed GoLand from JetBrains. I am reading the book The Go Programming Language, and in the first chapter author strongly recommends using the gofmt tool before each save. How I can follow this recommendation in GoLand?
You can do that in one of these two ways:
For Goland: preferences ->Tools ->File Watchers and enable go fmt. This way on each saves it will format the file.
once your code is done. just run the command gofmt -s -w . in the terminal in the required directory or else in the needed file. it will format your whole directory/file as per your need.
GoLand have commands to go fmt your file or project. Right click on your file and you will find it under "Go tools". You could see its shortcut there.
You can also use "Reformat code" command (bound to Command-Alt-L for me). It's not 100% same as go fmt but very close. Also works for other languages.
If you have an open terminal, you can run go fmt ./... to format all files in a directory (including sub directories). You can put this in a git commit hook to run it every time you commit.
As others mentioned there's a file watcher section under Preferences → Tools → File Watchers, in there you can setup to run go fmt or goimports everytime you save a Go file.
Just want to add 1 more option. You can automatically apply go fmt every time when you are about to commit to git. When you open the commit window, under the Before Commit section, there is a Go fmt checkbox. Just check it. Later when you do another commit, the default value for that checkbox is checked. So, you only need to check it once. Then go fmt will run automatically before you commit.
If your version of GoLand 2021.2 or higher, you can enable Run gofmt on code reformat option under Preferences/Settings | Editor | Code Style | Go | Other (it is enabled by default).
After that, execute Code | Reformat Code (Option + Command + L on macOS) and gofmt will be executed after internal GoLand formatter.
Now Goland has a section that will reformat your code on file save without setting up File Watchers:
Under Settings -> Tools -> Actions On Save you can activate the first entry

Can I click on a filename and line number in iterm2 to open that file in Visual Studio Code at the correct line number in OS X

When Iterm2 shows a file name and line number in Mac OS X, can I ⌘-click on the file and have it open in an already open window in Visual Studio Code and position the cursor at the correct line number.
(Asking this question to document the solution)
It looks like you can just select "Open with editor..." in advanced settings > semantic history now
UPDATE - see the newer accepted answer by #csilk for more recent solution
It turns out you can, though it is not entirely obvious.
Go to Iterm2 Preferences > Profiles > (chosse the profile) > Advanced, then in the Semantic History section choose: Run Command, and enter the following:
/usr/local/bin/code -g \1:\2
If that appears to open in a new window then also try changing your Visual Studio Code settings by adding the following to your settings.json, press ⌘, and add in the right hand pane add:
"window.openFilesInNewWindow": false
EDIT - as mentioned in the comments by #BenjaminPasero adding -r to the command line will also force the file to be opened in the last active Code window, e.g.:
/usr/local/bin/code -r -g \1:\2
As an alternative solution you may still use the default configuration of iTerm2 (open files with default app) but adjust the default app for file itself in MacOS.
File -> Get Info -> Open with: ->
and set your app in combobox (also changes may be applied to all type like the following one)
I did not find the configuration in iTerm2 to set the default editor.
However, it turns out there is another solution.Check out the image below.
set default app for *.js file

How to configure Visual Studio to use Beyond Compare

I would like to configure Visual Studio to open Beyond Compare by default as the diff tool. How can I do this?
In Visual Studio, go to the Tools menu, select Options, expand Source Control, (In a TFS environment, click Visual Studio Team Foundation Server), and click on the Configure User Tools button.
Click the Add button.
Enter/select the following options for Compare:
Extension: .*
Operation: Compare
Command: C:\Program Files\Beyond Compare 3\BComp.exe (replace with the proper path for your machine, including version number)
Arguments: %1 %2 /title1=%6 /title2=%7
If using Beyond Compare Professional (3-way Merge):
Extension: .*
Operation: Merge
Command: C:\Program Files\Beyond Compare 3\BComp.exe (replace with the proper path for your machine, including version number)
Arguments: %1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9
If using Beyond Compare v3/v4 Standard or Beyond Compare v2 (2-way Merge):
Extension: .*
Operation: Merge
Command: C:\Program Files\Beyond Compare 3\BComp.exe (replace with the proper path for your machine, including version number)
Arguments: %1 %2 /savetarget=%4 /title1=%6 /title2=%7
If you use tabs in Beyond Compare
If you run Beyond Compare in tabbed mode, it can get confused when you diff or merge more than one set of files at a time from Visual Studio. To fix this, you can add the argument /solo to the end of the arguments; this ensures each comparison opens in a new window, working around the issue with tabs.
Visual Studio with Git for Windows
If you're using GIT as your source code management system instead of the (fairly dated) TFVC then Visual Studio doesn't have options to configure anything like this.
Instead it (rightly in my opinion) uses the GIT config file's setting. So if you already have GIT setup to use Beyond Compare or any other third party comparison software it will just pick this up and start using it.
If not then just set that up (see here for further and likely more up to date help). The relevant info for setting up Visual Studio with Beyond Compare 4 is:
Open Visual Studio.
Select Options from the Tools menu.
Select Plug-In Settings under the Source Control branch of the left-side tree control.
Select Microsoft Git Provider under Plug-In Settings on the right-hand pane.
Edit the global git config file (location is OS specific for windows it's %HOMEDRIVE%%HOMEPATH%/.gitconfig. See here for info) OR if you want it to be repo specifict then after starting a project in a Git repository, edit the config file in the .git folder in the project folder.
Change the config file to reflect the following changes:
[diff]
tool = bc4
[difftool "bc4"]
cmd = \"C:\\Program Files (x86)\\Beyond Compare 4\\BComp.exe\" \"$LOCAL\" \"$REMOTE\"
[merge]
tool = bc4
[mergetool "bc4"]
cmd = \"C:\\Program Files (x86)\\Beyond Compare 4\\BComp.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"
If 64bit installer is used, verify the name of the executable. Mine
was BCompare.exe
[diff]
tool = bc4
[difftool "bc4"]
cmd = \"C:\\Program Files\\Beyond Compare 4\\BCompare.exe\" \"$LOCAL\" \"$REMOTE\"
[merge]
tool = bc4
[mergetool "bc4"]
cmd = \"C:\\Program Files\\Beyond Compare 4\\BCompare.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"
Issues: If you create a new project and get VS to create the git repo at
the same time it WILL add a load of overrides to the .git/config file
forcing it to use Visual Studio again (Thanks for that MS!).
SO either create the git repo via another means after the project has been setup
(like via SourceTree or the command line etc...) OR edit the .git/config file
(in the solution folder) and remove any overrides for the above settings.
Thanks to minnow in the comments for bringing my attention to it again.
Note: I keep coming across this but I am using VS with GIT and the
answers aren't correct and although some of the comments mention a URL
with the correct answer it's not clear and if I kept missing it I'm
sure others will so hopefully this will solve that issue.
If you are using the TFS, you can find the more information in diff/merge configuration in Team Foundation - common Command and Argument values
It shows how to configure the following tools:
WinDiff
DiffDoc (for Word files)
WinMerge
Beyond Compare
KDiff3
Araxis
Compare It!
SourceGear DiffMerge
Beyond Compare 3
TortoiseMerge
Visual SlickEdit
I got bored of doing this every 6 months when a new version of Visual Studio comes out, or I move PCs, or a new member joins the team. So, PowerShell:
# .Synopsys
# Sets up Beyond Compare professional as Diff tool for all instances of Visual Studio on this PC
# If you don't use TFS, change the sccProvider as appropriate
[CmdLetBinding()]
param(
$bcPath = 'C:\Program Files (x86)\Beyond Compare 3\BComp.exe',
$sccProvider = 'TeamFoundation'
)
$ErrorActionPreference = 'stop';
$baseKey = 'REGISTRY::\HKCU\Software\Microsoft\VisualStudio\*'
function SetRegKeyProperties($keyPath, [hashtable]$keyProps){
if(!(Test-Path $keyPath)){
Write-Verbose "Creating $keyPath"
# Force required here to recursively create registry path
[void] (new-item $keyPath -Type:Directory -Force);
}
foreach($prop in $keyProps.GetEnumerator()){
Set-ItemProperty -Path:$keyPath -Name:$prop.Key -Value:$prop.Value;
}
}
$configBases = dir $baseKey | ? { $_.PSChildName -match '^\d+\.\d$' }
foreach($item in $configBases){
Write-Host "Configuring $item"
$diffToolsKey = Join-Path $item.PSPath "$sccProvider\SourceControl\DiffTools"
SetRegKeyProperties (Join-path $diffToolsKey '.*\Compare') #{Command=$bcPath;Arguments='%1 %2 /title1=%6 /title2=%7'}
SetRegKeyProperties (Join-path $diffToolsKey '.*\Merge') #{Command=$bcPath;Arguments='%1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9'}
}
Works on my machine. YMMV. No warranties, no refunds. VS doesn't appear to cache the key, so takes effect immediately.
In Visual Studio 2008 + , go to the
Tools menu --> select Options
In Options Window --> expand Source Control --> Select Subversion User
Tools --> Select Beyond Compare
and click OK button..
The answer posted by #schellack is perfect for most scenarios, but I wanted Beyond Compare to simulate the '2 Way merge with a result panel' view that Visual Studio uses in its own merge window.
This config hides the middle panel (which is unused in most cases AFAIK).
%1 %2 "" %4 /title1=%6 /title2=%7 /title3="" /title4=%9
With thanks to Morgen
I'm using VS 2017 with projects hosted with Git on visualstudio.com hosting (msdn)
The link above worked for me with the "GITHUB FOR WINDOWS" instructions.
http://www.scootersoftware.com/support.php?zz=kb_vcs#githubwindows
The config file was located where it indicated at "c:\users\username\.gitconfig" and I just changed the BC4's to BC3's for my situation and used the appropriate path:
C:/Program Files (x86)/Beyond Compare 3/bcomp.exe
VS2013 on 64-bit Windows 7 requires these settings:
Tools | Options | Source Control | Jazz Source Control
CHECK THE CHECKBOX Use an external compare tool ... (easy to miss this)
2-Way Compare
Location of Executable: C:\Program Files (x86)\Beyond Compare 3\BCompare.exe
3-Way Conflict Compare
Location of Executable: C:\Program Files (x86)\Beyond Compare 3\BCompare.exe
BComp.exe works in multiple-tabbed scenario as well, so there is no need to add /solo unless you really want separate windows for each file comparison. Tested/verified on Beyond Compare 3 and 4. Moral: use BComp.exe, not BCompare.exe, for VS external compare tool configuration.
I use BC3 for my git diff, but I'd also add vscode to the list of useful git diff tools. Some users prefer vscode over vs ide experience.
Using VS Code for Git Diff
git config --global diff.tool vscode
git config --global difftool.vscode.cmd "code --wait --diff $LOCAL $REMOTE"
Can't comment because my reputation score is low.
Here's a waybackmachine link to Fresky's link

Multiple tabs in Windows and gvim

I am trying to get the Edit with Vim context menu to open files in a new tab of the previously opened Gvim instance (if any).
Currently, using Regedit I have modified this key:
\HKEY-LOCAL-MACHINE\SOFTWARE\Vim\Gvim\path = "C:\Programs\Vim\vim72\gvim.exe" -p --remote-tab-silent "%*"
The registry key type is REG_SZ.
This almost works... Currently it opens the file in a new tab, but it also opens another tab (which is the active tab) the tab is labeled \W\S\--literal and the file seems to be trying to open the following file.
C:\Windows\System32\--literal
I think the problem is around the "%*" - I tried changing that to "%1" but if i do that I get an extra tab called %1.
Affected version
Vim version 7.2 (same behaviour on 7.1)
Windows vista home premium
Thanks for any help.
David.
Try setting it to: "C:\Programs\Vim \vim72\gvim.exe" -p --remote-tab-silent "%1" "%*"
See: http://www.vim.org/tips/tip.php?tip_id=1314
EDIT: As pointed out by Thomas, vim.org tips moved to: http://vim.wikia.com/
See: http://vim.wikia.com/wiki/Add_open-in-tabs_context_menu_for_Windows
You were on the right track:
HKEY-LOCAL-MACHINE\SOFTWARE\Vim\Gvim\path = "C:\Programs\Vim \vim72\gvim.exe" -p
was sufficient ... it works!!
I found the answer... The link to cream gave me some additional areas to search around.
from http://genotrance.wordpress.com/2008/02/04/my-vim-customization/ there is a vim.reg registry file that contains the following
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Edit with Vim]
#=""
[HKEY_CLASSES_ROOT\*\shell\Edit with Vim\command]
#="\"C:\\Programs\\vim\\vim72\\gvim.exe\" -p --remote-tab-silent \"%1\" \"%*\""
[HKEY_CLASSES_ROOT\Applications\gvim.exe\shell\open\command]
#="\"C:\\Programs\\vim\\vim72\\gvim.exe\" -p --remote-tab-silent \"%1\" \"%*\""
this gives me the behaviour I want.
So I guess my original plan of editing the HKEY_LOCAL_MACHINE was just wrong.
Would also be nice to know what exactly what the "%1" and "%*" mean/ refer to.
Now... should I edit my original question, to show that I was starting off in the wrong registry area?
I would recommend trying Cream.
Cream is a set of scripts and add-ons that sit on top of gVim. Cream doesn't change the appearance of gVim, but it does change the way it behaves.
One of those behaviours is a tabbed document interface. Other behaviours are listed here. The downloads page is here.
There is an even cleaner fix using your _vimrc. Add the following line:
autocmd BufReadPost * tab ball
from http://www.vim.org/scripts/script.php?script_id=1720

Resources