Skip to content

Instantly share code, notes, and snippets.

@diogorusso
Last active November 30, 2022 18:07
Show Gist options
  • Save diogorusso/47756a7a474f7236332d11eabe9ac5ae to your computer and use it in GitHub Desktop.
Save diogorusso/47756a7a474f7236332d11eabe9ac5ae to your computer and use it in GitHub Desktop.
Checking and Installing Xcode Command Line Tools

MacOS dev env setup

  • X-Code command line + .bash_profile
  • Homebrew + Brewfile
  • GIT + Github
  • Ruby + RVM + Bundler
  • mySQL
  • Python + Pyenv + Pyenv-Virtualenvwrapper
  • Node + NPM + Yarn + N + NCU
  • Webpack , Gulp

X-Code Command Line tools

The Command Line Tools Package is a small self-contained package available for download separately from Xcode and that allows you to do command line development in macOS. It consists of the macOS SDK and command-line tools such as Clang, which are installed in the /Library/Developer/CommandLineTools directory.

What's GCC

Short for GNU Compiler Collection, GCC is a collection of programming compilers including C, C++, Objective-C, Fortran, Java, and Ada. Once installed, a basic C file, like the one shown on our C language overview, can be compiled by running the below command.

Shell Bash

Bash is a command processor that typically runs in a text window, where the user types commands that cause actions. Bash can also read and execute commands from a file, called a script. Like all Unix shells, it supports filename globbing (wildcard matching), piping, here documents, command substitution, variables, and control structures for condition-testing and iteration.

.bash_profile

bash_profile is a configuration file for bash shell. When bash is invoked as an interactive login shell it first reads and executes commands from ~/.bash_profile.

bashrc

.bashrc is a shell script that Bash runs whenever it is started interactively. It initializes an interactive shell session. You can put any command in that file that you could type at the command prompt.

# who are you?
whoami
#check if Xcode package is installed
#if installed it will display : /Applications/Xcode.app/Contents/Developer
xcode-select -p
# install Xcode command line form terminal
xcode-select --install
#verify successfull installation
xcode-select -p
#verify if GCC is installed
gcc --version
#create .bash_profile
cd ~/
touch .bash_profile
#show/hide hidden files
defaults write com.apple.finder AppleShowAllFiles YES
defaults write com.apple.finder AppleShowAllFiles FALSE
#show library
chflags nohidden ~/Library
#sudo scutil –-set HostName new_hostname
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function
# Git branch in prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
# Show / Hide Hidden Files.
alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'
#Colorize the ls output
alias ls='ls -G'
# Custom Alias
# alias customAlias='print hello alias'

HomeBrew Package Manager

Homebrew installs the stuff you need that Apple didn't. Homebrew installs packages to their own directory and then symlinks their files into /usr/local . Homebrew won't install files outside its prefix, and you can place a Homebrew installation wherever you like.

Brewfile

Homebrew users can define dependencies for their OS X operating system with a Brewfile

Cask

Homebrew-Cask extends Homebrew and allows you to install large binary files via a command-line tool.

MAS

The Mac App Store command line interface, or mas-cli, will allow you to install from the App Store.

#check if homebrew is installed
# if installed returns /usr/local/bin/brew
which brew
#install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
#once installation is successfull
brew doctor
#install MAS
brew install mas
# MAS signin
mas signin email@email.com
tap 'caskroom/cask'
brew 'tree'
brew 'git'
brew 'ruby'
brew 'pyenv'
brew 'pyenv-virtualenvwrapper'
brew 'node'
brew 'npm'
brew 'yarn'
cask 'google-chrome'
cask 'visual-studio-code'

Git

By far, the most widely used modern version control system in the world today is Git. Git is a mature, actively maintained open source project originally developed in 2005 by Linus Torvalds, the famous creator of the Linux operating system kernel.

Github

“GitHub is a web-based hosting service for software development projects that use the Git revision control system.”

#check system
brew doctor
#update packages
brew update
#install git
brew install git
#veirfy installation
git --version
#double check system
brew doctor
# Set your username
$ git config --global user.name "Your Name Here"
# Set your email address
$ git config --global user.email "your_name@domain.com"

Ruby

A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.

Ruby on Rails...

Rails is a model–view–controller (MVC) framework, providing default structures for a database, a web service, and web pages. It encourages and facilitates the use of web standards such as JSON or XML for data transfer, and HTML, CSS and JavaScript for display and user interfacing.

Ruby Versions

RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.if you don't care..Install Ruby with Homebrew

