Iterm2 是一个强大的命令行工具,这里介绍一个有趣的小功能。
程序员做图片任务的时候,有时希望能查看图片内容,但通常我们是通过命令行连接服务器,难道给服务器安装一个桌面系统?还是写一个复杂的脚本下载到本地再查看?iterm 2提供了一个方便的结局方案。
安装imgcat
imgcat只是iterm 2提供的工具中的一部分,在通过 ssh 登录到远端服务器后,点击iterm2 -> preference -> install shell integration,iterm2 会在远端服务器安装相应的组件:

命令行输出如下:
gpu104: curl -L https://iterm2.com/shell_integration/install_shell_integration_and_utilities.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 4347 100 4347 0 0 3766 0 0:00:01 0:00:01 --:--:-- 3766
Downloading script from https://iterm2.com/shell_integration/zsh and saving it to /home/kangrong/.iterm2_shell_integration.zsh...
Checking if /home/kangrong/.zshrc contains iterm2_shell_integration...
Appending source command to /home/kangrong/.zshrc...
Downloading imgcat...
Downloading imgls...
Downloading it2attention...
Downloading it2check...
Downloading it2copy...
Downloading it2dl...
...
使用imgcat
此后,你可以做两件事情:
第一,通过imgcat直接在iterm2中查看图片:

第二,鼠标点击即可下载文件:


本文介绍如何在Iterm2中利用imgcat工具直接查看远程服务器上的图片,无需安装桌面系统或复杂脚本。只需简单安装,即可实现在命令行中直接预览图片内容,提高工作效率。
607

被折叠的 条评论
为什么被折叠?



