diff --git a/CHANGELOG.md b/CHANGELOG.md index f18f46c6..72e5edbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,12 +17,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `buttonless` - Similar to transparent but also removed the buttons. - Add support for changing the colors from 16 to 256 in the `indexed_colors` config section - Add `save_to_clipboard` configuration option for copying selected text to the system clipboard +- New terminfo entry, `alacritty-direct`, that advertises 24-bit color support ### Changed - Inverse/Selection color is now modelled after XTerm/VTE instead of URxvt to improve consistency - First click on unfocused Alacritty windows is no longer ignored on platforms other than macOS - Reduce memory usage significantly by only initializing part of the scrollback buffer at startup +- The `alacritty` terminfo entry no longer requires the `xterm` definition to be + present on the system +- The default `TERM` value is no longer static; the `alacritty` entry is used if + available, otherwise the `xterm-256color` entry is used instead + +### Removed + +- The terminfo entry `alacritty-256color`. It is replaced by the `alacritty` + entry (which also advertises 256 colors) ### Fixed diff --git a/Cargo.lock b/Cargo.lock index be1e076e..7a524fca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,6 +35,7 @@ dependencies = [ "serde_json 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", "serde_yaml 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)", "static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "terminfo 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "vte 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "x11-dl 2.18.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -701,6 +702,14 @@ dependencies = [ "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "nom" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "notify" version = "4.0.6" @@ -828,6 +837,40 @@ name = "percent-encoding" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "phf" +version = "0.7.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "phf_shared 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "phf_codegen" +version = "0.7.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "phf_generator 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)", + "phf_shared 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "phf_generator" +version = "0.7.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "phf_shared 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "phf_shared" +version = "0.7.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "pkg-config" version = "0.3.14" @@ -1030,6 +1073,11 @@ dependencies = [ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "siphasher" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "slab" version = "0.3.0" @@ -1111,6 +1159,17 @@ dependencies = [ "wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "terminfo" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "nom 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "phf 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)", + "phf_codegen 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "termion" version = "1.5.1" @@ -1477,6 +1536,7 @@ dependencies = [ "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" "checksum nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d37e713a259ff641624b6cb20e3b12b2952313ba36b6823c0f16e6cfd9e5de17" +"checksum nom 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "898696750eb5c3ce5eb5afbfbe46e7f7c4e1936e19d3e97be4b7937da7b6d114" "checksum notify 4.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "873ecfd8c174964ae30f401329d140142312c8e5590719cf1199d5f1717d8078" "checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" @@ -1491,6 +1551,10 @@ dependencies = [ "checksum parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa" "checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +"checksum phf 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "cec29da322b242f4c3098852c77a0ca261c9c01b806cae85a5572a1eb94db9a6" +"checksum phf_codegen 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "7d187f00cd98d5afbcd8898f6cf181743a449162aeb329dcd2f3849009e605ad" +"checksum phf_generator 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "03dc191feb9b08b0dc1330d6549b795b9d81aec19efe6b4a45aec8d4caee0c4b" +"checksum phf_shared 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "b539898d22d4273ded07f64a05737649dc69095d92cb87c7097ec68e3f150b93" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)" = "ffe022fb8c8bd254524b0b3305906c1921fa37a84a644e29079a9e62200c3901" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" @@ -1517,6 +1581,7 @@ dependencies = [ "checksum servo-fontconfig 0.4.0 (git+https://github.com/jwilm/rust-fontconfig?branch=updated-2017-10-8)" = "" "checksum servo-fontconfig-sys 4.0.3 (git+https://github.com/jwilm/libfontconfig?branch=updated-2017-10-8)" = "" "checksum shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11" +"checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" "checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" "checksum slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5f9776d6b986f77b35c6cf846c11ad986ff128fe0b2b63a3628e3755e8d3102d" "checksum smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "153ffa32fd170e9944f7e0838edf824a754ec4c1fc64746fcc9fe1f8fa602e5d" @@ -1527,6 +1592,7 @@ dependencies = [ "checksum syn 0.15.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9056ebe7f2d6a38bc63171816fd1d3430da5a43896de21676dc5c0a4b8274a11" "checksum tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "55c1195ef8513f3273d55ff59fe5da6940287a0d7a98331254397f464833675b" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" +"checksum terminfo 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8e51065bafd2abe106b6036483b69d1741f4a1ec56ce8a2378de341637de689e" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" diff --git a/Cargo.toml b/Cargo.toml index 8adf3ef3..6c54c0ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,6 +39,7 @@ glutin = "0.16" env_logger = "0.5" base64 = "0.9.0" static_assertions = "0.2.5" +terminfo = "0.6.1" [target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os="dragonfly", target_os="openbsd"))'.dependencies] x11-dl = "2" diff --git a/README.md b/README.md index d7d299e9..a96ed29c 100644 --- a/README.md +++ b/README.md @@ -336,6 +336,27 @@ To install the completions for fish, run sudo cp alacritty-completions.fish $__fish_datadir/vendor_completions.d/alacritty.fish ``` +## Terminfo + +The terminfo database contains entries describing the terminal +emulator's capabilities. Programs need these in order to function +properly. + +Alacritty should work with the standard `xterm-256color` definition, +but to allow programs to make best use of alacritty's capabilities, +use its own terminfo definition instead. + +Unless the user has set the `TERM` environment variable in the +alacritty configuration, the `alacritty` terminfo definition will be +used if it has been installed. If not, then `xterm-256color` is used +instead. + +To install alacritty's terminfo entry globally: + +```sh +sudo tic -e alacritty,alacritty-direct alacritty.info +``` + ## Configuration Although it's possible the default configuration would work on your system, diff --git a/alacritty.info b/alacritty.info index 72e33354..b693d248 100644 --- a/alacritty.info +++ b/alacritty.info @@ -1,8 +1,109 @@ -alacritty| alacritty, - use=xterm-256color, - ritm=\E[23m, - sitm=\E[3m, - Tc, +alacritty|alacritty terminal emulator, + use=alacritty+common, + rs1=\Ec\E]104\007, + ccc, + colors#0x100, pairs#0x10000, + initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%* + %{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\, + oc=\E]104\007, + setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48; + 5;%p1%d%;m, + setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5 + ;%p1%d%;m, + setb@, setf@, -alacritty-256color| alacritty with 256 colors, - use=alacritty, +alacritty-direct|alacritty with direct color indexing, + use=alacritty+common, + RGB, + colors#0x1000000, pairs#0x10000, + initc@, op=\E[39;49m, + setab=\E[%?%p1%{8}%<%t4%p1%d%e48;2;%p1%{65536}%/%d;%p1%{256} + %/%{255}%&%d;%p1%{255}%&%d%;m, + setaf=\E[%?%p1%{8}%<%t3%p1%d%e38;2;%p1%{65536}%/%d;%p1%{256} + %/%{255}%&%d;%p1%{255}%&%d%;m, + setb@, setf@, + +alacritty+common|base fragment for alacritty, + OTbs, am, bce, km, mir, msgr, xenl, AX, XT, + colors#8, cols#80, it#8, lines#24, pairs#64, + acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, + bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l, + clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=\r, + csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, + cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C, + cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A, + cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, + dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, + el1=\E[1K, flash=\E[?5h$<100/>\E[?5l, home=\E[H, + hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@, + il=\E[%p1%dL, il1=\E[L, ind=\n, invis=\E[8m, + is2=\E[!p\E[?3;4l\E[4l\E>, kmous=\E[M, meml=\El, + memu=\Em, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, + rmacs=\E(B, rmam=\E[?7l, rmir=\E[4l, rmkx=\E[?1l\E>, + rmm=\E[?1034l, rmso=\E[27m, rmul=\E[24m, rs1=\Ec, + rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7, setab=\E[4%p1%dm, + setaf=\E[3%p1%dm, + setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6} + %=%t3%e%p1%d%;m, + setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6} + %=%t3%e%p1%d%;m, + sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p5%t;2%;%?%p2%t;4%; + %?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m, + sgr0=\E(B\E[m, smacs=\E(0, smam=\E[?7h, smir=\E[4h, + smkx=\E[?1h\E=, smm=\E[?1034h, smso=\E[7m, smul=\E[4m, + tbc=\E[3g, vpa=\E[%i%p1%dd, E3=\E[3J, + kbs=^H, + ritm=\E[23m, sitm=\E[3m, + mc5i, + mc0=\E[i, mc4=\E[4i, mc5=\E[5i, + u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?%[;0123456789]c, + u9=\E[c, + rmcup=\E[?1049l\E[23;0;0t, smcup=\E[?1049h\E[22;0;0t, + npc, + indn=\E[%p1%dS, kb2=\EOE, kcbt=\E[Z, kent=\EOM, + rin=\E[%p1%dT, + rep=%p1%c\E[%p2%{1}%-%db, + rmxx=\E[29m, smxx=\E[9m, + XM=\E[?1006;1000%?%p1%{1}%=%th%el%;, + xm=\E[<%p1%d;%p2%d;%p3%d;%?%p4%tM%em%;, + kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kend=\EOF, + khome=\EOH, + kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, + kf13=\E[1;2P, kf14=\E[1;2Q, kf15=\E[1;2R, kf16=\E[1;2S, + kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, + kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~, + kf23=\E[23;2~, kf24=\E[24;2~, kf25=\E[1;5P, kf26=\E[1;5Q, + kf27=\E[1;5R, kf28=\E[1;5S, kf29=\E[15;5~, kf3=\EOR, + kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~, + kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~, + kf36=\E[24;5~, kf37=\E[1;6P, kf38=\E[1;6Q, kf39=\E[1;6R, + kf4=\EOS, kf40=\E[1;6S, kf41=\E[15;6~, kf42=\E[17;6~, + kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~, + kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, + kf49=\E[1;3P, kf5=\E[15~, kf50=\E[1;3Q, kf51=\E[1;3R, + kf52=\E[1;3S, kf53=\E[15;3~, kf54=\E[17;3~, + kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~, + kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, + kf61=\E[1;4P, kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~, + kf8=\E[19~, kf9=\E[20~, + kLFT=\E[1;2D, kRIT=\E[1;2C, kind=\E[1;2B, kri=\E[1;2A, + kDN=\E[1;2B, kDN3=\E[1;3B, kDN4=\E[1;4B, kDN5=\E[1;5B, + kDN6=\E[1;6B, kDN7=\E[1;7B, kLFT3=\E[1;3D, kLFT4=\E[1;4D, + kLFT5=\E[1;5D, kLFT6=\E[1;6D, kLFT7=\E[1;7D, + kRIT3=\E[1;3C, kRIT4=\E[1;4C, kRIT5=\E[1;5C, + kRIT6=\E[1;6C, kRIT7=\E[1;7C, kUP=\E[1;2A, kUP3=\E[1;3A, + kUP4=\E[1;4A, kUP5=\E[1;5A, kUP6=\E[1;6A, kUP7=\E[1;7A, + kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~, + kNXT=\E[6;2~, kPRV=\E[5;2~, kich1=\E[2~, knp=\E[6~, + kpp=\E[5~, kDC3=\E[3;3~, kDC4=\E[3;4~, kDC5=\E[3;5~, + kDC6=\E[3;6~, kDC7=\E[3;7~, kEND3=\E[1;3F, kEND4=\E[1;4F, + kEND5=\E[1;5F, kEND6=\E[1;6F, kEND7=\E[1;7F, + kHOM3=\E[1;3H, kHOM4=\E[1;4H, kHOM5=\E[1;5H, + kHOM6=\E[1;6H, kHOM7=\E[1;7H, kIC3=\E[2;3~, kIC4=\E[2;4~, + kIC5=\E[2;5~, kIC6=\E[2;6~, kIC7=\E[2;7~, kNXT3=\E[6;3~, + kNXT4=\E[6;4~, kNXT5=\E[6;5~, kNXT6=\E[6;6~, + kNXT7=\E[6;7~, kPRV3=\E[5;3~, kPRV4=\E[5;4~, + kPRV5=\E[5;5~, kPRV6=\E[5;6~, kPRV7=\E[5;7~, + kdch1=\E[3~, + Cr=\E]112\007, Cs=\E]12;%p1%s\007, + Ms=\E]52;%p1%s;%p2%s\007, Se=\E[2 q, Ss=\E[%p1%d q, diff --git a/alacritty.yml b/alacritty.yml index e6578ffa..91bff074 100644 --- a/alacritty.yml +++ b/alacritty.yml @@ -5,14 +5,14 @@ # environment variables. Some entries may override variables # set by alacritty itself. env: - # TERM env customization + # TERM variable # - # If this property is not set, alacritty will set it to `xterm-256color`. + # This value is used to set the `$TERM` environment variable for + # each instance of Alacritty. If it is not present, alacritty will + # check the local terminfo database and use 'alacritty' if it is + # available, otherwise 'xterm-256color' is used. # - # Note that some xterm terminfo databases don't declare support for italics. - # You can verify this by checking for the presence of `smso` and `sitm` in - # `infocmp xterm-256color`. - TERM: xterm-256color + # TERM: xterm-256color window: # Window dimensions (changes require restart) @@ -336,6 +336,9 @@ live_config_reload: true # it possible to pass escape sequences. # To find escape codes for bindings like `PageUp` ("\x1b[5~"), you can run # the command `showkey -a` outside of tmux. +# Note that applications use terminfo to map escape sequences back to +# keys. It is therefore required to update the terminfo when +# changing an escape sequence. # # Values for `action`: # - Paste diff --git a/alacritty_macos.yml b/alacritty_macos.yml index 9782c5df..8ce0181a 100644 --- a/alacritty_macos.yml +++ b/alacritty_macos.yml @@ -4,14 +4,14 @@ # environment variables. Some entries may override variables # set by alacritty itself. env: - # TERM env customization + # TERM variable # - # If this property is not set, alacritty will set it to `xterm-256color`. + # This value is used to set the `$TERM` environment variable for + # each instance of Alacritty. If it is not present, alacritty will + # check the local terminfo database and use 'alacritty' if it is + # available, otherwise 'xterm-256color' is used. # - # Note that some xterm terminfo databases don't declare support for italics. - # You can verify this by checking for the presence of `smso` and `sitm` in - # `infocmp xterm-256color`. - TERM: xterm-256color + # TERM: xterm-256color window: # Window dimensions (changes require restart) @@ -332,6 +332,9 @@ live_config_reload: true # it possible to pass escape sequences. # To find escape codes for bindings like `PageUp` ("\x1b[5~"), you can run # the command `showkey -a` outside of tmux. +# Note that applications use terminfo to map escape sequences back to +# keys. It is therefore required to update the terminfo when +# changing an escape sequence. # # Values for `action`: # - Paste diff --git a/src/lib.rs b/src/lib.rs index d9006fe0..fcc55799 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,6 +50,7 @@ extern crate unicode_width; extern crate vte; extern crate xdg; extern crate base64; +extern crate terminfo; #[macro_use] pub mod macros; diff --git a/src/tty.rs b/src/tty.rs index 9f6a2e64..b9d00fa5 100644 --- a/src/tty.rs +++ b/src/tty.rs @@ -22,12 +22,14 @@ use std::ptr; use std::process::{Command, Stdio}; use libc::{self, winsize, c_int, pid_t, WNOHANG, SIGCHLD, TIOCSCTTY}; +use terminfo::Database; use term::SizeInfo; use display::OnResize; use config::{Config, Shell}; use cli::Options; + /// Process ID of child process /// /// Necessary to put this in static storage for `sigchld` to have access @@ -210,7 +212,16 @@ pub fn new(config: &Config, options: &Options, size: &T, window_id builder.env("USER", pw.name); builder.env("SHELL", shell.program()); builder.env("HOME", pw.dir); - builder.env("TERM", "xterm-256color"); // default term until we can supply our own + + // TERM; default to 'alacritty' if it is available, otherwise + // default to 'xterm-256color'. May be overridden by user's config + // below. + let mut term = "alacritty"; + if let Err(_) = Database::from_name("alacritty") { + term = "xterm-256color"; + } + builder.env("TERM", term); + builder.env("COLORTERM", "truecolor"); // advertise 24-bit support if let Some(window_id) = window_id { builder.env("WINDOWID", format!("{}", window_id));