Cómo actualizar seriamente su terminal Mac (e incluso darle un tema Matrix)

Una píldora azul, una píldora roja y 3 pasos para la felicidad terminal

¿Su terminal Mac actualmente se ve así -> (en otras palabras, apesta un poco)?

¿Quieres que se vea así -> (o, ya sabes, rudo)?

O más realista -> (y en realidad más asombroso)… ¿así?

Todavía se ve rudo, y ahora se puede usar y ejecutar una gran cantidad de funciones útiles adicionales que le ahorrarán tiempo y lo harán sentir como un codificador de siguiente nivel.(se ciña o no al esquema de color de Matrix).

Ahora que tengo su atención, aprendamos juntos.

Le prometo, querido lector, que escribiré en un inglés sencillo lo mejor que pueda para llevarlo a esta gloriosa misión de investigación. Yo mismo estoy al comienzo de mi viaje de codificación, pero eso no significa que no podamos lograr cosas grandes e importantes (como evitar aprender a codificar resolviendo cómo hacer que cada maldita cosa se parezca a Matrix, y tal vez aprender algo accidentalmente sobre el código en el proceso).

Para los no iniciados: ¿que es Terminal en Mac?

Normalmente, hace clic con un clic alrededor de la pantalla con un teclado y un mouse para hacer cosas divertidas en su computadora. Con Terminal (una aplicación normal que viene con su Mac), le ordena a su computadora que haga cosas en lugar de usar el poder de escribir en su teclado.

Estas pueden ser cosas simples como crear una nueva carpeta escribiendo "mkdir", hasta cosas todopoderosas como obligar a su computadora a hacer un sándwich:

Ahora que está aclarado, ¿cómo hacemos que Terminal sea increíble?

La píldora azul o la píldora roja ...

Como estoy seguro de que esperaba en una publicación de blog de referencias rápidas y sueltas de Matrix, hay dos opciones. La píldora azul es fácil y estará listo para dividir en menos de tres minutos. La píldora roja es más emocionante, fascinante y tiene un techo mucho más alto, para lo cual necesitaremos aprovechar mucho más de sus preciadas neuronas.

La pastilla azul

Para la píldora azul, aquí hay algunos pasos rápidos y fáciles para que su terminal enorgullezca a Neo:

[1] Terminal abierto a través de la función de búsqueda Spotlight

- Comando ⌘ + Espacio, "Terminal"

[2] Abrir preferencias de Terminal: cambiar perfil a "Homebrew", incluso al iniciar

-Terminal, Preferencias, General -> Nueva ventana con perfil -> Homebrew

- Terminal, Preferencias, Perfiles -> Homebrew -> Haga clic en "Predeterminado" en la parte inferior izquierda

[3] Reiniciar terminal

Ahora debería tener una terminal niiiccceee Matrix-esque, como la siguiente:

Esa píldora azul fue deliciosa y fácil. Ahora para la píldora roja.

La pastilla roja

Esto es para los triunfadores, los locos, los buscadores de la verdad. Después, el código de su terminal no solo se verá como Matrix, sino que hará cosas todopoderosas. Puede que nunca vuelva a ser el mismo programador ...

Todo lo que necesita son tres pasos:

[1] Badassify su terminal

[2] Make it Matrix

[3] Nivel de potencia de su terminal

Paso 1 de 3: Badassify su terminal

Lo primero es lo primero, debemos capacitar a su terminal para que haga cosas increíbles, que incluyen:

  • Instalación de iTerm: una mejor versión de Terminal (vea las increíbles funciones desde paneles divididos hasta búsquedas inteligentes en terminales haciendo clic aquí)
  • Cambiar el shell de "bash" al más flexible y potente "zsh" (el shell es como el software que está ejecutando su aplicación de terminal. Toma los comandos de su teclado en el terminal y se los da a la computadora para que los ejecute)
  • Instale "oh-my-zsh", que sobrecargará su shell zsh (es decir, es un marco impulsado por la comunidad para administrar su configuración zsh)
  • Poderes adicionales: resaltado de sintaxis (le muestra si su comando se ejecutará antes de ejecutarlo) y navegación del terminal z (hace que navegar por el terminal sea mucho más rápido al estimar la carpeta a la que desea cambiar usando "frecuencia")

Para potenciar su terminal con todo lo anterior, siga esta excelente guía de Jilles Soeters: Baddassify your terminaly regrese para los Pasos 2 y 3.

Qué bien tenerte aquí de nuevo

Ahora es el momento de tomar su terminal recién armada e ingerir completamente esa píldora roja ...

Paso 2 de 3: conviértalo en matriz

Afortunadamente, un alma amable (Robert Dempsey) ya ha exportado un esquema de color Matrix completo para iTerm, ¡así que todo lo que tenemos que hacer es importarlo!

