aboutsummaryrefslogtreecommitdiff
path: root/vim/.vim/plugged/fzf.vim/bin/preview.rb
diff options
context:
space:
mode:
authorKumar Damani <damani.kumar@gmail.com>2019-05-16 22:16:09 +0000
committerKumar Damani <damani.kumar@gmail.com>2019-05-16 22:16:09 +0000
commit12564a8f73ebe721d415a04d36f7aac7091bea9d (patch)
treebbc8a6bf6aabe832b3ee435eaa605dcac655fc5f /vim/.vim/plugged/fzf.vim/bin/preview.rb
parent1241da7ab7a4e91248391ee9b045267bcbbeee4f (diff)
updating vimrc
Diffstat (limited to 'vim/.vim/plugged/fzf.vim/bin/preview.rb')
-rw-r--r--vim/.vim/plugged/fzf.vim/bin/preview.rb59
1 files changed, 0 insertions, 59 deletions
diff --git a/vim/.vim/plugged/fzf.vim/bin/preview.rb b/vim/.vim/plugged/fzf.vim/bin/preview.rb
deleted file mode 100644
index 48feef5..0000000
--- a/vim/.vim/plugged/fzf.vim/bin/preview.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/env ruby
-#
-# usage: ./preview.rb FILENAME[:LINE][:IGNORED]
-
-require 'open3'
-require 'shellwords'
-
-COMMAND = ENV.fetch(
- 'FZF_PREVIEW_COMMAND',
- %[bat --style=numbers --color=always {} || highlight -O ansi -l {} || coderay {} || rougify {} || cat {}]
-)
-ANSI = /\x1b\[[0-9;]*m/
-REVERSE = "\x1b[7m"
-RESET = "\x1b[m"
-
-def usage
- puts "usage: #$0 FILENAME[:LINENO][:IGNORED]"
- exit 1
-end
-
-usage if ARGV.empty?
-
-file, center, extra = ARGV.first.split(':')
-if ARGV.first =~ /^[A-Z]:\\/
- file << ':' + center
- center = extra
-end
-usage unless file
-
-path = File.expand_path(file)
-unless File.readable? path
- puts "File not found: #{file}"
- exit 1
-end
-
-if `file --mime "#{file}"` =~ /binary/
- puts "#{file} is a binary file"
- exit 0
-end
-
-center = (center || 0).to_i
-height =
- if ENV['LINES']
- ENV['LINES'].to_i
- else
- File.readable?('/dev/tty') ? `stty size < /dev/tty`.split.first.to_i : 40
- end
-offset = [1, center - height / 3].max
-
-Open3.popen3(COMMAND.gsub('{}', Shellwords.shellescape(path))) do |_in, out, _err|
- out.each_line.drop(offset - 1).take(height).each_with_index do |line, lno|
- if lno + offset == center
- puts REVERSE + line.chomp.gsub(ANSI) { |m| m + REVERSE } + RESET
- else
- puts line
- end
- end
-end
-print RESET