Skip to content

Instantly share code, notes, and snippets.

@moisoto
moisoto / Working-With-read.md
Last active November 26, 2019 02:46
macOS: ZSH Tidbits

ZSH Tidbits: Working with the read command

The read command can be a headache when you are porting your scripts from a shell to another.

Let's see the way it works with bash (the default shell for macOS before Catalina):

read -p "Do you wish to continue? (Y/n)"
[[ $REPLY == "y" ]] && echo "You must use Capital Y if you wish to continue"
[[ $REPLY != "Y" ]] && exit
@moisoto
moisoto / macOS_ZSH_word-list-for-loop.md
Last active November 26, 2019 21:35
MacOS: ZSH Tidbits

Working with a word list on a for loop

On bash:

#!/bin/bash
LIST="one two three"
for item in $LIST ; do echo $item ; done

On zsh:

@moisoto
moisoto / macOS_ZSH_working-with-options.md
Last active November 26, 2019 16:25
MacOS: ZSH Tidbits

Working with ZSH Options

When using ZSH as your default shell there is a chance you’ll set specific options on your .zshrc script to make work easier.

You can read about ZSH options and what they do here for more information on what you can do with zsh options.

Problem is, when doing ZSH scripts you can’t depend on the user having specific options. So you must be careful that you are not assuming the script works on any environment since your script may be depending on your specific options. Also the user may set an option that breaks your script.

To avoid this, you should set there following code at the start of all your zsh scripts:

@moisoto
moisoto / publish-your-package.md
Last active January 25, 2021 18:40
Publishing Your Package Documentation

Publishing your Package

Go Module!

If you haven't already go and initialize your module:

# This assumes you have your package located at ~/go/src/github.com/your_account/your_package
go mod init github.com/your_account/your_package
go mod tidy
@moisoto
moisoto / Create-Win10-Install.md
Last active February 2, 2021 19:44
Creating an Install Image for Windows 10 on a Mac

Creating an Install Image for Windows 10 on a Mac

Format Memory Stick

  • Insert your memory stick (16GB Minimum) and check the disk which is associated to it by executing the command diskutil list | grep external:
$ diskutil list | grep external
/dev/disk2 (external, physical):
@moisoto
moisoto / DeleteLocalSnapshots.md
Last active July 10, 2024 20:22
MacOS - Free Disk Space by deleting Time Machine Local Snapshots

How to delete Time Machine Local Snapshots and free your Disk Space

List local snapshots:

tmutil listlocalsnapshots /

You will be presented with a list of snapshots like this:

@moisoto
moisoto / SwiftForBeginners-Playgrounds.md
Last active August 26, 2022 17:12
Swift Playground Examples for Beginners

Making ZSH your default shell

If you are on macOS Catalina, your default shell is most likely zsh but to make sure, run the following commands:

# Check your default shell:
echo $SHELL

# Check your current shell (if you configured your terminal to use a specific shell different front your default):
ps -o comm= $$

macOS / Xcode 12 - Recover space used by Xcode Device Simulators

Check your current Simulators:

To check the simulators currently installed in your system:

$ xcrun simctl list

Check Occupied Space:

@moisoto
moisoto / macOS_GitHub_Using_Token_Authentication.md
Last active August 17, 2021 01:14
macOS / GitHub - Using Token Authentication

GitHub - Using Token Authentication

Since August 13, 2021 GitHub is no longer allowing users to access repositories with username/password authentication. This will affect users accesing github repositories from command line clients.

You will need to create a Personal Access Token (PAT) if you wish to continue accessing your repositories from the command line.

Instructions for how to create a PAT can be found on GitHub. It's a simple process and at the time of this writing it consists on going to your profile's Developer Settings at Your Github profile -> Settings -> Developer Settings (click on your profile picture to find the link to Your GitHub profile).

When creating yor access token for accessing your repositories it is better if you set an expiration date[*](#f1