avatarManav

Summary

The web content provides a guide on using iTerm2's file utilities for file operations on remote servers, demonstrating how to download, upload, view images, and copy file contents to the clipboard using practical examples with Multipass on MacOS.

Abstract

The article "iTerm2 File utilities — What they are and how to use them" delves into the advanced file management capabilities of iTerm2, a popular terminal replacement for MacOS. It outlines the pre-requisites for setting up a local Ubuntu server using Multipass and details the installation process for iTerm2 Shell Integration with iTerm2 Utilities. The guide then illustrates several use cases, including downloading files from a remote server to the local machine using it2dl, uploading files with it2ul, inline viewing of image files in the terminal with imgcat, and copying file contents directly to the clipboard with it2copy. Each use case is accompanied by step-by-step instructions and screenshots, making it easy for users to follow along and leverage these utilities for efficient file handling across remote servers.

Opinions

  • The author positions iTerm2 as the premier terminal replacement app for MacOS, implying its superiority in functionality.
  • The article is presented as an extension to a previous piece on iTerm2 advanced tricks, suggesting a continuation of valuable insights for readers already familiar with the basics.
  • By using Multipass to create a local Ubuntu server, the author demonstrates a practical approach to a common task, enhancing the article's relevance to users who manage servers.
  • The inclusion of screenshots for each step of the process indicates a user-friendly approach, aiming to make the guide accessible to a wider audience, including those who may be less familiar with command-line operations.
  • The author emphasizes the convenience of iTerm2 utilities by comparing them to traditional methods like setting up SFTP connections, highlighting the efficiency gains for users.
  • A call to action is subtly included at the end, encouraging readers to engage with the content by following the author for more insights and to support the article by using the clap button.
  • The author endorses an AI service, ZAI.chat, as a cost-effective alternative to ChatGPT Plus (GPT-4), suggesting its value to readers interested in AI technology.

iTerm2 File utilities — What they are and how to use them

iTerm2 is the king of terminal replacement apps on MacOS, and rightfully so. Below we look at some of the iTerm2 utilities primarily related to file operations and using them across remote servers

Note: This article is an extension of our iTerm2 advanced tricks article

To adequately demonstrate the use cases, we will be using Multipass to set up a local ubuntu server

Let’s get started!

Photo by Arthur Reeder on Unsplash

Pre-Requisite

[a] Install Multipass Multipass can be installed on MacOS using brew

brew install multipass

[b] once installed, start a Multipass instance with the name testBox using

multipass launch — name testBox

multipass launch

[c] Check if the multipass instance is running using

multipass list

multipass list

[d] Try accessing the shell of the remote server using

multipass shell testBox

multipass shell

[e] Install iTerm2 Shell Integration with iTerm2 Utilities

shell integration menu
install shell integration

click Download and Run Installer

install shell integration and utilities
installation complete

[e] Exit and Re-login to the ubuntu machine

exit multipass shell testBox

Use Case [1]: Download a File

Utility Name: it2dl What does it do: Download a file Syntax: it2dl {filename}

Let’s start by creating a test file on the remote server /tmp directory Staying in the Ubuntu shell, let’s browse to the/tmp directory cd /tmp

and create a simple text file echo “THIS IS A TEST FILE FROM DECODED BYTES” > testFile.txt

create test file

You can review the contents of the testFile using cat testFile.text

Now let’s download this file to the ~/Downloads directory on the local machine. Type it2dl testFile.txt

and testFile.txt should download the file to your local ~/Downloads directory

Note: We created a test file manually to showcase the capability, but this can be used to download logs and other important files from the server without setting up sftp connections or users

Use Case [2]: Upload a FILE

Utility Name: it2ul What does it do: Upload a file Syntax: it2ul — select the file from the finder window

Next, let's try and upload a file. Still, in the /tmp directory on the ubuntu server, type in it2ul

This will open a finder window where you can pick the file to upload

pick the file to upload

and check if the file upload is successful using ls -ltr

file uploaded

Use Case [3]: Check the image file on terminal

Utility Name: imgcat What does it do: View an image file inline on terminal Syntax: imgcat {filename}

You can even check the image file on the terminal; just use imgcat {filename}

which, in our case, is imgcat ‘Twitter Profile Picture.png’

and voila

the image showed inline on terminal

Use Case [4]: Copy File Contents to Clipboard

Utility Name: it2copy What does it do: Copy file contents Syntax: it2copy {filename}

Finally, suppose you want to copy the contents of a file to the clipboard; you can do that using it2copy {filename}

Let's create a directory listing file in /tmp directory as ls -ltr > dirlisting.txt

and then you can copy the contents of this file using it2copy dirlisting.txt

Finally, you can paste the contents into Notes app or any other text app

Bonus: If the remote server has `php` installed; you can use imgls to show a listing of images with thumbnails

And that's all. Thanks for reading. Follow for more daily valuable content

Don’t forget to click the clap button a few times

Shell
Iterm2
Utilities
Development
Programming
Recommended from ReadMedium