美文网首页
利用iTerm2的Shell Integration进行文件下载

利用iTerm2的Shell Integration进行文件下载

作者: 湘港记者 | 来源:发表于2020-06-16 21:04 被阅读0次

    简介

    通过Shell Integration,iTerm2可以与unix shell集成在一起,它甚至可以跟踪命令历史记录,当前工作目录,主机名等等。个人使用频率最高的则是他的文件上传和下载功能。

    安装

    注意我们是要在服务器上安装Shell Integration,而非本机!
    我们可以在iTerm2上登录到服务器,然后点击菜单

    iTerm2 --> Install Shell Intergration
    

    也可以输入命令进行安装

    curl -L https://iterm2.com/shell_integration/install_shell_integration.sh | bash
    

    安装结束后会将以下命令添加到~/.bash_profile等文件

    source ~/.iterm2_shell_integration.zsh
    

    安装完后在shell的左边会有一个小三角形,表示Shell Intergration已经启动。


    最左侧的三角形

    常见问题

    点击后常会出现错误提示

    Failed to connect to localhost:22. Double-check that the host name is correct.
    

    这是因为他是通过hostname -f来确定服务器地址,但是服务器基本不会把IP设置为hostname,因此会报错,解决方法是在服务器~/.bash_profile中(如果使用的是bash的话)加入

    export iterm2_hostname=IP地址:SSH端口号
    

    且需要添加在source "${HOME}/.iterm2_shell_integration.bash"之前。添加完成后source或重启shell即可。

    使用方法

    下载

    在终端窗口中选中目标文件,点击右键,选择Download with scp即可。

    下载文件(通过scp进行)

    上传

    cd到目标路径下,拖拽本机文件,同时按住Option键,至终端窗口中。

    相关文章

      网友评论

          本文标题:利用iTerm2的Shell Integration进行文件下载

          本文链接:https://www.haomeiwen.com/subject/hlfdxktx.html