Skip to content

Commit

Permalink
ch08/drop s
Browse files Browse the repository at this point in the history
  • Loading branch information
lymslive committed Dec 14, 2018
1 parent da0c488 commit 198acd1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions example/ch08/drop
11 changes: 11 additions & 0 deletions example/ch08/drop.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /usr/bin/env perl
# 从 vim 内置终端发送 drop 消息打开文件
# 传输的 json 消息必须用双引号 ""
use strict;
use warnings;

use Cwd 'abs_path';
my $filename = shift or die "usage: dorp filename";
my $filepath = abs_path($filename);
exec "vim $filepath" unless $ENV{VIM};
print qq{\x1B]51;["drop", "$filepath"]\x07};
7 changes: 7 additions & 0 deletions example/ch08/drop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /usr/bin/env python
import sys, os
if len(sys.argv) > 1:
fn = os.path.abspath(sys.argv[1])
sys.stdout.write('\x1b]51;["drop", "%s"]\x07'%fn)

# https://www.zhihu.com/question/278228687/answer/413375553
4 changes: 4 additions & 0 deletions example/ch08/drop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/bash

# echo -e '\e]51;["drop", "$1"]\x07'
echo -e "\e]51;[\"drop\", \"$1\"]\x07"

0 comments on commit 198acd1

Please sign in to comment.