Don't mess w/your system Ruby, your system needs to be stable and it's not necessary. Homebrew isn't made to manage multiple versions of software. RVM (and others) and made to do exactly that. I currently have 6 rubies installed. I'd hate to have to manage that manually. RVM (or friends) is the way to go if you are installing Ruby on your host.

Install Ruby + RVM

Ruby Gems

RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries. The gem command is used to build, upload, download, and install Gem packages.

Gemfile

A Gemfile is a file we create which is used for describing gem dependencies for Ruby programs. Your Gemfile should always be in the root of your project directory, this is where Bundler expects it to be and it is the standard place for any package manager style files to live.

Bundler

Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed. It ensures that the gems you need are present in development, staging, and production. Starting work on a project is as simple as bundle install.

brew doctor
brew update
#disabling gem documentations
echo "gem: --no-document" >> ~/.gemrc
#install rvm + ruby on rails
curl -L https://get.rvm.io | bash -s stable --auto-dotfiles --autolibs=enable --rails
# install rvm + ruby (no rails)
# curl -L https://get.rvm.io | bash -s stable --auto-dotfiles --autolibs=enable --ruby
# relaunch temrinal
# type rvm | head -1
# if you get: rvm is a function, success
# rvm -v
# ruby -v
#list all ruby versions
# rvm list rubies
#use specific version in new sessions
# rvm use 2.2.0 --default
#Getting started with bundler is easy! Open a terminal window and run this command:
$ gem install bundler
#Specify your dependencies in a Gemfile in your project's root:
#source 'https://rubygems.org'
#gem 'nokogiri'
#gem 'rack', '~> 2.0.1'
#gem 'rspec'
#Learn More: Gemfiles
#Install all of the required gems from your specified sources:
#$ bundle install

Python

Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together.

PyEnv

pyenv lets you easily switch between multiple versions of Python. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well.

PyEnv-VirtualEnv

pyenv-virtualenv is a pyenv plugin that provides features to manage virtualenvs and conda environments for Python on UNIX-like systems.

PyEnv-VirtualEnvWrapper

pyenv-virtualenvwrapper is a pyenv plugin which provides a pyenv virtualenvwrapper command to manage your virtualenvs with virtualenvwrapper.

Attention: This plugin is different from pyenv-virtualenv, which provides extended commands like pyenv virtualenv 3.4.1 project_name to directly help out with managing virtualenvs. pyenv-virtualenvwrapper helps in interacting with virtualenvwrapper, but pyenv-virtualenv provides more convenient commands, where virtualenvs are first-class pyenv versions, that can be (de)activated. That's to say, pyenv and virtualenvwrapper are still separated while pyenv-virtualenv is a nice combination.

brew doctor
brew update
#install pyenv
brew install pyenv
#install pyenv-virtualenv
brew install pyenv-virtualenv
#install pyenv-virtualenvwrapper
brew install pyenv-virtualenvwrapper
brew doctor

NODE JS

Node.js is an open-source, cross-platform JavaScript run-time environment for executing JavaScript code server-side.

NPM

NPM is a package manager for Node.js packages, or modules if you like. The NPM program is installed on your computer when you install Node.js!

Yarn

Yarn caches every package it downloads so it never needs to download it again. It also parallelizes operations to maximize resource utilization so install times are faster than ever.

Node Versions

If you can survive with only one version of Node.js, brew and the official installer could be a solution.

When you have more projects, quite quickly you have to be able to switch between more versions of Node.js, so this requirement pushes to a node version management solution.

Manage Node Versions with N

Node.js version management: no subshells, no profile setup, no convoluted API, just simple.

Package.json

All npm packages contain a file, usually in the project root, called package.json - this file holds various metadata relevant to the project. This file is used to give information to npm that allows it to identify the project as well as handle the project's dependencies.

NPM Check Updates

npm-check-updates is a command-line tool that allows you to upgrade your package.json or bower.json dependencies to the latest versions, regardless of existing version constraints.

Global Packages

Global packages are for anything that you need to access from the shell. By contrast local packages are for using within your apps.

#INSTALL N
#Since you probably already have node, the easiest way to install n is through npm:
npm install -g n
#Execute n on its own to view your currently installed versions.
n
#Simply execute n <version> to install a version of node.
n 0.8.14
#If <version has already been installed (via n), n will activate that version.
#NINSTALL NPM CHECK UPDATES
npm install -g npm-check-updates
#Show any new dependencies for the project in the current directory
ncu
#Upgrade a project's package file
ncu -u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment