Deprecated: Creation of dynamic property Timber\Site::$pingback is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Site.php on line 180

Deprecated: Creation of dynamic property Timber\User::$name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/User.php on line 118

Deprecated: Creation of dynamic property Timber\Post::$os_meta is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$has_disclaimer is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_edit_lock is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_edit_last is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$tipologia is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_tipologia is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$attributi is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_attributi is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$in_evidenza_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_in_evidenza_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$inviato_in_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_inviato_in_newsletter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$fonte is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_fonte is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$fonte_url is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_fonte_url is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_category is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_blz_affiliation_attributes is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_content_type is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_attributes is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_primary_speciali is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_focuskw is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_metadesc is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_linkdex is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_content_score is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_focuskeywords is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_keywordsynonyms is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_wpseo_estimated-reading-time-minutes is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_thumbnail_id is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_yoast_indexnow_last_ping is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_oembed_5c86f260961246cd7b5a04646a6b24d6 is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_oembed_time_5c86f260961246cd7b5a04646a6b24d6 is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$newsletter_subject is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_newsletter_subject is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$newsletter_summary is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$_newsletter_summary is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_date_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$ping_status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_password is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_name is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$to_ping is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$pinged is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_modified_gmt is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_content_filtered is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$guid is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$menu_order is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$post_mime_type is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$comment_count is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$filter is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71

Deprecated: Creation of dynamic property Timber\Post::$status is deprecated in /var/www/html/web/app/themes/ilsoftware/vendor/timber/timber/lib/Core.php on line 71
I 20 Microscript geniali che ogni utente avanzato dovrebbe usare: risparmia ore di lavoro

I 20 Microscript geniali che ogni utente avanzato dovrebbe usare: risparmia ore di lavoro

Presentiamo un'eccezionale collezione di microscript che semplificano operazioni quotidiane nel terminale, come la gestione della clipboard, la creazione di directory, l’avvio di server Web o la compressione di file multimediali. Facili da installare e portabili tra Linux, macOS e WSL.

Evan Hahn è uno di quegli sviluppatori che, dopo anni passati a modellare il suo ambiente di lavoro, ha messo insieme una collezione di microscript — semplici, piccoli programmi shell — che usa ogni giorno. Questi strumenti non fanno cose spettacolari da soli, ma risolvono fastidi quotidiani: copiare la directory corrente, avviare un server statico in una cartella, provare rapidamente qualcosa in una directory temporanea, riprodurre un suono quando un comando lungo termina, e così via.

Date un’occhiata alla collezione di script utilizzabili ogni giorno: ve ne sono alcuni davvero intelligenti che, con poche semplici righe di codice, permettono di risparmiare minuti e snellire il lavoro. Tutti gli script sono progettati per usare stdin/stdout e si concatenano con le pipe. Inoltre, sono portabili: con piccole differenze, possono funzionare su sistemi diversi come Linux, macOS e Windows (ad esempio con Windows Subsystem for Linux, WSL).

Pensateli come come scorciatoie intelligenti: gli script sviluppati da Hahn non sostituiscono strumenti complessi, ma rendono il terminale più umano.

