Kako ozbiljno nadograditi svoj Mac terminal (i čak mu dati Matrix temu)

Plava tableta, crvena tableta i 3 koraka do blaženstva terminala

Izgleda li vaš Mac Terminal trenutno ovako -> (drugim riječima, pomalo je sranje)?

Želite li da izgleda ovako -> (ili, znate, gad)?

Ili realnije -> (i zapravo strašnije) ... poput ovog?

I dalje izgleda loše, a sada je upotrebljiv i sposoban pokrenuti gomilu dodatnih korisnih značajki koje će vam uštedjeti vrijeme i učiniti da se osjećate poput kodera sljedeće razine(bez obzira držite li se Matrix sheme boja ili ne).

Sad kad imam vašu pažnju, naučimo zajedno.

Moje obećanje vama, dragi čitatelju, jest da ću napisati na jednostavnom engleskom jeziku najbolje što mogu kako bih vas poveo u ovu slavnu misiju utvrđivanja činjenica. I sam sam na početku mog kodiranja, ali to ne znači da ne možemo postići velike i važne stvari (poput izbjegavanja stvarnog učenja kodiranja razrađivanjem načina kako da svaka vražja stvar izgleda poput Matrixa i možda slučajnog učenja nečega o kodu u procesu).

Za neupućene: što je Terminal na Macu?

Obično kliknete tipkom i mišem po zaslonu da biste na računalu radili zabavne stvari. Pomoću Terminala (uobičajena aplikacija koja dolazi s vašim Macom) računalu zapovijedate da umjesto toga koristi snagu tipkanja na tipkovnici.

To mogu biti jednostavne stvari poput stvaranja nove mape upisivanjem "mkdir", do svemoćnih stvari poput prisiljavanja računala da vam napravi sendvič:

Sad kad je to razjašnjeno, kako Terminal učiniti sjajnim?

Plava ili crvena tableta ...

Kao što sam siguran da ste očekivali u postu na blogu labavih i brzih Matrix referenci, postoje dva izbora. Plava tableta je jednostavna i bit ćete gotovi za manje od tri minute. Crvena tableta je uzbudljivija, očaravajuća i ima znatno viši strop - za što ćemo morati iskoristiti mnogo više vaših dragocjenih neurona.

Plava tableta

Za plavu pilulu, evo nekoliko brzih i jednostavnih koraka kako vaš terminal učiniti Neo ponosnim:

[1] Otvorite terminal putem funkcije pretraživanja Spotlight

- naredba ⌘ + razmak, „terminal“

[2] Otvorite postavke terminala: promijenite profil u "Homebrew", uključujući pri pokretanju

-Terminal, Postavke, Općenito -> Novi prozor s profilom -> Homebrew

- Terminal, Postavke, Profili -> Homebrew -> Kliknite "Zadano" u donjem lijevom dijelu

[3] Ponovo pokrenite terminal

Sada biste trebali imati niiiccceee Matrix-esque terminal, kao u nastavku:

Ta je Plava pilula bila ukusna i lagana. Sada Crvena pilula.

Crvena tableta

Ovo je za one koji pretjeruju, one lude, one koji traže istinu. Nakon njega vaš terminalni kôd neće izgledati samo kao Matrix, nego će raditi svemoćne stvari. Možda više nikad nećeš biti isti koder ...

Potrebna su samo tri koraka:

[1] Umanjite svoj terminal

[2] Neka to bude Matrix

[3] Razina snage vašeg terminala

Korak 1 od 3: Badassificirajte svoj terminal

Prvo, prvo moramo osnažiti vaš terminal za izvrsne stvari, uključujući:

  • Instaliranje iTerm: bolja verzija terminala (pogledajte ovdje sjajne značajke od razdvajanja okna do inteligentnog pretraživanja terminala za pretraživanje)
  • Promjena ljuske iz "bash" u fleksibilniji i snažniji "zsh" (ljuska je poput softvera koji izvršava vaša terminalna aplikacija. Potrebne su vam naredbe tipkovnice u terminalu i dane ih računalu da ih izvrši.)
  • Instalirajte "oh-my-zsh", koji će super napuniti vašu zsh ljusku (to jest, to je okvir vođen zajednicom za upravljanje vašom zsh konfiguracijom)
  • Bonus ovlasti: isticanje sintakse (pokazuje hoće li se vaša naredba pokrenuti prije nego što je pokrenete) i z navigacija po terminalu (čini navigaciju terminalom mnogo bržom procjenom mape u koju želite prebaciti pomoću "frecency")

Da biste svoj terminal osnažili svim navedenim, slijedite ovaj izvrsni vodič Jillesa Soetersa: Baddassificirajte svoj terminali vratite se na korake 2 i 3.

Drago mi je što ste se vratili

Sada je vrijeme da uzmete svoj novoasasificirani terminal i u potpunosti unesete tu crvenu tabletu ...

Korak 2 od 3: Neka to bude Matrix

Srećom, neka ljubazna duša (Robert Dempsey) već je izvezla punu matričnu shemu boja za iTerm, pa sve što trebamo učiniti je uvesti je!

Naravno, ako vam tema Matrix boja ne odgovara, slobodno upotrijebite zadanu postavku i prijeđite na korak 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”