Does 'meld' have a command-line style? - meld

Does meld support automatic merging ability, like 'kdiff3' does?
With kdiff3, you can do:
kdiff3 file1 file2 -o outfile
and do not have to open the GUI.
So can you do such with meld? I didn't find related topic in meld manual.
Thanks!

I don't think so. You can use
meld file1 file2 --output=file3
to set the target file for saving a merge result, but it will still open the GUI (meld is after all a visual differ)

Related

How to print from Git Bash terminal?

While using git bash terminal, I can't print a pdf file. In fact I can't print anything. I am using correct file name and I've tried typing:
lp file.pdf
but I get bash:
lp: command not found
I get same promt when trying to print anything using lp command.
How do you print from git bash terminal?
Git bash is an emulated bash. The standard programs available on most Linux distributions are not available there.
Windows programs are available. You can run them, but you'll have to make sure all the details are set up, and sometimes they don't like the environment.
For example, both notepad and wordpad (write) should be able to use the /p and/or /pt options, but you may have trouble getting it to find the file.
write tst
will open the file in wordpad, and
write /p tst
is supposed to print it, assumedly to the default printer, though my config seems admin-locked to something stupid.
Maybe that will help. Good luck.

Textmate tutorial terminal mac-osx

I have installed Textmate editor on my terminal and I am looking for some tutorial to discover Textmate's command lines ? Does anyone has a some links ?
Best,
Newben
The textmate bin that is optionally installed for command line access is really nothing but a simple manner to open files in the OSX gui application.
That said, there are a few handy shortcuts. -w issues a "wait" while opening the file, thus following commands in a sequence will wait until the document is closed to execute. For example:
alias bashrc="mate -w ~/.bashrc; source ~/.bashrc"
That said, if you are looking for a good command set for using within the gui itself, let me know and I will fill in a list of handy commands (it has been my default editor for 6 years now).
Edit: Here are the beginnings of my TextMate docs. I currently have the Cheat Sheet in a state that should prove useful. I will be adding to it and writing up some more extensive docs in the near future.
TextMate Cheat Sheet
You can invoke it from the command line with:
mate path/to/file/you/want/to/edit.txt
You can use more than one file, space separated. To see more options do:
mate --help
This if you installed the commandline option. which you can also do from preferences at any time (its just a symlink)

Vim: Mac vs. Linux ^M Problem

I use Vim and GIT to develop my project on a Linux/Ubuntu machine. In the past, I used to use Windows, which means line ends were DOS format. Now after moving to Linux, I always see ^M confusing/annoying characters at the end of the line. Some people here:
How to convert the ^M linebreak to 'normal' linebreak in a file opened in vim?
suggested that I should make a find/replace or use tools like dos2unix. These are good suggestions, but with a version-controlled project it means I have to add unnecessary commits for the files after change, and it is a big task anyway that is not worth spending time on it. So:
Is there anyway to make Vim tolerant for this? That is, if the file is DOS line-ended, it keeps it like this, and use its formatting for new newlines, and so on.
I have added this line to my .vimrc file.
set fileformats=unix,mac,dos
If you don't know what a vimrc file is, it's simply the file that configure (and allows you to customize) your vim. By default vim will be looking for a file called .vimrc (notice the dot at the beginning) in the user's home folder. If it cannot find it, it will source it from /etc/vimrc.
Yes, you can set the following in vim to say it's a dos format file:
:set ff=dos
And, likewise:
:set ff=unix
The best answer I found is #Keith answer in the comments:
"With subversion you can set a property svn:eol-style=native that will cause it to convert line endings to.. native type for all platforms automatically. I don't know if git has that feature, but you might look into that first. It probably does."
And these links might be useful link is how to set:
http://help.github.com/dealing-with-lineendings/
http://git-scm.com/docs/gitattributes

How to set Araxis as diff / merge tool for MSYS git?

