Posts about tools(2)

Page 1 of 1
Cool pic

Web Dev CLI Setup for macOS 💻 🍎

First things I do to start burning oil as a Web Dev

It’s not so often we get to set up a mac with the basic command line tools that make you productive, here I’ll leave what I do.

Command Line Tools

If you’re gonna be writing apps for iOS or macOS, most probably you should be installing Xcode, but if that’s not the case, probably it’s enough to install the command line tools:

Terminal window
xcode-select –-install

NOTE

Trying to run an unknown command such as git, will also cause the system to prompt us to install the command line tools.

To verify that the command line tools have been installed, you can run:

Terminal window
xcode-select -p

The output of the command above should be the location of the **command line tools in our system, in my case /Library/Developer/CommandLineTools. If you’re curious about what tools exactly are we getting, run:

Terminal window
ls Library/Developer/CommandLineTools/usr/bin

Homebrew: the macOS Package Manager

Homebrew is the most popular package manager for macOS, which we can install with:

Terminal window
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Oh My Zsh

Oh My Zsh is an open source, community-driven framework for managing your Zsh configuration. Installing it is super easy:

Terminal window
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

If you restart your shell, you’ll see you have a pretty cool new prompt. Next, let’s install some plugins:

  • Autosuggestions plugin, which suggests commands as you type based on history and completions. Read installation instructions here
  • zsh-syntax-highlighting plugin, which enables highlighting of commands whilst they are typed at a zsh prompt into an interactive terminal. This is super helpful for catching typos that would result in syntax errors. Read how to install it in oh my zsh here
  • zsh-autocomplete plugin, which provides real-time type-ahead autocompletion to your command line. This one doesn’t include instructions about how to install in oh my zsh. Basically we just have to clone it in the plugins folder:
Terminal window
git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git $ZSH_CUSTOM/plugins/zsh-autocomplete

NOTE

Note how above we’re using the ZSH_CUSTOM environment variable, which is used in Oh My Zsh to specify a custom directory for your plugins, themes, and custom configurations.

Once we’ve installed the plugins we want, we have to add them to the list of plugins in a our .zshrc file; this is what my list looks like:

Terminal window
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
zsh-autocomplete
)

To uninstall any of the plugins, we just have to remove it from the list of plugins above, and remove its folder; for example, to remove the zsh-syntax-highlighting folder:

Terminal window
rm -rf $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

FZF

Fzf is a command-line fuzzy finder which I find super useful. Let’s install it with brew:

Terminal window
brew install fzf

Here I had some problems integrating this tool with zsh, but searching through the internets I found out that we have to run an installation script to generate the necessary configuration files:

Terminal window
$(brew --prefix)/opt/fzf/install

NOTE

The $(brew --prefix) part is a command substitution that gives us the folder where Homebrew installs all the stuff; so if you run brew --prefix the output in my case, at the time of writing this, was /opt/homebrew (back in the day it was some other folder).

The output of the command above:

