iTerm2有一个很好的⌘-点击打开一个文件在你的IDE。
问题是我正在通过Vagrant运行一个web服务器,所以/home/vagrant实际上不是iTerm2可以访问的物理目录。
有什么办法我可以:
A.)映射/家庭/流浪/到/Sites在我的.bash_profile
B.)通过返回修改后的路径的查找/替换脚本运行它?
有什么建议吗?谢谢
发布于 2017-03-28 19:22:33
没有办法使用.bash_profile来配置它.但在你的iTerm2 2偏好中有一个解决方案。
首选项->概要文件->语义历史。更改为运行命令.并填充:
sh ~/click-handler.sh \1 /home/vagrant /Sites创建~/click-handler.sh:
old_filepath=$1
old_basepath=$2
new_basepath=$3
new_filepath="${old_filepath/$old_basepath/$new_basepath}"
open $new_filepath我们试试吧!
发布于 2017-03-28 21:57:36
谢谢乌德雷。你绝对给我指明了正确的方向。“运行命令”的问题是,如果iTerm2不识别文件系统中的目录,它(目前为3.0.15)不会响应单击。我将其更改为“始终运行命令”,并能够使用您的代码来提出这个问题。我真的很感激你的帮助。
#!/bin/bash
# iTerm2 > Profiles > Adv -> Semantic History > Always Run Command:
# sh ~/click-handler.sh \1 /home/vagrant /Sites \5
original_filepath=$1
vagrant_basepath=$2
local_basepath=$3
current_pwd=$4
# remove quotes from var_dump if present
original_filepath_temp="${original_filepath%\"}"
original_filepath="${original_filepath_temp#\"}"
# look for /home/vagrant in the $original_filepath
if [[ $original_filepath =~ ^(\/home\/vagrant) ]];
then
new_filepath="${original_filepath/$vagrant_basepath/$local_basepath}"
# echo $new_filepath > ~/Library/Logs/iterm.log
/usr/local/bin/subl $new_filepath
# default local handling
else
original_filepath="$current_pwd/$original_filepath"
# echo $original_filepath > ~/Library/Logs/iterm.log
/usr/local/bin/subl $original_filepath
fihttps://stackoverflow.com/questions/43077713
复制相似问题