Por supuesto, si el tema de color de Matrix no le gusta, no dude en usar uno predeterminado y vaya al paso 3.

[1] Download the color scheme code from this link and move the folder to an easy place to access

- Click: “Download Zip”

- Create a folder on your Desktop called “iTermThemes”

- Move the file “matrix_color_scheme_iterm2” to the iTermThemes folder (not the whole folder, only the file)

[2] Open Terminal and change to the directory where you moved the file

- Use the change directory (cd) command to change to the folder where you have the file

cd Desktop/iTermThemes

[3] Now that you are in the correct directory (folder) in Terminal, copy paste the following code into Terminal to run it:

for f in*; do

THEME=$(basename "$f")

defaults write -app iTerm 'Custom Color Presets' -dict-add "$THEME" "$(cat "$f")"

done

This code runs through each of the color codes in the file (using “for…”)

and saves the result as “matrix_color_scheme_2” in the Custom colors in iTerm

(Example of a color: ‘Selected Text Color’ = { ‘Blue Component’ = ‘1.000000’; ‘Green Component’ = ‘1.000000’; ‘Red Component’ = ‘1.000000’)

[4] Update iTerm preferences to use the new Matrix color scheme

- iTerm2, Preferences, Profiles, Colors, Color Presets, “matrix_color_scheme_iterm2”

Your Terminal should now feel like this:

Step 3 of 3: Power-level your terminal

There is more?! Indeed there is more, you want your terminal to be the talk of the town, right?

The next step is to pimp your terminal with Powerlevel9k by Ben Hilburn, giving it fancy symbols and customisable gizmos with an out-of-the-box configuration. These visual cues are actually super useful in saving space and understanding your live environment, like what directory you are in, what Git branch you are on, and even how long your code took to run.

Before we begin, some background knowledge:

- “Powerlevel9k” is a theme for Oh-My-Zsh

- For the symbols to appear properly, you also need to install a “Powerlinefont (a font that includes a set of symbols, like how wingdings has symbols, but with actual letters too)

Install Powerlevel9k theme for Oh-My-ZSH

[1] Copy this code into your terminal, which will clone the Powerlevel9k repository into your Oh-My-Zsh custom themes directory.

$ git clone //github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k

[2] You then need to choose this theme in Oh-My-Zsh by editing the profile file

[i] Open the profile file in the text editor “nano” by typing the following into your terminal:

nano ~/.zshrc

[ii] Find the part of the file with

ZSH_THEME=" e>"

…and replace it with (important: no spaces)

ZSH_THEME="powerlevel9k/powerlevel9k"

Note: You can navigate around the “nano” text editor using your arrow keys and type straight into it (much easier than VIM, if you have ever used that!).

[iii] To save the change and exit the Nano text editor:

- Ctrl-x (i.e. ^x)

- Y (this saves the change)

Now… the final step

Install and select Powerline fonts

Installing the standard Powerline fonts is thankfully very easy!

[1] By running the following code, you will clone the Powerline repository to your computer and install the fonts all in one easy step (you can keep the comments in).

# clonegit clone //github.com/powerline/fonts.git --depth=1# installcd fonts./install.sh# clean-up a bitcd ..rm -rf fonts

[2] Select a Powerline font in iTerm preferences

- iTerm, Preferences, Profiles, Text, Change Font, *Select Meslo LG M for Powerline*

All that is left is to FEEL THE POWER of your new Terminal

What if I told you… that this is only the beginning

I highly recommend continuing to play around with the powers of iTerm, Oh-My-Zsh and Powerlevel9k. It is a great practical way to learn more about Terminal while super-charging it.

There are a ton of settings, customisation options, and plugins so you can get your Terminal looking and behaving exactly as you want it to with a bunch of awesome features.

An easy win I found was adding the following code to your zshrc file. Type it into Terminal nano ~/.zshrc) just before the “ ZSH_Theme” line. This shortens the file-paths shown on each line and saves some room for your code itself.

#Shorten directory shownPOWERLEVEL9K_SHORTEN_DIR_LENGTH=1POWERLEVEL9K_SHORTEN_DELIMITER=””POWERLEVEL9K_SHORTEN_STRATEGY=”truncate_from_right”
#Set default user to avoid showing 'user' on every lineDEFAULT_USER=”whoami”

Of course, you can also choose alternative colour schemes for your Terminal if your grow tired of green. Just know, you may upset Morpheus.

I hope you enjoy your new Badass Matrix Terminal and, if you enjoyed this blog post, (my first ever!), feel free to click ‘Follow’ and give me a few Claps by clicking the beautiful Medium claps button below ?

Click here for my next post: “How to become a code-learning super NINJA”