How to open a tex file in Texmaker from terminal in MacOS? - macos

In Ubuntu I could simply run from the terminal:
texmaker file.tex
which opened my tex file in Texmaker. In MacOS, the texmaker command is not found, even though I have Texmaker installed.
How can I achieve this in MacOS? Is there an equivalent command?

If you mean this then you can install it with homebrew using this command:
brew cask install texmaker

Once Texmaker is installed, you can add:
alias texmaker="open -a texmaker"
to your .profile. From now on, it should be possible to simply run from the command line:
texmaker file.tex
at the location where the file.tex is.

Related

How to use macvim (mvim) in terminal after install with homebrew

I installed macvim with homebrew and when i tip "mvim file" in terminal open the file in another window. Can I fix and open mvim in terminal?
The binary is needed by some plugins (YouCompleteMe), for one.
You can use the binary that is installed with macvim. By default, it's
/usr/local/Cellar/macvim/8.0-144_3/MacVim.app/Contents/MacOS/Vim
You can simply alias vim to it in your shell config (.bashrc, .zshrc, etc.)
alias vim=/usr/local/Cellar/macvim/8.0-144_3/MacVim.app/Contents/MacOS/Vim
MacVim (mvim) is not a terminal application. If you want to open vim in a terminal, just use "vim" instead.
We want the contents of the MacVim.app package to be in the PATH, but do this cleanly. So here's what I do:
cd /Applications; ln -s ../usr/local/Cellar/macvim/8.1-151_1/MacVim.app
That gets you MacVim in /Applications, via a symlink that can be updated when the package is upgraded. Then add this to the PATH in the shell startup file:
PATH=/Applications/MacVim.app/Contents/bin:$PATH
Then when you upgrade you just change the symlink in /Applications and everything still works nicely.

Installing vim with homebrew assistance

I tried to install YouCompleteMe on Mac for vim, but I've been using the system vim which is version 7.3. I tried to update my vim using homebrew by typing brew install vim and everything seemed to be fine.
When I type vim I still see the system vim loading (version 7.3).
I feel like I'm missing a step that's keeping me from using the updated vim I got from homebrew. Does anyone know what I'm missing?
For reference when I type which vim I get the following output /usr/bin/vim. Any help would be greatly appreciated.
Just install vim via homebrew:
brew install vim
Then restart your shell:
exec -l $SHELL
And check the version:
$ vim --version|head -n 1
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 9 2016 19:07:39)
You should probably have done brew install vim --with-override-system-vi. This will replace default vim path.
You're loading your system vim first, as you can see by which vim returning /usr/bin/vim instead of /usr/local/bin/vim.
/usr/local/bin is homebrew's path.
Make sure that your path lists /usr/local/bin before /usr/bin:
/usr/local/bin:/usr/bin
This will allow homebrew's vim to be sourced before the system vim.
To view your path:
echo "$PATH"
Rather than reinstalling vim you can move your current vim to vim73 (or something similar).
First check if /usr/local/bin is present in PATH environment variable. Doing echo $PATH on your terminal should do that.
Install vim with homebrew if you haven't already.
brew install vim
Then move your current vim installation.
mv /usr/bin/vim /usr/bin/vim73
Run which vim to confirm. It should say /usr/local/bin/vim.
brew install vim --with-override-system-vi (missing the with-)
echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bash_profile
source ~/.bash_profile
Run this command and it will be fixed.

Install libSVM on Mac OSX and use easy.py and grid.py

I spent quite some time figuring out how to install libSVM on Mac OSX and use easy.py and grid.py. I've done quite some research but there are problems such as gnuplot isn't installed in the place where easy.py is calling it with brew.
It turned out I have to do the following steps
go to https://www.dropbox.com/s/rpn6yersv06tttz/gnuplot-4.2.5-i386.dmg
download the gnuplot-4.2.5-i386.dmg
open the resulting DMG file
open the gnuplot-4.2.3 DMG the Extras folder
drop Gnuplot.app into your applications folder
go to /usr/bin in terminal and do
$ sudo ln -sf "/Applications/Gnuplot.app/Contents/Resources/bin/
gnuplot"
You will be prompted to install X11 if you haven't done so, but after that if you run sample line like
python easy.py svmguide1 svmguide1.t
it should work. The sample files can be downloaded at http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary.html#svmguide1
references: http://www.csie.ntu.edu.tw/~cjlin/papers/guide/guide.pdf
Make sure Homebrew is installed, then just run:
brew install gnuplot
Link the executable, so that it is in the PATH (i.e. /usr/bin) and can be found by the Python scripts:
sudo ln -s /opt/local/bin/gnuplot /usr/bin/gnuplot
After that's done, libsvm's Python scripts should not complain any longer.
Since macOS high sierra, /usr/bin is not modifyable by the user anymore, gnuplot is installed at /usr/local/bin instead. Open easy.py and change the path from "/usr/bin" to "/usr/local/bin"

Update OSX Vim using MacVim