Terminal window
Downloading bin/fzf ...
- Already exists
- Checking fzf executable ... 0.61.3
Do you want to enable fuzzy auto-completion? ([y]/n)
Do you want to enable key bindings? ([y]/n)
Generate /Users/javi/.fzf.bash ... OK
Generate /Users/javi/.fzf.zsh ... OK
Do you want to update your shell configuration files? ([y]/n)
Update /Users/javi/.bashrc:
- [ -f ~/.fzf.bash ] && source ~/.fzf.bash
+ Added
Update /Users/javi/.zshrc:
- [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
+ Added
Finished. Restart your shell or reload config file.
source ~/.bashrc # bash (.bashrc should be loaded from .bash_profile)
source /Users/javi/.zshrc # zsh
Use uninstall script to remove fzf.

At the end, we should end up with a line at the end of our .zshrc:

Terminal window
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh

Which checks that the generated ~/.fzf.zsh file exists, and source it.

Amazon Q

A friend of mine recommended me a (generative AI)-powered assistant named Amazon Q, which is quite easy to install in macOS:

Terminal window
brew install amazon-q

Or just download the .dmg file, and clickety-click until we have it running. Whatever way we choose, we can verify the installation with:

Terminal window
q --version

NVM

nvm is next:

Terminal window
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash

Running the command above appends the following lines to the bottom of our .zshrc:

Terminal window
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

To verify the installation we have to run:

Terminal window
command -v nvm

which should output nvm if the installation was successful. Please note that which nvm will not work, since nvm is a sourced shell function, not an executable binary.

NOTE

To download, compile, and install the latest release of Node.js, do this:

Terminal window
nvm install node # "node" is an alias for the latest version
The future

uv - Blazingly Fast 😏 🚀

A Python's Package and Project Manager written in Rust

uv is an extremely fast package and project manager for Python, written in Rust. I hear you mumbling, another package manager for Python? Bro, this time is different, hear me out, uv really is the future. In this post we’ll spend some minutes learning how to use it.

What can I do with it?

Lots of things, but from the top of my head:

Installation

There are plenty of ways to get this puppy up and running in our machine. The first one, if you’re lucky enough to be on Linux or macOS:

Terminal window
$ curl -LsSf https://astral.sh/uv/install.sh | sh

After the installation, we have to restart our shell (just type exit in your terminal). That’s because the installer added uv to our PATH.

NOTE

If you’re in Windows 🤢:

Terminal window
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

For Christ’s sake, you can even install it with pip!

Terminal window
pip install uv

Anyways, once you’ve installed it, and as a sanity test, run:

Terminal window
$ uv
An extremely fast Python package manager.
Usage: uv [OPTIONS] <COMMAND>

TIP

Check the docs for uninstallation if you need to.

Installing Python Versions

uv can also install and manage Python versions:

Terminal window
$ uv python install

That would get us the latest version, but if you want to install a specific one, just say it:

Terminal window
$ uv python install 3.12

NOTE

If you run the command above (regardless if you’re in a project folder), it will install Python in ~/.local/share/uv/python/cpython-3.13.3-macos-aar, and create a symlink to it in ~/.local/bin/python3.13.

To see a list of the available and installed Python versions:

Terminal window
$ uv python list

IMPORTANT

We don’t need to install Python to get started; If Python is already installed on your system, uv will detect and use it.

Projects

uv supports managing Python projects, which define their dependencies in a pyproject.toml file. Like in other languages, we can create a new Python project using the uv init command:

Terminal window
uv init my-proj

That will create the following project structure within the my-proj folder:

my-proj/
.
├── .python-version
├── README.md
├── main.py
└── pyproject.toml

TIP

If you already have a project folder, let’s say you already have the my-proj folder, you can run just uv init within the folder.

The main.py file contains a simple “Hello world” program. Try it out with uv run:

Terminal window
$ cd my-proj
$ uv run main.py
Using CPython 3.13.2 interpreter at: /usr/bin/python3.13
Creating virtual environment at: .venv
Hello from my-proj!

Now, if we list the content of our project:

Terminal window
$ ls -a
.
├── .git
├── .gitignore
├── .venv
│   ├── bin
│   ├── lib
│   └── pyvenv.cfg
├── .python-version
├── README.md
├── main.py
├── pyproject.toml
└── uv.lock

That’s right, uv has created a virtual environment (in .venv folder), and initialized a git repo for us. From a project point of view, the pyproject.toml contains our project’s metadata (sort of the package.json in Node.js):

[project]
name = "hello-world"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
dependencies = []

Managing Dependencies

Managing dependencies is easy. Let’s say we want to install marimo:

uv add marimo

Marimo includes a tutorial, so let’s run it, to verify it’s installed:

uv run marimo tutorial intro

WARNING

If you try to run:

marimo tutorial
zsh: command not found: marimo

Your shell will complain! That’s because when we run uv add marimo, uv installs marimo into a virtual environment (under the .venv folder). This environment is isolated, meaning the marimo executable is only available when the virtual environment is activated or when you explicitly use uv run to access it.

I hope that was enough to get you started; feel free to check the official docs, they’re awesome.