Monday, November 5, 2018

MacOS commands

MacOS commands



  • Task Manager
    • <command><option><esc>
  • Screen Shot:
    • <command><option><h><m>   ->   Minimize all windows
    • <command><shift><3>   ->  copy entire screen to an image on Desktop;
    • <command><shift><4> + <space> + click   ->   copy the select window to an image;
    • <command><shift><4> + define a custom area with the mouse   ->  copy the selected area to an image;
    • <command><shift><5>
  • Ifconfig  ->  Find your IP Address;
  • miniterm.py /dev/tty.usbserial-1420 115200   ->   Connect to serial device;
  • <command><shift><g>   ->  "Go to folder" in Finder 
  • sudo chflags nohidden(or hidden) directoryname   ->   directoryname that you want to see(or not) in Finder. (log out and back in)
  • defaults write com.apple.finder AppleShowAllFiles TRUE   ->   Showing all files in Finder. (log out and back in)
  • SSH:
    • Check if SSH is enabled:
      • sudo systemsetup -getremotelogin
    • Enable / Disable SSH server (remote access):
      • sudo systemsetup -setremotelogin on
      • sudo systemsetup -setremotelogin off
  • sudo nmap -sn -PE 192.168.1.0/24   ->   Ping all 256 IP's of the class C network 192.168.1.0. Using /24 will search 256 address, /23 will search 512 address, /22 will search 1024. Options meaning:  -sn (No port scan) -PE (ICMP ping echo).
  • ping -c 3 192.168.1.255 | grep 'bytes from' | awk '{ print $4 }' | sort | uniq   ->   Ping the broadcast address to return all devices on the network.
  • ping 192.168.1 | arp -a   ->   Ping all IP's and return their MAC address.
  • <command><option><esc>   ->   The basic “Force Quit Applications” window, which can be thought of as a simple task manager for Mac OS X.
  • <command><shift><Dot>   ->   Show hidden files on Mac via Finder. Repeat it to hide them again
If you like this content, feel free to

Installing Tools on Macbook Air

macOS Mojave 10.14.1
Xcode 10.1


Goal:

  • Install development tools on MacbookAir (e.g. Arduino IDE, Fritzing, Python, MicroPython, Brew, Sourcetree Bitbucket Sync, NodeJS).

  
ToDo:


Status:

  • 2018.11.05 - Working on it.

Install:

  • Installing Xcode:
    • Install Xcode from the App Store.
    • Open Xcode and install "complement"
  • Install Xcode’s separate Command Line Tools app:
    • Open Terminal:
    • xcode-select --install
    • OR Download it from https://developer.apple.com/download/more/ and install manually
  • Install Homebrew:
    • ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    • Enter your macbook user password
  • Configure Path:
    • nano ~/.bash_profile
    • Write the text below:
    • export PATH=/usr/local/bin:$PATH
    • Save the file using <control><o> and exit with <control><x>. Then activate the changes with the command below:
    • source ~/.bash_profile
  • Check that Homebrew was successfully installed:
    • brew doctor
    • This should be the output:
    • Your system is ready to brew.
    • brew update
  • Installing Python3:
    • Search for everything you can install, related to python:
    • brew search python3
    • python3 --version
    • Pip, Setuptools, and Wheel have also been installed.
  • Check if it is a 32 or 64 bits (python2 and python3)
    • python
    • import sys
    • is_64bits = sys.maxsize > 2**32
  • Python Virtual Environments:
    • Virtual environments enable you to have an isolated space on your computer for Python projects, ensuring that each of your projects can have its own set of dependencies that won’t disrupt any of your other projects. You can set up as many Python programming environments as you would like. Each environment is basically a directory or folder in your computer that has a few scripts in it to make it act as an environment.
    • Create a folder to python virtual environments:
      • mkdir ~/development
      • cd ~/development
      • mkdir python_envs
    • Installing Virtualenvwrapper:
      • pip3 install virtualenvwrapper
      • nano ~/.bash_profile
        • export WORKON_HOME=~/development/python_envs
        • MacOS:
          • export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
          • source /usr/local/bin/virtualenvwrapper.sh
        • Linux:
          • export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
          • source ~/.local/bin/virtualenvwrapper.sh
        • Windows:
          • pip install virtualenvwrapper-win
          • In Windows, the default path for WORKON_HOME is %USERPROFILE%\Envs
        • Close the terminal and open it again, to reload the bash_profile.
    • Creating a new environment (this creates the my_project folder inside $WORKON_HOME folder):
      • mkvirtualenv -p python3 my_project
    • To use this environment, you need to activate it:
      • cd $WORKON_HOME/my_project
      • workon my_project
    • Within the virtual environment, you can use the command python instead of python3, and pip instead of pip3 if you would prefer.
      • pip3 install django
    • To get out of the virtual environment:
      • deactivate
    • To delete the virtual environment created:
      • rmvirtualenv my_project
  • Installing Sourcetree:
    • Download at https://www.sourcetreeapp.com/
    • Install and clone repositories at /Users/<username>/development
  • Installing NodeJS:
  • Bash History behavior:
    • Note that the history file is automatically truncated to the size of HISTSIZE (500 by default) if the user does not explicitly set the size differently. HISTFILESIZE will be automatically set with the same value of HISTSIZE, so don't need to worry about it.
    • There are two lists of commands, one in memory and another in file. The setting for HISTCONTROL acts over the memory list. When you type a command it will be appended to the list. If the command to add is equal to the last command in the list and the option ignoredups is set, the command will be discarded.
    • Add HISTSIZE and HISTCONTROL to ~/.bash_profile:
      • nano ~/.bash_profile
        • export HISTSIZE=70000
        • export HISTFILESIZE=70000
        • export HISTCONTROL=ignoredups:erasedups
        • shopt -s histappend
        • PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND"
    • Close the terminal and open again to apply the changes.
Info:

References:
If you like this content, feel free to