Gli script “must-have” dei quali vi innamorerete

  1. copy e pasta — clipboard da terminale. Il primo script legge da stdin e mette il contenuto nella clipboard di sistema. Il secondo stampa il contenuto della clipboard su stdout.
  2. mkcd — crea e entra nella cartella. Crea una directory e si sposta dentro in un solo comando.
  3. tempe — directory temporanea per esperimenti. Crea una directory temporanea, ci entra e assicura che si lavori in una sandbox.
  4. serveit — avvio di un server Web. Avvia un server HTTP statico nella cartella corrente (utile per sviluppo frontend, test di file HTML locali, e così via).
  5. trash — non eliminare, manda al cestino. Sposta i file nel cestino anziché rimuoverli definitivamente, riducendo il rischio di cancellazioni accidentali.
  6. boop — suono al termine di un comando. Riproduce un jingle se il comando precedente è andato a buon fine, o un suono triste in caso contrario. Utile per i comandi che impiegano molto tempo.
  7. getsubs, getsong, getpod — wrapper per yt-dlp. Automatizzano il download di audio, podcast e sottotitoli usando yt-dlp. Molto potenti ma con implicazioni legali (necessità di rispettare i diritti di copyright).
  8. pastas — monitorare la clipboard. Restituisce il contenuto attuale dell’area degli appunti e ripete l’operazione ogni volta che cambia. Comodo per registrare tutto ciò che si copia in memoria durante una sessione di lavoro.
  9. cpwd — copia la directory corrente nella clipboard. È l’equivalente di pwd | copy, utile per condividere rapidamente percorsi di file o cartelle.
  10. url — analizza e scompone un URL. Estrae protocollo, dominio, percorso e parametri, utile per il debugging o la pulizia di link traccianti.
  11. scratch — apre un buffer temporaneo. Crea un file temporaneo e lo apre nell’editor di testo per appunti o test veloci.
  12. jsonformat — formatta JSON in modo leggibile. Indenta e colora l’output JSON per analisi rapide da terminale.
  13. snippets — gestisce frammenti di testo. Permette di salvare e richiamare snippet frequenti, come emoji, simboli o blocchi di codice.
  14. emoji — ricerca di emoji dal terminale. Permette di trovare rapidamente emoji in base a una parola chiave.
  15. removeexif — elimina i metadati EXIF. Pulisce le immagini dai dati di posizione o fotocamera prima della condivisione.
  16. speak — sintetizza la voce. Converte testo in audio leggibile usando say (macOS) o espeak-ng (Linux).
  17. ocr — estrae testo da immagini. Usa un motore OCR per convertire un file immagine in testo leggibile (su macOS).
  18. shrinkvid — comprime video con FFmpeg. Riduce la dimensione dei file mantenendo una buona qualità visiva.
  19. radio — avvia stazioni radio Web. Permette di ascoltare flussi musicali in streaming.
  20. running — elenca i processi attivi per nome. Equivalente più leggibile di ps aux | grep.

Come scaricare gli script in un colpo solo

Per semplicità, ci riferiamo all’utilizzo della finestra del terminale di Linux. Tuttavia la stessa procedura può essere sfruttata su macOS così come in Windows, usando WSL.

Come primo passo, per scaricare e archiviare in locale gli script di Hahn, si può clonare il repository dello sviluppatore:

git clone https://codeberg.org/EvanHahn/dotfiles.git

Portandosi nella sottocartella dotfiles/home/bin/bin, si possono trovare tutti gli script, pronti per l’uso e con i relativi nomi.

Per “installare uno script” e renderlo utilizzabile dall’utente in uso, basta impartire i comandi seguenti:

mkdir -p ~/.local/bin
cp ~/dotfiles/home/bin/bin/serveit ~/.local/bin/serveit
chmod 755 ~/.local/bin/serveit

In questo modo, digitando il comando serveit in una qualunque directory Linux, tutti i file ivi presenti diventeranno accessibili digitando 127.0.0.1:8000 nella barra degli indirizzi del browser Web preferito. Funziona perfettamente anche da WSL in ambiente Windows!

Script condivisione file tramite server Web con Serveit

È possibile anche eseguire, qualora lo si desiderasse, effettuare un’installazione dello script system-wide ossia per tutti gli utenti. In questo caso è necessario avvalersi del comando sudo:

sudo cp ~/dotfiles/home/bin/bin/serveit /usr/local/bin/serveit
sudo chmod 755 /usr/local/bin/serveit
# (facoltativo) impostare proprietario root
sudo chown root:root /usr/local/bin/serveit

Nell’esempio abbiamo citato serveit ma ovviamente la procedura può essere ripetuta per qualsiasi script.

Conclusioni

Gli script di Evan Hahn sono un esempio perfetto di come piccole automazioni possano semplificare il lavoro di ogni giorno, rendendo le operazioni più veloci, intuitive e piacevoli.

Dall’avvio di server locali alla gestione della clipboard, passando per strumenti per file temporanei o conversioni rapide, ciascuno di questi microscript può trasformarsi in un vero alleato per sviluppatori e utenti avanzati.

Per chi desidera esplorare l’intera collezione, approfondire le funzionalità e scoprire nuovi script da integrare nel proprio workflow, il consiglio è di visitare direttamente il sito dello sviluppatore e consultare il repository ufficiale.

Ti consigliamo anche

Link copiato negli appunti