on master help sign in
Merge remote-tracking branch 'upstream/master' into feature-tabs

# Conflicts: # src/printer.rs

commit1807f9653cb27a16f9b7d7e445217562ef8d612a authoreth-p <32112321+eth-p@users.noreply.github.com> dateTue 11 Sep 2018, 14:03 (8 years ago) parent1e74f0e4e3ab4d
6 files changed+65−9
.travis.yml+7−1 README.md+24 ci/before_deploy.bash+14−1 ci/before_install.bash+8 ci/script.bash+1−1 src/printer.rs+11−6
.travis.yml+7−1
@@ -23,7 +23,13 @@ matrix:
2323 - TARGET=arm-unknown-linux-gnueabihf
2424 - CC_arm_unknown_linux_gnueabihf=/usr/bin/arm-linux-gnueabihf-gcc-4.8
2525 - CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc-4.8
26−
26+ - os: linux
27+ rust: stable
28+ env:
29+ - TARGET=aarch64-unknown-linux-gnu
30+ - CC_aarch64-unknown-linux-gnu=/usr/bin/aarch64-linux-gnu-gcc-4.8
31+ - CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc-4.8
32+
2733 # Minimum Rust supported channel.
2834 - os: linux
2935 rust: 1.26.0
README.md+24
@@ -134,6 +134,8 @@ or install it with [scoop](https://scoop.sh/):
134134scoop install bat
135135```
136136
137+[See below](#using-bat-on-windows) for notes.
138+
137139### From binaries
138140
139141Check out the [Release page](https://github.com/sharkdp/bat/releases) for
@@ -235,6 +237,28 @@ script as a wrapper, for example:
235237less --tabs 4 -RF "$@"
236238```
237239
240+## Using `bat` on Windows
241+
242+`bat` mostly works out-of-the-box on Windows, but a few features may need extra configuration.
243+
244+### Paging
245+
246+Windows only includes a very limited pager in the form of `more`. You can download a Windows binary
247+for `less` [from its homepage](http://www.greenwoodsoftware.com/less/download.html) or [through
248+Chocolatey](https://chocolatey.org/packages/Less). To use it, place the binary in a directory in
249+your `PATH` or [define an environment variable](#using-a-different-pager).
250+
251+### Colours
252+
253+Windows 10 natively supports colours in both `conhost.exe` (Command Prompt) and PowerShell since
254+[v1511](https://en.wikipedia.org/wiki/Windows_10_version_history#Version_1511_(November_Update)), as
255+well as in newer versions of bash. On earlier versions of Windows, you can use
256+[Cmder](http://cmder.net/), which includes [ConEmu](https://conemu.github.io/).
257+
258+**Note:** The Git and MSYS versions of `less` do not correctly interpret colours on Windows. If you
259+don’t have any other pagers installed, you can disable paging entirely by passing `--paging=never`
260+or by setting `BAT_PAGER` to an empty string.
261+
238262## Troubleshooting
239263
240264### Terminals & colors
ci/before_deploy.bash+14−1
@@ -19,6 +19,8 @@ pack() {
1919
2020 if [[ $TARGET == "arm-unknown-linux-gnueabihf" ]]; then
2121 gcc_prefix="arm-linux-gnueabihf-"
22+ elif [[ $TARGET == "aarch64-unknown-linux-gnu" ]]; then
23+ gcc_prefix="aarch64-linux-gnu-"
2224 else
2325 gcc_prefix=""
2426 fi
@@ -49,13 +51,24 @@ make_deb() {
4951 local version
5052 local dpkgname
5153 local conflictname
54+ local gcc_prefix
5255
5356 case $TARGET in
5457 x86_64*)
5558 architecture=amd64
59+ gcc_prefix=""
5660 ;;
5761 i686*)
5862 architecture=i386
63+ gcc_prefix=""
64+ ;;
65+ aarch64*)
66+ architecture=arm64
67+ gcc_prefix="aarch64-linux-gnu-"
68+ ;;
69+ arm*hf)
70+ architecture=armhf
71+ gcc_prefix="arm-linux-gnueabihf-"
5972 ;;
6073 *)
6174 echo "make_deb: skipping target '${TARGET}'" >&2
@@ -75,7 +88,7 @@ make_deb() {
7588
7689 # copy the main binary
7790 install -Dm755 "target/$TARGET/release/$PROJECT_NAME" "$tempdir/usr/bin/$PROJECT_NAME"
78− strip "$tempdir/usr/bin/$PROJECT_NAME"
91+ "${gcc_prefix}"strip "$tempdir/usr/bin/$PROJECT_NAME"
7992
8093 # manpage
8194 install -Dm644 "doc/$PROJECT_NAME.1" "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"
ci/before_install.bash+8
@@ -27,3 +27,11 @@ if [[ $TARGET == arm-unknown-linux-gnueabihf ]]; then
2727 libc6-armhf-cross \
2828 libc6-dev-armhf-cross
2929fi
30+
31+# needed for cross-compiling for arm64
32+if [[ $TARGET == aarch64-unknown-linux-gnu ]]; then
33+ sudo apt-get install -y \
34+ gcc-4.8-aarch64-linux-gnu \
35+ binutils-aarch64-linux-gnu \
36+ gcc-aarch64-linux-gnu
37+fi
ci/script.bash+1−1
@@ -6,7 +6,7 @@ set -ex
66cargo build --target "$TARGET" --verbose
77
88# We cannot run arm executables on linux
9−if [[ $TARGET != arm-unknown-linux-gnueabihf ]]; then
9+if [[ $TARGET != arm-unknown-linux-gnueabihf ]] && [[ $TARGET != aarch64-unknown-linux-gnu ]]; then
1010 cargo test --target "$TARGET" --verbose
1111
1212 # Run 'bat' on its own source code and the README
src/printer.rs+11−6
@@ -114,9 +114,13 @@ impl<'a> InteractivePrinter<'a> {
114114 }
115115
116116 // Get the Git modifications
117− let line_changes = match file {
118− InputFile::Ordinary(filename) => get_git_diff(filename),
119− _ => None,
117+ let line_changes = if config.output_components.changes() {
118+ match file {
119+ InputFile::Ordinary(filename) => get_git_diff(filename),
120+ _ => None,
121+ }
122+ } else {
123+ None
120124 };
121125
122126 // Determine the type of syntax for highlighting
@@ -210,11 +214,8 @@ impl<'a> Printer for InteractivePrinter<'a> {
210214 line_buffer: &[u8],
211215 ) -> Result<()> {
212216 let line = String::from_utf8_lossy(&line_buffer).to_string();
213−
214− // Highlight.
215217 let regions = self.highlighter.highlight(line.as_ref());
216218
217− // Print.
218219 if out_of_range {
219220 return Ok(());
220221 }
@@ -251,6 +252,10 @@ impl<'a> Printer for InteractivePrinter<'a> {
251252 as_terminal_escaped(style, &*text, true_color, colored_output,)
252253 )?;
253254 }
255+
256+ if line.bytes().next_back() != Some(b'\n') {
257+ write!(handle, "\n")?;
258+ }
254259 } else {
255260 for &(style, region) in regions.iter() {
256261 let mut ansi_iterator = AnsiCodeIterator::new(region);