I'm trying to update Vim (for use in Terminal) on my Mac. It's currently running version 7.3, but YouCompleteMe requires Vim 7.3.584, and won't run even though it's installed.
I've tried using a Vim alias in my .bash_profile:
alias vim='/Users/Conor/Applications/MacVim.app/Contents/MacOS/Vim'
However none of my Vim plugins are launched when I run Vim like this, any my vimrc file isn't recognised either.
How can I get this alias to recognise my existing Vim settings? Or is there a better way of upgrading Vim for mac?
The *.tbz that you downloaded from the official page contains a mvim script.
Once you have moved that script somewhere in your $PATH you can start the MacVim GUI like this:
$ mvim filename
and the MacVim CLI like that:
$ mvim -v filename
From there the only thing you need is to change your alias to point to mvim:
alias vim='mvim -v'
The original built-in Vim and its runtime files stay untouched, MacVim uses its own runtime files located in the MacVim.app bundle and both honor your personal config (assuming they are located where they should be: ~/.vimrc and ~/.vim/).
Quick, clean and painless.
If you installed MacVim with HomeBrew you can use
brew install macvim --override-system-vim
If you just want pure vim with python support do:
brew install vim --override-system-vim --HEAD
I had the same issue as you, but this worked like a charm. You complete me works perfectly after this.

How to run mvim (MacVim) from Terminal?

I have MacVim installed and I am trying to set it up as the editor for Git (version control), but I can't run 'mvim' from the command line as it isn't recognised. How do I setup mvim so I can run it from Terminal?
I don't think I'd to add anything to the path, did
brew install macvim
mvim -v
should then open macvim in the terminal, you can also go ahead and alias that
alias vim='mvim -v'
There should be a script named mvim in the root of the .bz2 file. Copy this somewhere into your $PATH ( /usr/local/bin would be good ) and you should be sorted.
If you go the brew route, the best way to install would be:
brew install macvim --with-override-system-vim
That will provide mvim, vim, vi, view, etc. in /usr/local/bin (all symlinked to the copy in the Cellar). This also removes the need to create any aliases and also changes your vi, vim, etc. to all use the same Vim distribution as your MacVim.
In addition, if you want to use MacVim (or GVim) as $VISUAL or $EDITOR, you should be aware that by default MacVim will fork a new process from the parent, resulting in the MacVim return value not reaching the parent process. This may confuse other applications, but Git seems to check the status of a temporary commit message file, which bypasses this limitation. In general, it is a good practice to export VISUAL='mvim -f' to ensure MacVim will not fork a new process when called, which should give you what you want when using it with your shell environment.
If you already have macVim installed: /Applications/MacVim.app/Contents/MacOS/Vim -g will give you macVim GUI.
just add an alias.
i use gvim because that is what i use on linux for gnome-vim.
alias gvim='/Applications/MacVim.app/Contents/MacOS/Vim -g'
Assume MacVim is installed in the Application folder.
Instead of adding MacVim path to your environment, create a link by typing this in terminal:
sudo ln -s /Applications/MacVim.app/Contents/bin/mvim /usr/local/bin/mvim
Then, open a new terminal window/tab and type mvim.
If you have homeBrew installed, this is all you have to do:
brew install macvim
brew linkapps
Then type mvim in your terminal to run MacVim.
Here's what I did:
After building Macvim I copied mvim to one of my $PATH destinations (In this case I chose /usr/local/bin)
cp -v [MacVim_source_folder]/src/MacVim/mvim /usr/local/bin
Then when you invoke mvim it is now recognised but there is an annoying thing. It opens the visual MacVim window, not the one in terminal. To do that, you have to invoke
mvim -v
To make sure every time you call mvim you don't have to remember to add the '-v' you can create an alias:
alias mvim='mvim -v'
However, this alias will only persist for this session of the Terminal. To have this alias executed every time you open a Terminal window, you have to include it in your .profile
The .profile should be in your home directory. If it's not, create it.
cd ~
mvim -v .profile
include the alias command in there and save it.
That's it.
I'm adding Bard Park's comment here for that was the real answer for me:
Since mvim is simply a shell script, you can download it directly from the MacVim source at GitHub here: http://raw.github.com/b4winckler/macvim/master/src/MacVim/mvim
I'd seriously recommend installing MacVim via MacPorts (sudo port install MacVim).
When installed, MacPorts automatically updates your profile to include /opt/local/bin in your path, and so when mvim is installed as /opt/local/bin/mvim during the install of MacVim you'll find it ready to use straight away.
When you install the MacVim port the MacVim.app bundle is installed in /Applications/MacPorts for you too.
A good thing about going the MacPorts route is that you'll also be able to install git too (sudo port install git-core) and many many other ports. Highly recommended.
This works for me:
λ brew link --overwrite macvim
Linking /usr/local/Cellar/macvim/8.0-146_1... 12 symlinks created
For Mac .app bundles, you should install them via cask, if available, as using symlinks can cause issues. You may even get the following warning if you brew linkapps:
Unfortunately brew linkapps cannot behave nicely with e.g. Spotlight using
either aliases or symlinks and Homebrew formulae do not build "proper" .app
bundles that can be relocated. Instead, please consider using brew cask and
migrate formulae using .apps to casks.
For MacVim, you can install with:
brew cask install macvim
You should then be able to launch MacVim like you do any other macOS app, including mvim or open -a MacVim from a terminal session.
UPDATE: A bit of clarification about brew and brew cask. In a nutshell, brew handles software at the unix level, whereas brew cask extends the functionality of brew into the macOS domain for additional functionality such as handling the location of macOS app bundles. Remember that brew is also implemented on Linux so it makes sense to have this division. There are other resources that explain the difference in more detail, such as What is the difference between brew and brew cask?
so I won't say much more here.

Resources