about summary refs log tree commit diff stats
path: root/html/076continuation.cc.html
Commit message (Expand)AuthorAgeFilesLines
* 4891Kartik Agaram2018-12-301-0/+1
* 4890 - new html renderingsKartik Agaram2018-12-291-16/+11
* 4814Kartik Agaram2018-12-011-54/+57
* 4709Kartik Agaram2018-10-171-18/+18
* 4539Kartik Agaram2018-09-071-7/+7
* 4447Kartik Agaram2018-07-271-39/+39
* 4239Kartik Agaram2018-05-081-197/+210
* 4228Kartik K. Agaram2018-03-151-292/+313
* 4199Kartik K. Agaram2018-01-251-255/+143
* 4161Kartik K. Agaram2017-12-151-280/+329
* 4155Kartik K. Agaram2017-12-071-196/+237
* 4134 - 'input' = 'ingredient'Kartik K. Agaram2017-12-031-184/+214
* 4118Kartik K. Agaram2017-11-061-291/+292
* 4117 - done with delimited continuationsKartik K. Agaram2017-11-061-288/+291
* 4113Kartik K. Agaram2017-11-051-288/+291
* 4109Kartik K. Agaram2017-11-051-177/+309
* 4102Kartik K. Agaram2017-11-011-8/+8
* 3995Kartik K. Agaram2017-09-131-6/+6
* 3990Kartik K. Agaram2017-09-031-0/+256
>
aa488bd9 ^


d0d194d8 ^
aa488bd9 ^
43e0f44a ^
bf14a7e7 ^

1a8e1924 ^
3744fed3 ^
d0d194d8 ^

fecebfe8 ^
ff725e2b ^
fecebfe8 ^
98f3d958 ^

f3c29a69 ^



bf14a7e7 ^

3dbf8b38 ^


fecebfe8 ^
bf14a7e7 ^

356726c4 ^
bf14a7e7 ^

f51fc9f6 ^
aa488bd9 ^
bf14a7e7 ^
356726c4 ^
fecebfe8 ^
ff725e2b ^

87b0d82e ^
ff725e2b ^
87b0d82e ^




43e0f44a ^

43e0f44a ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
           
                                                                        

                                                                         
 
                                                                        

                                                                              

                         

                                                                

                                                        
                                                           








                                                                        

                                                                             

                                        
                     
 


                                                                   
                                                                             
                                               
 

                             
                                                                             
                                                                        

                                                                            
                        
                        
            

                                                                                         



                                                                    

                       


                                                                                                 
                                                                        

    
                   

                                          
                                                                    
                                             
                                   
                
                                                                                  

                                                
                                                           
                                                                                    




                                                              

    
      
#!/bin/bash
# ranger supports enhanced previews.  If the option "use_preview_script"
# is set to True and this file exists, this script will be called and its
# output is displayed in ranger.  ANSI color codes are supported.

# NOTES: This script is considered a configuration file.  If you upgrade
# ranger, it will be left untouched. (You must update it yourself.)
# Also, ranger disables STDIN here, so interactive scripts won't work properly

# Meanings of exit codes:
# code | meaning    | action of ranger
# -----+------------+-------------------------------------------
# 0    | success    | success. display stdout as preview
# 1    | no preview | failure. display no preview at all
# 2    | plain text | display the plain content of the file
# 3    | fix width  | success. Don't reload when width changes
# 4    | fix height | success. Don't reload when height changes
# 5    | fix both   | success. Don't ever reload

# Meaningful aliases for arguments:
path="$1"    # Full path of the selected file
width="$2"   # Width of the preview pane (number of fitting characters)
height="$3"  # Height of the preview pane (number of fitting characters)

maxln=200    # Stop after $maxln lines.  Can be used like ls | head -n $maxln

# Find out something about the file:
mimetype=$(file --mime-type -Lb "$path")
extension=${path##*.}

# Functions:
# "have $1" succeeds if $1 is an existing command/installed program
function have { type -P "$1" > /dev/null; }
# "success" returns the exit code of the first program in the last pipe chain
function success { test ${PIPESTATUS[0]} = 0; }

case "$extension" in
	# Archive extensions:
	7z|a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\
	rar|rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)
		als "$path" | head -n $maxln
		success && exit 0 || acat "$path" | head -n $maxln && exit 3
		exit 1;;
	# PDF documents:
	pdf)
		pdftotext -l 10 -nopgbrk -q "$path" - | head -n $maxln | fmt -s -w $width
		success && exit 0 || exit 1;;
	# BitTorrent Files
	torrent)
		transmission-show "$path" | head -n $maxln && exit 3
		success && exit 5 || exit 1;;
	# HTML Pages:
	htm|html|xhtml)
		have w3m    && w3m    -dump "$path" | head -n $maxln | fmt -s -w $width && exit 4
		have lynx   && lynx   -dump "$path" | head -n $maxln | fmt -s -w $width && exit 4
		have elinks && elinks -dump "$path" | head -n $maxln | fmt -s -w $width && exit 4
		;; # fall back to highlight/cat if theres no lynx/elinks
esac

case "$mimetype" in
	# Syntax highlight for text files:
	text/* | */xml)
		highlight --out-format=ansi "$path" | head -n $maxln
		success && exit 5 || exit 2;;
	# Ascii-previews of images:
	image/*)
		img2txt --gamma=0.6 --width="$width" "$path" && exit 4 || exit 1;;
	# Display information about media files:
	video/* | audio/*)
		have exiftool && exiftool "$path" && exit 5
		# Use sed to remove spaces so the output fits into the narrow window
		if have mediainfo; then
			mediainfo "$path" | sed 's/  \+:/: /;'
			success && exit 5
		fi
		exit 1;;
esac

exit 1