A.5. Mac

You need a real package manager (not XCode) before you can install all the tools you need to keep up with other developers.

A.5.1. A Mac package manager

Homebrew (https://brew.sh) is probably the most popular command-line package manager for Macs among developers. It’s easy to install and contains one-step installation packages for most tools that developers use. It’s equivalent to Ubuntu’s apt package manager. Apple could’ve ensured their OS would play nice with apt, but they didn’t want developers to bypass their XCode and App Store “funnels,” for obvious monetization reasons. So some intrepid Ruby developers homebrewed their own package manager.[2] And it’s almost as good as apt or any other OS-specific binary package manager. See the following listing.

2

See the Homebrew package manager Wikipedia article (https://en.wikipedia.org/wiki/Homebrew_(package_management_software)).

Listing A.4. Install brew
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/
     install/master/install)"

You’ll be asked to confirm things with the Return key and also enter your root/sudo password. So don’t walk away to brew your coffee until you’ve entered your password and the installation script is happily chugging along.

A.5.2. Some packages

Once brew is installed, you may want to install some Linux tools that are handy to have around, as shown in the following listing.

Listing A.5. Install developer tools
$ brew install wget htop tree pandoc asciidoctor

A.5.3. Tuneups

If you are serious about NLP and software development, you’ll want to make sure you have your OS tuned up so you can get stuff done. Here’s what we install whenever we create a new user account on a Mac:

If you want to share screenshots with other NLP developers you’ll need a screen grabber such as Snappy. And a clipboard manager, such as CopyClip, lets you copy and paste more than one thing at a time and persist your clipboard history between reboots. A clipboard manager gives you the power of console history search ([ctrl]-[R]) in your GUI copy and paste world.

And you should also increase your bash shell history, add some safer rm -f aliases, set your default editor, create colorful text, and add open commands for your browser, text editor, and merge tool, as shown in the following listing.

Listing A.6. bash_profile
#!/usr/bin/env bash
echo "Running customized ~/.bash_profile script: '$0' ......."
export HISTFILESIZE=10000000
export HISTSIZE=10000000
#  append the history file after each session
shopt -s histappend
#  allow failed commands to be re-edited with Ctrl-R
shopt -s histreedit
#  command substitions are first presented to user before execution
shopt -s histverify
# store multiline commands in a single history entry
shopt -s cmdhist
# check the window size after each command and, if necessary, update the valu
     es of LINES and COLUMNS
shopt -s checkwinsize
# grep results are colorized
export GREP_OPTIONS='--color=always'
# grep matches are bold purple (magenta)
export GREP_COLOR='1;35;40'
# record everything you ever do at the shell in a file that won't be unintent
     ionally cleared or truncated by the OS
export PROMPT_COMMAND='echo "# cd $PWD" >> ~/
     .bash_history_forever; '$PROMPT_COMMAND
export PROMPT_COMMAND="history -a; history -c; history -r; history 1 >> ~/
     .bash_history_forever; $PROMPT_COMMAND"
# so it doesn't get changed again
readonly PROMPT_COMMAND
# USAGE: subl http://google.com  # opens in a new tab
if [ ! -f /usr/local/bin/firefox ]; then
    ln -s /Applications/Firefox.app/Contents/MacOS/firefox /usr/local/bin/
     firefox
fi
alias firefox='open -a Firefox'
# USAGE: subl file.py
if [ ! -f /usr/local/bin/subl ]; then
    ln -s /Applications/Sublime Text.app/Contents/SharedSupport/bin/subl /
     usr/local/bin/subl
fi
# USAGE: meld file1 file2 file3
if [ ! -f /usr/local/bin/meld ]; then
    ln -s /Applications/Meld.app/Contents/MacOS/Meld /usr/local/bin/meld
fi
export VISUAL='subl -w'
export EDITOR="$VISUAL"
# you can use - f to override these interactive nags for destructive disk writes
alias rm="rm -i"
alias mv="mv -i"
alias ..="cd .."
alias ...="cd ../.."

You can find other bash_profile scripts with a GitHubGist search (https://gist.github.com/search?q=%22.bash_profile%22+mac).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset