Good evening. I'm a Mac user.
I think the Mac is a nice machine, but I'm often addicted to using it without thinking. As the basic Unix environment is complete, especially for Linux users, there are subtle differences and strange behavior. It can be frustrating. In this entry, I'll summarize some of them that I'm addicted to and how to deal with them.
# 6/18 Added about virtualenv
# 6/21 iterm edition added
# 7/17 Added to MacVim edition
In addition, the tools I use
homebrew
iTerm2
vim
zsh
tmux
So, I mainly develop using Python. Also, I will omit the introduction of each tool and so on because there are many other articles.
Googling and hitting the introductory script.
In addition, since you can see options and useful advice for each formula, it may be good to add a habit of brew info
frequently for the introduction package.
~ Homebrew edition finished ~
iTerm seems to be better, so I use iTerm. Please install from the official.
Perhaps you are always launching the CUI.
So ⌘ + w
is an evil keybinding that can cause an outburst and hit the monitor. Let's erase it.
From the menu, open Preference-> Keys
. Add ⌘ + w or ⌘ + q to Global Shortcut Keys to make it ignore.
On the Mac, you can put out incomprehensible symbols by hitting various keys together with Alt. Since the symbols rarely come into play during coding, we will make it possible to use it as a meta key. With this, you of emacser are also safe.
Open the settings you want to use with Preference-> Profiles
.
If you don't understand well, I think you should go to solarized and import the theme for iTerm2.
Then open Keys and set Left option key acts as:
to + Esc.
Let's restart the terminal. I think that it works like deleting a word with alt + d. You did it, did not you?
Since I have been made into a body that can not live without zsh, I will introduce zsh.
However, Apple's standard zsh script under / etc
does something wrong, so you have to do something about it.
You can either rewrite / etc / zshenv
yourself or install it as brew install --disable-etcdir zsh
.
The above details are written carefully as it is with brew info zsh
.
After the installation is completed, please refer to http://tukaikta.blog135.fc2.com/blog-entry-195.html and change the login shell.
Next, let's load the zsh completion functions.
It can be installed with brew install zsh-completions
. Next, set the fpath.
fpath = (
#zsh-completions
/usr/local/share/zsh-completions(N-/)
#homebrew
/usr/local/share/zsh/functions(N-/)
)
export fpath
It looks like the above. If you are interested, use brew --prefix. In old entries etc., completion functions for brew etc. are brought in separately with symbolic links, but now there is a good one in zsh-completions, so it is useless.
The commands that come standard with MacOS seem to be derived from old BSD, and it is very stressful because the options are different and the behavior is strange, so let's replace them.
Let's introduce "openssl", "readline", "git", "coreutils", "gnu-sed", "wget", "gawk", "ctags", "sl".
It's coreutils I wrote above, but if you put it in normally, you'll need to type the command name prefixed with g.
Set PATH and MANPATH by referring to brew info
.
Also, let's give priority to homebrew tools.
BREW_PATH=`/usr/local/bin/brew --prefix`
typeset -U path
path=(
#Something like my own script or something I built myself
$HOME/Dropbox/bin/mac(N-/)
$HOME/Dropbox/bin(N-/)
$HOME/bin(N-/)
#Prioritize the introduction with homebrew
$BREW_PATH/bin(N-/)
##Homebrew puts python and pip at the same time
##It goes into the PATH below, but regarding the command/usr/local/Automatically symbolic link to bin
##It seems that it is no longer necessary to add the following because it has come to be stretched. For more information brew info python
#$BREW_PATH/share/python(N-/)
#The default command is the GNU command
$(brew --prefix coreutils)/libexec/gnubin(N-/)
/usr/bin(N-/)
/bin(N-/)
#sbin
/usr/local/sbin(N-/)
/usr/sbin(N-/)
/sbin(N-/)
)
export path
alias sed='gsed'
Please do the first part as you like. For the time being, prioritizing coreutils should give you the same behavior and options as GNU's. Now the shell script that worked on Linux doesn't work! It won't happen (maybe)
Mac terminal emulators such as iTerm2 do not seem to work well with the clipboard on tmux.
This creates a tragic situation where you are using Vim and with set clipboard = unnamed
enabled, Vim on your device, including MacVim, can't paste at all.
Install reattach-to-user-namespace
from brew to avoid the above.
Next, install the script to start tmux in cooperation with the above tools by referring to https://gist.github.com/elasticdog/1462391.
Finally,"tmux save-buffer - | reattach-to-user-namespace pbcopy"And"reattach-to-user-namespace pbpaste | tmux load-buffer - && tmux paste-buffer" It is also possible to link the tmux register with the clipboard by attaching such an operation to an appropriate binding of tmux.
Speaking of which, there are tmux that seems to be adjusted for iTerm, but I think that homebrew is good because it seems to be meaningless.
Mac standard Python is not good, so let's use brew.
Since I want to use openssl installed by homebrew, explicitly specify brew install python --with-brewed-openssl
.
If you use virtualenv as it is, it will be awkward because the Mac default Python is prioritized.
First, make sure that homebrew's python and pip are prioritized by the PATH setting made in the basic command above.
which python
which pip
Next, put in virtualenv and virtualenvwrapper. I'm a man who uses pip.
After installation, write the following settings in .zprofile.
# --- virtualenv
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages --python=/usr/local/bin/python'
## virtualenv should use Distribute instead of legacy setuptools
#It seems that setuptools has been updated
#export VIRTUALENV_DISTRIBUTE=true
source /usr/local/bin/virtualenvwrapper.sh
#--- pip
# cache pip-installed packages to avoid re-downloading
export PIP_DOWNLOAD_CACHE = $HOME/.pip/cache
Originally, I feel that setting VIRTUALENVWRAPPER_PYTHON
will do the trick, but for some reason I want to use standard python, so I set it explicitly with VIRTUALENVWRAPPER_VIRTUALENV_ARGS
.
By the way, my python combat power is farmer class, so if there is something wrong, please plunge into it.
After writing, let's reload the zsh settings.
You can build it yourself, but I'm not good at it, so I use brew.
brew install vim --override-system-vi --with-lua --with-ruby --with-python --with-python3
Let's leave it as. Of course, lua, ruby and python3 are also introduced first. In particular, lua has been actively introduced recently, so it would be good to include it.
Earlier MacVim had a crashing Python script, but with the latest version it works fine.
Also, put in the best to benefit from ShougoWare's if_lua acceleration.
brew install macvim --with-lua
will do.
Also, it seems that luajit is supported by the standard formula of brew, so if you want to include it, let's use --with-luajit
.
Please refer to this blog for details. Latest patch & if_lua MacVim for fast search & completion!
Also, the binary of MacVim-Kaoriya has been updated with the binary with if_lua, so that may be fine.
I gave it as I wanted, so there may be additions and corrections in the future.
Recommended Posts