I'm trying to use Araxis Merge as my diff / merge tool for MSYSGit.
I found a few resources on the net:
On the Araxis site, they mention an "easy" way, but it implies a executables (araxisgitdiff.exe and araxisgitmerge.exe) that are not part of my distro.
I also found some info in gitguru, but the actual information re: Araxis is sparse at best, and I could not make anything out of that.
Finally, there was some info on an older stackoverflow post, but the suggested method doesn't work for me. That particular info was geared towards OS X. I "translated" to Windows as best as I could, but without success:
I created /bin/git-diff-driver.sh
#!/bin/sh
"/c/Program Files/Araxis/Araxis Merge/compare.exe" -title1:"$1 (repo version)" -title2:"$1 " -max "$2" "$5"
and edited gitconfig
[merge]
tool = araxismerge
[mergetool "araxismerge"]
cmd = "/c/Program Files/Araxis/Araxis Merge/compare.exe" -3 -merge -wait $LOCAL $BASE $REMOTE $MERGED
[diff]
external = "/bin/git-diff-driver.sh"
and the only result I get is:
$ git diff HEAD^ HEAD
external diff died, stopping at PowerEditor/src/Notepad_plus.cpp.
Edit:
I've also tried with the exe named as "c:/Program Files/Araxis/Araxis Merge/compare.exe" as suggested by one of the answers, with the same results.
Edit:
I've found that it can easily be set if you use TortoiseGit, but it seems to handle diff by itself and no settings from TortoiseGit give any indication on how to set up Araxis as a merge tool when diff is invoked from the command line.
Edit:
So, the question is: Is there anybody who successfully uses Araxis Merge to diff and merge stuff with MSYSGit, and if so, how do you it?
If you want to have 'git diff' always use araxis you can use the instructions in the help file, but if you want to have control to use 'git diff' as you normally would from the command line and 'git difftool' to engage the Araxis GUI.
Try adding the following to your git config::
[difftool "araxis"]
path = "/c/Program Files/Araxis/Araxis Merge/compare.exe"
renames = true
trustExitCode = true
[diff]
tool = araxis
stat = true
[mergetool "araxismergetool"]
cmd = 'C:\\Program Files\\Araxis\\Araxis Merge\\araxisgitmerge.exe' "$REMOTE" "$BASE" "$PWD/$LOCAL" "$PWD/$MERGED"
trustExitCode = false
[mergetool]
keepBackup = false
[merge]
tool = araxismergetool
stat = true
The documentation at araxis has been updated: http://www.araxis.com/merge/documentation-windows/integrating-with-other-applications#Git
I can use the configuration shown there without any modifications.
Right... I got it working, with msysgit version 1.6.3.2.1299.gee46c, under DOS or Git Bash, with an evaluation license for Araxis Merge 2009, v2009.3713:
The approach is to use the new git difftool and git mergetool, instead of plain diff.
First, let's setup some scripts for those diff and merge tool
C:\>git config --global diff.tool adifftool
C:\>git config --global diff.external git-difftool--helper
C:\>git config --global difftool.adifftool.cmd "difftool.sh \"$LOCAL\" \"$REMOTE\" \"$MERGED\""
C:\>git config --global difftool.prompt false
Notes:
by setting diff.external to the Git script git-difftool--helper, I will use difftool even when I will type 'git diff'.
do not forget to pass $MERGED to your difftool script: that is the only variable with the real name of the file being diff'ed. $LOCAL and $REMOTE are temporary names.
For the merge tool, you would set the following global values:
C:\>git config --global merge.tool amergetool
C:\>git config --global mergetool.amergetool.cmd "mergetool.sh \"$PWD/$LOCAL\" \"$PWD/$BASE\" \"$PWD/$REMOTE\" \"$PWD/$MERGED\""
C:\>git config --global mergetool.prompt false
By setting those tools to some shell scripts, you will be able to switch tools from within those scripts.
Another approach is to name your tools (mergetool.araxis.cmd, mergetool.winmerge.cmd, ...) and to specify the right tool in the diff.tool or merge.tool setting.
Create difftool.sh and mergetool.sh in a directory referenced by your global environment variable PATH. They will work even from DOS (and they are sh -- shell -- scripts)
difftool.sh
#!/bin/sh
echo Launching Araxis Merge.exe: $3
t1="'$3 (from)'"
t2="'(to)'"
"C:/Program Files/Araxis/Araxis Merge/Compare.exe" -max -nowait -2 -title1:${t1} -title2:${t2} "$1" "$2"
Notes:
Impossible to have -title1:"someTitle With Space"... only title without space does work..., so for now, try it without any 'titleN' option.
Got it! You cannot pass the title value directly to the -title option, you need to set it to a local variable, with "' '" quotes combinations (the double quotes will disappear during the shell script execution, leaving the simple quotes, allowing spaces within a title!)
$3 represent the real name and not some temporary file name for diff purpose. Hence the use of $3 within the title1 option, with space in it.
git diff HEAD^ HEAD would not work in DOS session: only git diff "HEAD^" HEAD would.
mergetool.sh
#!/bin/sh
# Passing the following parameters to mergetool:
# local base remote merge_result
alocal=$1
base=$2
remote=$3
result=$4
t1="'$4 (current branch)'"
t2="'(common ancestor)'"
t3="'(to be merged)'"
if [ -f $base ]
then
"C:/Program Files/Araxis/Araxis Merge/Compare.exe" -max -wait -merge -3 -a2 -title1:${t1} -title2:${t2} -title3:${t3} "$alocal" "$base" "$remote" "$result"
else
"C:/Program Files/Araxis/Araxis Merge/Compare.exe" -max -wait -merge -3 -a2 -title1:${t1} -title2:${t2} -title3:${t3} "$alocal" "$result" "$remote" "$result"
fi
I am not sure I those scripts do work properly when multiple files are involved (multiple diffs, multiple files to be merged).
Just tested it: it works, and Araxis compare.exe does open one tab per file to diff or merge.
Give it a try and let us know ;)
I think that you need to be a bit more careful with your escaping in your .gitconfig.
Unfortunately, due to the way the config variable is expanded and evaled, your string needs to be an valid shell command which is then 'git config' escaped.
Try something like this:
[mergetool "araxismerge"]
cmd = \"/c/Program Files/Araxis/Araxis Merge/compare.exe\" -3 -merge -wait \"$LOCAL\" \"$BASE\" \"$REMOTE\" \"$MERGED\"
Yes, not very pretty, I know. It's one of the cases where using git config directly is actually easier.
git config --global mergetool.araxismerge.cmd '"/c/Program Files/Araxis/Araxis Merge/compare.exe" -3 -merge -wait "$LOCAL" "$BASE" "$REMOTE" "$MERGED"'
I struggled with this problem for quite a while, and now I finally can say, that all suggested dirty hacks (like intermediate shell scripts) are rather unnecessary =D. Thing is, all of the latest versions of MSYSGit (I have 1.6.4) support Araxis Merge (I have 2008) out of the box. It comes at no surprise, that internally it's called "araxis". So, all that you need is to set
[merge]
tool = araxis
in your .gitconfig. Also you have to include Araxis folder into your PATH environment variable (MSYSGit looks for Compare.exe).
For a good measure, other Git settings related to "araxis" mergetool, that you could have configured (especially, if you happen to choose exactly that name, as did some people on this page), should all be removed. That includes everything under [mergetool "araxis"] section. Be sure to remove them from all configs (system, global, and repository), otherwise, they might interfere with normal "internal tool" behavior.
In any case, if you're interested in how MSYSGit will start your Araxis Merge, or wondering what other mergetools it supports out of the box, the place to look is \share\git-gui\lib\mergetool.tcl script in your MSYSGit installation folder.
PS. You might be able to avoid setting PATH environment variable, by configuring mergetool.araxis.path in .gitconfig. Personally, I never bothered to do so, since
I use Araxis Merge from command line anyway.
Specifying directory path in .gitconfig (especially the one like "C:\Program Files\Araxis\Araxis Merge\", which contains spaces) can prove hard to be done correctly, since it is prone to backslash/forwardslash issues, that plague MSYSGit.
PPS. All of the above applies to making Araxis your difftool, too. I.e, you need to add
[diff]
tool = araxis
and remove anything else in [difftool "araxis"] section, if you have it in your config (don't forget to set up PATH, though).
You could try to follow the script mentioned in my answer about diffMerge (for Windows) and see if it works.
The executable path could be better expressed with:
#!/bin/sh
"C:/Program Files/Araxis/Araxis Merge/compare.exe" -title1:"$1 (repo version)" -title2:"$1 " -max "$2" "$5"
One way I found to do it "simply" is to install TortoiseGit and set the diff / merge tools in TortoiseGit options.
However, this does not address the issue if you want to diff from the command line.
Since I've been bitten to customised git differs/mergers, I thought I would try to fix this one for once and for all. I got to the point where AraxisMerge started, but without the titles of the tabs. So that will be left as an exercise for the reader :)
Observations and comments:
I didn't have AraxisMerge, so I downloaded it and got a free 30-days evaluation license to try it out with. This version (7.0 it seems) comes with araxisgitdiff.exe, and the link with instructions you send works. So that would be option #1: upgrade araxis merge.
Since I'm working from CMD.EXE, 'git diff HEAD HEAD^' does not work. The '^' needs to be escaped to 'git diff HEAD "HEAD^"'.
For my own work I use kdiff3 as a free replacement on Windows which works reasonably well (it helps that it is supported by default by git)
Starting with the git-diff-driver.sh gave the same error to me. After changing the script to only contain 'echo', this did not change. So the error is independent from the contents of the script.
Then I removed the '/bin' part from .gitconfig, so the line becomes
external = "git-diff-driver.sh"
...and this started to work: it started the merger, but it does not escape the '(repo) ' part correctly. As a workaround I got it working without the titles with:
#!/bin/sh
"/c/Program Files/Araxis/Araxis Merge/compare.exe" -max "$2" "$5"
Good luck!

How do I print the source code of a bash script (on paper)?

I need to print some Bash script on paper. Any recommendations on how to get a nice output with syntax highlighting and all that?
I've tried TextMate, but the output had huge fonts (and no syntax highlighting, no colors).
You can use gvim to convert the script to colorized html. (Open script in gvim then select 'Syntax' menu then 'Convert to html'). Then you can print that html using firefox.
I use enscript. It's a command line tool for formatting text for printing. It includes support for bash syntax highlighting. It is easy to configure for line numbering and row highlighting.
Generally I tell it to print to a file so I can look at it in Preview and tweak any options.
You can pull it out of MacPorts if you don't have it already.
I ended up using Bundles > TextMate > Create HTML in TextMate and then printing the HTML.
I usually prefer enscript, and these are my favorite options:
enscript -2rG -Ebash <filename> -P<printername>
-2 -> print two pages per sheet
-r -> rotate 90ยบ
-G -> fancy headers
-Ebash -> syntax highlight per bash
If you are tired of writing this all the time, you can write an alias or put it in a makefile.
Komodo Edit is free, works in Linux, OSX and Windows, does great job highlighting many different formats.

Resources