This time, I tried to summarize the development tools that I will introduce when building a development environment with Rails as "Development Tools Edition". I hope it will be useful when I have the opportunity to set it up again someday!
The goal is to be able to develop Rails using neovim.
Please also check out the previous App Edition
name | Use |
---|---|
Homebrew | Package manager |
Alfred | Universal launcher app |
White source | font |
iTerm2 | High-performance terminal |
zsh | shell |
prezto | Config framework for zsh |
neovim | editor |
iceberg | theme |
Git | version control |
rbenv | Ruby version control |
Docker | Virtual platform |
Homebrew A package manager that simplifies software deployment on MacOSX systems. You can easily transfer the installed software group to another environment using brewfile. It's convenient because it collects what you need in one place, saving you the trouble of management. Most of the items described below will be introduced using this tool, so it is a good idea to install them first.
** Installation procedure ** As shown in Official site, just execute the following command on the terminal. Start Spotlight Search with Command + Space and type "Terminal" to launch the terminal.
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
You will be asked for a password on the way, so enter the password of the user who is logged in to the Mac.
$ Password:
Also, Homebrew depends on software called "Command line tools for Xcode", and you will be asked to install this software on the way, so please install it.
Complete when the output is as follows. For the time being, use the doctor command to check if the installation was successful.
==> Next steps:
- Run `brew help` to get started
- Further documentation:
https://docs.brew.sh
$ brew doctor
Your system is ready to brew.
Alfred I wanted to list Alfred in the app section, but I've listed it here because it's an app that I definitely want to bring with me in any environment using Homebrew. It works as an app launcher like the standard Mac Spotlight, and has various functions such as calling system functions from shortcuts to edit files in a batch, and having a snippet registration function. If you pay, you can use the above snippet registration function and file operation function, but since it is more convenient and sophisticated than Spotlight, I think there is no loss in introducing it. I haven't mastered it at all, but it seems that productivity will increase considerably, so I would like to learn if I can afford it.
** Installation procedure ** Install using Homebrew. Homebrew basically installs CUI, but you can install GUI by using an extension called homebrew-cask.
Let's enable this extension first. Execute the following command to add cask to Homebrew.
$ brew cask
Originally, it is necessary to enter the name of the application you want to install after cask, and "Error: Invalid usage: No subcommand given." Is output, but cask is added just because the command execution method is strange. please do not worry.
Then install Alfred via cask. Of course, you can skip the above cask installation and have it run.
$ brew cask install Alfred
alfred was successfully installed!
If you want to start with the same Command + Space as Spotlight, after installation, open Mac System Preferences → Keyboard → Shortcuts and disable Spotlight shortcuts. After that, start Alfred and change the shortcut to complete the installation.
I have tried various fonts that are easy to see on the editor, but I personally recommend it because it is the easiest to see and supports Nerd Fonts that outputs icons as fonts on the CUI. It is a very active font because it is highly complete because it customizes Ricty, which is famous as a font for programming, and it is still updated regularly and its visibility is improving steadily. For details, see Author's article.
** Installation procedure ** Install the Homebrew extension for fonts as well as cask, and install the white source fonts through it.
$ brew tap homebrew/cask-fonts
$ brew cask install font-hackgen-nerd
This font will be used in the following items, so we will only introduce it here. If you have a favorite font, you can use it after installing cask-fonts to check if it is handled by Homebrew with the following command.
$brew search font name
iTerm2 A high-performance version of the standard Mac terminal. The editor theme "iceberg" described later was introduced because the terminal does not support full-color output and the colors are not displayed as expected. Looking at the following article, I thought that I could do various things in copy mode without installing tmux.
-Is there a guy who is better at using iTerm than I am?
** Installation procedure ** Install by executing the following.
$ brew cask install iTerm2
This is fine for installation, but when you access a directory such as download, you will be notified whether to give permission to iTerm. If you're curious about this notification as it appears when you access various directories, add iTerm.app to System Preferences → Security & Privacy Full Disk Access.
The color scheme will be set in the iceberg section described later, so here we will set the status bar and font. First, let's create a new profile with the + mark in Preferences → Profile. The name is appropriate. The author named it "iceberg".
Next, open the Text tab and set the Font at the bottom to the "white source" you entered earlier.
Also, since the display position of the status bar is above by default, you can change it to below by selecting Status bar location in Preferences → Appearance.
Go to the Session tab and check Status bar enabled at the bottom.
After that, press the Configure Status Bar button, drag the item you want to display to Active Components, and set the color and font in Advanced. In my case, the background color and the item separator line color are the same as the iceberg background color # 161821, and the font is also white source. (In the case of iMac, the battery display is unnecessary, but if you want to synchronize the settings with the Macbook etc., you may add it.)
After setting, press OK to close. Press Other Actions at the bottom left to set the created profile to the default. It will be reflected when you restart after that.
Also, this profile can be exported as JSON in Other Actions, so it is convenient to remember that you can synchronize the settings by importing it on another PC.
zsh If you are using Catalina, you do not need to install it, but install the latest version with Homebrew and use it.
** Installation procedure ** In the case of Catalina, the login shell is zsh, so look at the location and version of that command.
$ which zsh
/bin/zsh
$ /bin/zsh --version
zsh 5.7.1
Then edit / etc / shells with vim to install zsh via Homebrew and make it the login shell. You will be asked for a password, so enter the password of the logged-in user.
$ brew install zsh
$ sudo vim /etc/shells
Password:
After opening, add "/ usr / local / bin / zsh" to the bottom of the file and change the shell with the following command.
$ chsh -s /usr/local/bin/zsh
If it can be executed, restart the terminal. After starting, check the location and version of zsh again, and if you can confirm the change, it is complete.
$ which zsh
/usr/local/bin/zsh
$ zsh --version
zsh 5.8
prezto If you don't want to mess around with the zshrc file, you can add prezto for some convenience. You can also make the prompt a little more fashionable.
** Installation procedure ** Start the terminal and execute the following.
#Define variables first and decide where to place prezto and where to save the configuration file.
$ ZDOTDIR="~/.config/zsh"
#Clone the prezto body
$ git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
#Generate a configuration file
$ setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done
#Make the shell the default
$ chsh -s /usr/local/bin/zsh
#Generated at ZDOTDIR.Move zshenv to the root directory and edit it.
$ mv ~/.config/zsh/.zshenv ~/.zshenv
$ vim .zshenv
.zshenv
#abridgement
#Configuration file save destination
export ZDOTDIR="$HOME/.config/zsh"
Next, add a useful module to prezto.
$ vim ~/.config/zsh/.zpreztorc
Edit the part around the 32nd line.
.zpreztorc
zstyle ':prezto:load' pmodule ¥
'environment' \
'terminal' \
'editor' \
'history' \
'directory' \
'spectrum' \
'utility' \
'completion' \
'syntax-highlighting' \ #Add this
'autosuggestions' \ #This is also added
'prompt'
Restart the shell and you're done.
neovim Derived editor that extends vim. I wonder if IDE such as Jetbrains, VSCODE and this is the best choice at the moment. To be honest, I have to customize and maintain this and that, so the easiest thing to do is the IDE. However, operating Vim is really easy, isn't it? So, both IDE and VSCODE can enjoy those benefits, but they're not perfect. I think this is a matter of taste.
** Installation procedure ** Execute the following command.
$ brew install nvim
The installation itself is complete, and continue to create the configuration file.
$ mkdir ~/.config/nvim
$ touch ~/.config/nvim/dein.toml
$ touch ~/.config/nvim/dein_lazy.toml
$ touch ~/.config/nvim/init.vim
$ vi ~/.config/nvim/init.vim
After creating it, I will edit various settings, but I introduced dein.vim and summarized the minimum ones below. dein.vim is a plugin manager that manages all the modules that bring extensions to vim. If you rewrite it as follows and start neovim again, it will be installed automatically. You don't have to worry about errors.
init.vim
" dein.vim settings
let s:dein_dir = expand('~/.cache/dein')
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'
" dein installation check
if &runtimepath !~# '/dein.vim'
if !isdirectory(s:dein_repo_dir)
execute '!git clone https://github.com/Shougo/dein.vim' s:dein_repo_dir
endif
execute 'set runtimepath^=' . s:dein_repo_dir
endif
" begin settings
if dein#load_state(s:dein_dir)
call dein#begin(s:dein_dir)
" .toml file
let s:rc_dir = expand('~/.config/nvim')
if !isdirectory(s:rc_dir)
call mkdir(s:rc_dir, 'p')
endif
let s:toml = s:rc_dir . '/dein.toml'
let s:lazytoml = s:rc_dir . '/dein_lazy.toml'
" read toml and cache
call dein#load_toml(s:toml, {'lazy': 0})
call dein#load_toml(s:lazytoml, {'lazy': 1})
" end settings
call dein#end()
call dein#save_state()
endif
" plugin installation check
if dein#check_install()
call dein#install()
endif
" plugin remove check
let s:removed_plugins = dein#check_clean()
if len(s:removed_plugins) > 0
call map(s:removed_plugins, "delete(v:val, 'rf')")
call dein#recache_runtimepath()
endif
filetype plugin indent on
syntax enable
"Change leader key
let mapleader = "\<Space>"
colorscheme iceberg
set termguicolors
set encoding=utf-8
set nrformats=
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
set autoindent
set smartindent
set nobackup
set noswapfile
set clipboard&
set clipboard^=unnamed
set number
set norelativenumber
set title
set nocursorline
set list
set listchars=tab:\|\ ,trail:-,eol:↲,extends:»,precedes:«,nbsp:%
set showmatch
set matchtime=1
set hlsearch
set whichwrap=b,s,<,>,[,]
set tags=./tags;
set completeopt=menuone,noinsert
set viminfo+=n~/.config/nvim/.viminfo
" j,Move display line with k key
nnoremap <silent> k gk
nnoremap <silent> gk k
nnoremap <silent> j gj
nnoremap <silent> gj j
"Wrap back movement
set whichwrap=b,s,<,>,[,]
"Do not insert with Enter in completion
inoremap <expr><CR> pumvisible() ? "<C-e>" : "<CR>"
iceberg There are various themes, but I like the cool and eye-friendly color scheme. Please see Official Site and use it if you like it.
** Installation procedure ** We will introduce it to iTerm2 and neovim respectively. First of all, neovim.
Open dein.toml and add iceberg. Also added dein.vim itself and an airline that makes vim's status bar look good.
vi ~/.config/nvim/dein.toml
dein.toml
[[plugins]]
repo = 'Shougo/dein.vim'
[[plugins]]
repo = 'cocopon/iceberg.vim'
[[plugins]]
repo = 'vim-airline/vim-airline'
After that, when you start neovim, it will be installed automatically.
Next, set up iTerm2. Create an iTerm color setting file with vim and save it as described below.
$ vi iceberg.itermcolors
iceberg.itermcolors
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.12941177189350128</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.094117648899555206</real>
<key>Red Component</key>
<real>0.086274512112140656</real>
</dict>
<key>Ansi 1 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.47058823704719543</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.47058823704719543</real>
<key>Red Component</key>
<real>0.88627451658248901</real>
</dict>
<key>Ansi 10 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.55686277151107788</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.7921568751335144</real>
<key>Red Component</key>
<real>0.75294119119644165</real>
</dict>
<key>Ansi 11 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.5372549295425415</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.69411766529083252</real>
<key>Red Component</key>
<real>0.91372549533843994</real>
</dict>
<key>Ansi 12 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.81960785388946533</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.67450982332229614</real>
<key>Red Component</key>
<real>0.56862747669219971</real>
</dict>
<key>Ansi 13 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.82745099067687988</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.62745100259780884</real>
<key>Red Component</key>
<real>0.67843139171600342</real>
</dict>
<key>Ansi 14 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.80784314870834351</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.76862746477127075</real>
<key>Red Component</key>
<real>0.58431375026702881</real>
</dict>
<key>Ansi 15 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.87058824300765991</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.83137255907058716</real>
<key>Red Component</key>
<real>0.82352942228317261</real>
</dict>
<key>Ansi 2 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.50980395078659058</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.7450980544090271</real>
<key>Red Component</key>
<real>0.70588237047195435</real>
</dict>
<key>Ansi 3 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.47058823704719543</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.64313727617263794</real>
<key>Red Component</key>
<real>0.88627451658248901</real>
</dict>
<key>Ansi 4 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.7764706015586853</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.62745100259780884</real>
<key>Red Component</key>
<real>0.51764708757400513</real>
</dict>
<key>Ansi 5 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.78039216995239258</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.57647061347961426</real>
<key>Red Component</key>
<real>0.62745100259780884</real>
</dict>
<key>Ansi 6 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.7607843279838562</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.72156864404678345</real>
<key>Red Component</key>
<real>0.5372549295425415</real>
</dict>
<key>Ansi 7 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.81960785388946533</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.78431373834609985</real>
<key>Red Component</key>
<real>0.7764706015586853</real>
</dict>
<key>Ansi 8 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.5372549295425415</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.43921568989753723</real>
<key>Red Component</key>
<real>0.41960784792900085</real>
</dict>
<key>Ansi 9 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.5372549295425415</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.5372549295425415</real>
<key>Red Component</key>
<real>0.91372549533843994</real>
</dict>
<key>Background Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.12941177189350128</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.094117648899555206</real>
<key>Red Component</key>
<real>0.086274512112140656</real>
</dict>
<key>Badge Color</key>
<dict>
<key>Alpha Component</key>
<real>0.5</real>
<key>Blue Component</key>
<real>0.0</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.1491314172744751</real>
<key>Red Component</key>
<real>1</real>
</dict>
<key>Bold Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.87843137979507446</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.70980393886566162</real>
<key>Red Component</key>
<real>0.54901963472366333</real>
</dict>
<key>Cursor Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.81960785388946533</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.78431373834609985</real>
<key>Red Component</key>
<real>0.7764706015586853</real>
</dict>
<key>Cursor Guide Color</key>
<dict>
<key>Alpha Component</key>
<real>0.25</real>
<key>Blue Component</key>
<real>1</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.9268307089805603</real>
<key>Red Component</key>
<real>0.70213186740875244</real>
</dict>
<key>Cursor Text Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>1</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>1</real>
<key>Red Component</key>
<real>0.99607843160629272</real>
</dict>
<key>Foreground Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.81960785388946533</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.78431373834609985</real>
<key>Red Component</key>
<real>0.7764706015586853</real>
</dict>
<key>Link Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.73423302173614502</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.35916060209274292</real>
<key>Red Component</key>
<real>0.0</real>
</dict>
<key>Selected Text Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.81960785388946533</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.78431373834609985</real>
<key>Red Component</key>
<real>0.7764706015586853</real>
</dict>
<key>Selection Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.25882354378700256</real>
<key>Color Space</key>
<string>sRGB</string>
<key>Green Component</key>
<real>0.17254902422428131</real>
<key>Red Component</key>
<real>0.15294118225574493</real>
</dict>
</dict>
</plist>
It is applied when this file is imported by selecting Preferences-> Profile-> Color Presets of iTerm.
Git A version control system that can track change history such as source code.
** Installation procedure ** Install via Homebrew. First, check the original version of git and install it with Homebrew.
$ git --version
git version 2.24.3(Apple git-128)
$ brew install git
If it is left as it is, git that is originally in the Mac will be used, so pass it through the path.
$ vim ~/.config/zsh/.zshrc
.zshrc
export PATH="/usr/local/bin/git:$PATH"
If you restart the terminal once and the version of git has changed, it is successful.
$ git --version
git version 2.29.1
rbenv You can easily switch and manage Ruby versions. There is no loss if you put it in for the time being.
** Installation procedure ** Install with Homebrew.
$ brew install rbenv
$ rbenv -v
1.1.2
Then pass the path. Also, specify the location of the directory where shims and versions of rbenv are located in the RBENV_ROOT variable. The last rbenv init is mandatory.
$ vim ~/.config/zsh/.zshrc
.zshrc
export RBENV_ROOT="~/.local/share/rbenv"
export PATH="$RBENV_ROOT/bin:$PATH"
eval "$(rbenv init -)"
Then install Ruby through this rbenv.
#You can see the list of Ruby versions that can be installed with the following command
$ rbenv install -l
#After deciding the version, install it
$ rbenv install 2.7.2
#Make the installed version executable
$ rbenv global 2.7.2
#Execute the following command, and if the specified version has an asterisk, k
$ rbenv versions
system
* 2.7.2
Docker A tool that provides a platform for developing in a virtual environment.
** Installation procedure ** Download and install Docker for Mac from below. Official site
Eventually it will look like this.
Please refer to the following article for how to actually create a virtual environment using Docker.
I've omitted other Vim plugins and detailed settings, but this includes personal preferences, so you may want to try various settings. I'm still trying it out, so I'd like to write an article when it's ready.
Until the end Thank you for reading!
Recommended Posts