- lsix एक Bash script है जो
ls की तरह current directory या निर्दिष्ट files की list के लिए images को terminal के अंदर thumbnails के रूप में दिखाता है, और output में Sixel graphics का उपयोग करता है
- यह ImageMagick का उपयोग करके कई image formats को process करता है, और command line पर GIF या कई images वाली file निर्दिष्ट करने पर frames को फैलाकर montage के रूप में दिखाता है
- यह terminal में Sixel support, foreground color・background color, color registers expand किए जा सकते हैं या नहीं, और window width detect करके thumbnail quality और layout adjust करता है
- Installation के लिए
lsix file को path में डालकर ImageMagick तैयार करना होता है; macOS पर brew install lsix से ImageMagick भी साथ में install किया जा सकता है
- XTerm में default रूप से Sixel mode बंद होता है और कुछ terminals compatible नहीं हैं, इसलिए actual use से पहले यह confirm करना चाहिए कि वह Sixel-compatible terminal है या नहीं
ls की तरह इस्तेमाल होने वाला terminal image listing tool
- lsix images के लिए
ls जैसा tool है, जो terminal में file thumbnails inline दिखाता है
- इसका basic execution तरीका सरल है
- सिर्फ
lsix enter करने पर current working directory की images दिखती हैं
lsix [ FILES ... ] के रूप में filenames specify किए जा सकते हैं
- shell wildcards इस्तेमाल किए जा सकते हैं, इसलिए
lsix *jpg * png जैसा run संभव है
- Output में Sixel graphics का इस्तेमाल होता है
ImageMagick-based format handling और display तरीका
- ImageMagick का उपयोग करने से कई तरह के image formats support होते हैं
- PDF जैसे formats, जिनकी rendering धीमी हो सकती है, उन्हें explicitly request न करने पर display नहीं किया जाता
- किसी specific format को forcefully list करने के लिए filename सीधे specify करें या
*.pdf जैसे wildcard का उपयोग करें
- Command line पर GIF या कई images वाली file specify करने पर सभी frames को फैलाकर montage के रूप में दिखाया जाता है
- GIF कुछ frames में previous frame से बदले हुए pixels ही store कर सकता है
- Non-bitmap graphics भी काम कर सकते हैं
- उदाहरण:
.svg, .eps, .pdf, .xcf
Terminal environment detection features
- lsix control sequences का उपयोग करके detect करता है कि terminal Sixel graphics को inline display कर सकता है या नहीं
- PNG और SVG के alpha channels को terminal background color के अनुसार process किया जाता है
- lsix terminal escape sequences से foreground color और background color पता करने की कोशिश करता है
- Foreground color text fill color के लिए इस्तेमाल होता है
- xterm जैसे terminals, जिनमें color registers की संख्या बढ़ाई जा सकती है, detect होने पर image quality बढ़ाने के लिए उन्हें automatically expand किया जाता है
- dtterm WindowOps support करने वाले terminals में window width के अनुसार एक line में tiles की संख्या adjust की जाती है
- Directory में images बहुत अधिक होने पर पूरे montage generation का इंतज़ार न करना पड़े, इसके लिए handling की जाती है
- Images 21 से ज़्यादा हों तो उन्हें line-by-line display किया जाता है
- Filename बहुत लंबा हो तो ImageMagick
montage को pass करने से पहले text में line breaks डाले जाते हैं
- lsix के बिना
montage इस्तेमाल करने पर लंबे filenames एक-दूसरे पर overlap कर सकते हैं
- Unicode filenames तब काम करते हैं जब इस्तेमाल किए जा रहे font में glyphs मौजूद हों
Installation और configuration तरीका
- Installation के लिए
lsix file को /usr/local/bin जैसे path में रखकर run करें
- lsix एक Bash shell script है
- Required software सिर्फ ImageMagick है
- उदाहरण:
apt-get install imagemagick
- macOS users
brew install lsix इस्तेमाल कर सकते हैं
- जरूरत पड़ने पर ImageMagick भी साथ में install हो जाता है
- Current design बहुत सरल है
- कोई command-line flags नहीं
- कोई config file नहीं
- adjustment के लिए कोई knobs नहीं
- Tile width, font family, point size जैसी values file के top पर variables edit करके बदली जा सकती हैं
- Installed fonts की list
convert -list font से check की जा सकती है
Sixel support वाले terminal की requirements
- Terminal को Sixel graphics support करना चाहिए
- एक single image को Sixel में output करके terminal test किया जा सकता है
convert foo.jpg -geometry 800x480 sixel:-
- Development में xterm का vt340 emulation mode इस्तेमाल हुआ
- XTerm में default रूप से Sixel mode enabled नहीं होता
- Run करते समय
xterm -ti vt340 इस्तेमाल किया जा सकता है
- या
.Xresources में xterm*decTerminalID : vt340 add करके xrdb -merge .Xresources run किया जा सकता है
- Fedora जैसे कुछ distributions
xterm को Sixel support के बिना compile कर सकते हैं
- इस स्थिति में
foot या mlterm जैसे alternative terminals try किए जा सकते हैं
Compatible और incompatible terminals
- Sixel-compatible terminals के रूप में confirmed या reported items
- XTerm, MLterm, foot, Wezterm, Contour, iTerm2 for Apple MacOS, Yaft test किए गए हैं
- Konsole, yakuake, WSLtty for Microsoft Windows, MinTTY for Cygwin, VTE special compile, sixel-tmux, ttyd reported हैं
- Sixel-incompatible terminals
- MacOS Terminal, kitty
- Standard libvte-based terminals
- gnome-terminal
- terminator
- lxterm
- Alacritty patch apply करने पर काम कर सकता है
Known bugs और limitations
- XTerm का reverse video mode
xterm -rv, foreground color और background color को explicitly specify करने जैसा नहीं है
- Explicit specification detect करने का तरीका है, लेकिन reverseVideo resource detect नहीं किया जा सकता, इसलिए background color गलत हो सकता है
- XTerm की screen width अभी 1000px तक limited है
- जब xterm 1000x1000 से बड़ी images process कर सकेगा, तब limitation हटाने की योजना है
- आखिरी test XTerm(344) के आधार पर था
@ से शुरू होने वाले filenames को ImageMagick special तरीके से handle करता है
lsix ./@foo.png की तरह directory आगे लगानी चाहिए
- यह lsix नहीं, बल्कि ImageMagick bug है
- Filename के रूप में empty string
"" specify करने पर ImageMagick hang हो जाता है
- यह ImageMagick bug या गलत behavior लगता है
- Long filename line wrapping काम करता है, लेकिन intelligent नहीं है
- Spaces, dash, underscore, period के आधार पर line wrapping अभी implemented नहीं है
- Command line पर directory specify करने पर इसे ऐसे handle किया जाता है जैसे user ने उस directory में
cd किया हो
- Recursive processing मुश्किल नहीं है, लेकिन simple script में command-line flags जोड़ने से परहेज है
lsix foo.avi run करने से problems हो सकती हैं
Sixel standard और implementation limitations
- Sixel standard में graphics screen size query करने का तरीका नहीं दिखता
- VT340 documentation के आधार पर, program को rendering target device का resolution पहले से पता होना चाहिए
- XTerm 344 ने इस समस्या को solve करने वाला control sequence
CSI ? Pi ; Pa ; Pv S add किया
mlterm जैसे कुछ terminals ने अभी इसे implement नहीं किया है
- dtterm WindowOps extension से window size पढ़ने का alternative है
- Sixel graphics screen की geometry और window size जरूरी नहीं कि समान हों, इसलिए यह exact solution नहीं है
- उदाहरण के लिए xterm, window बड़ी होने पर भी graphics geometry को 1000x1000 तक limit करता है
- अगर दोनों methods fail हों, तो lsix VT340 environment मान लेता है
- Resolution 800x480
- माना जाता है कि एक line में सिर्फ 6 tiles fit होते हैं
- Sixel standard available color registers की संख्या query करने का तरीका भी provide नहीं करता
- lsix xterm extension का उपयोग करता है
- Terminal response न दे तो original VT340 माना जाता है और केवल 16 color registers इस्तेमाल होते हैं
libsixel का इस्तेमाल न करने का कारण
- libsixel optimized Sixel graphics commands output करने वाला project है
- lsix libsixel के बजाय Bash और ImageMagick का उपयोग करता है
- Bash और ImageMagick व्यापक रूप से उपलब्ध हैं, इसलिए कहीं भी आसानी से चलाने के लिए यह choice है
- Script को simple रखता है ताकि users इसे आसानी से modify और extend कर सकें
- ImageMagick, libsixel के
img2sixel द्वारा इस्तेमाल किए जाने वाले stb_image से ज्यादा variety के input formats पढ़ सकता है
- उदाहरण: xpm, svg, 16-bit png, sixel files
- ImageMagick input पढ़कर Sixel output सीधे लिख सकता है
- libsixel तेज़ हो सकता है, लेकिन simple directory listing display के लिए ImageMagick भी काफी fast है
References
1 टिप्पणियां
Hacker News की रायें
अगर मेरी तरह tmux के बिना टर्मिनल इस्तेमाल करना मुश्किल लगता है, तो जो Sixel ब्रांच प्रयोगात्मक थी, वह करीब 10 महीने पहले आखिरकार merge हो गई थी
अब mainline tmux को
--enable-sixelके साथ build करके tmux के अंदरlsixजैसे टूल इस्तेमाल कर सकते हैंअगर जानना हो कि आपका पसंदीदा टर्मिनल या terminal multiplexer Sixel को support करता है या नहीं, तो "Are We Sixel Yet" साइट देख सकते हैं
https://github.com/tmux/tmux/commit/dfbc6b1888c110cf0ade66f2...
https://www.arewesixelyet.com
अगर अपने workflow में बदलाव लाना चाहते हैं, तो मेरी राय में यह default state में tmux से कहीं बेहतर अनुभव है
जो features पहले external plugins और जटिल config scripts से जोड़ने पड़ते, वे इसमें default रूप से शामिल हैं, और stability व performance भी काफी बेहतर रहे
https://zellij.dev/
क्या बता सकते हैं कि यह workflow के लिए अनिवार्य tool क्यों बन जाता है, और मेरे काम के लिए भी क्यों जरूरी हो सकता है?
क्या यह मौजूदा tiling तरीके की तुलना में tmux में stack-type window manager लाने जैसा बदलाव है? या बस terminal graphics बेहतर हो जाते हैं? क्या मैं इसे पूरी तरह गलत समझ रहा हूं?
अगर यह सिर्फ graphics बेहतर होने की बात है, तो समझ नहीं आता कि tmux को इसका support क्यों देना चाहिए; Gnome Terminal जैसे terminal emulator ज्यादा महत्वपूर्ण लगते हैं। शायद दोनों की जरूरत हो, लेकिन मुझे लगा था tmux को बस pass-through कर देना चाहिए
brewसे tmux install करने पर Sixel enabled होता है या नहीं?इस repository में मुझे सबसे पसंद आने वाला feature
README.md.ddirectory हैयह काफी अच्छा idea है, और लगता है कि
.mdहटाया भी जा सकता हैतब सिर्फ
cat READMEकरने पर भी images वैसे ही दिख सकते हैं"\e[c"का उपयोग करके Sixel support को automatically detect करता हैhttps://github.com/hackerb9/lsix/blob/3a431793a747df3f934051...
"\e[c"का मतलब "send device attributes" हैhttps://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-F...
idea अच्छा है, लेकिन PuTTY/KiTTY में काम नहीं करता
$ lsixचलाने पर error आता है कि terminal Sixel graphics support report नहीं करता, औरxterm -ti vt340जैसे Sixel-supporting terminal का इस्तेमाल करने या terminal creator से support मांगने को कहता हैsingle image को
convert foo.jpg -geometry 800x480 sixel:-से test किया जा सकता है, और अगर terminal सच में support करता हो तो http://github.com/hackerb9/lsix/issues पर bug report करने को बताता हैdevice attributes code
^[[?6cके रूप में दिखता हैअफसोस। यह काफी शानदार होता। क्या Sixel support करने वाला कोई open-source Windows terminal है? ज्यादातर Cygwin या WSL वाले दिखते हैं, pure Windows के लिए ज्यादा नजर नहीं आते
यह cross-platform है और Sixel graphics support करता है
https://github.com/wez/wezterm
इसी तरह की category में timg भी है: https://github.com/hzeller/timg
MacOS के लिए iTerm2 में similar feature built-in है, और server side पर load कम पड़ता है
server पर कई image libraries से image को Sixel में render करने के बजाय, पूरी image को base64 encode करके client को भेजता है और client image format पहचानकर terminal में locally render करता है
https://iterm2.com/documentation-images.html
Linux पर unmodified
imgcatscript ज्यों की त्यों इस्तेमाल कर रहा हूंImageMagick से convert करने की तुलना में जाहिर तौर पर बहुत तेज है, लेकिन फिलहाल
lsixको भीbindirectory में जोड़ रखा हैuntrusted directory में चलाते समय सावधान रहना चाहिए
खासकर PDF जैसी चीजें जो images parse करती हैं, वे दूसरे tools की तरह risky हो सकती हैं, और ImageMagick इस्तेमाल करते समय और ज्यादा सावधानी चाहिए
अगर untrusted downloads folder को Gnome Files में खोलने पर वह अंदर की images दिखाता है और इसलिए parse करता है, तो क्या यह security issue है जिस पर ध्यान देना चाहिए?
PDF के अंदर JavaScript जैसी चीजें problem हो सकती हैं, यह सोचता था, लेकिन simple preview तक risky हो सकता है, ऐसा नहीं सोचा था
आपका terminal Sixel graphics support करना चाहिए
https://github.com/dheera/python-termgraphics
इस library को modify करके fallback path के रूप में support देना दिलचस्प हो सकता है
TERM=xterm256-colorजैसी value set करना सब compatible ही होगा… है न? खांसी gnome-terminal खांसीfzf 0.44.0 से preview pane में experimental Sixel image support देता है
Windows पर इस्तेमाल नहीं किया जा सकता
https://github.com/junegunn/fzf/releases/tag/0.44.0
fzf --preview='fzf-preview.sh {}'fzf --preview 'convert {} -geometry 800x480 sixel:-'इस्तेमाल कर सकते हैंइसके लिए भी ImageMagick install होना जरूरी है