diff --git a/.travis.yml b/.travis.yml index 28478f22..100f54fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,13 @@ matrix: - TARGET=arm-unknown-linux-gnueabihf - CC_arm_unknown_linux_gnueabihf=/usr/bin/arm-linux-gnueabihf-gcc-4.8 - CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc-4.8 - + - os: linux + rust: stable + env: + - TARGET=aarch64-unknown-linux-gnu + - CC_aarch64-unknown-linux-gnu=/usr/bin/aarch64-linux-gnu-gcc-4.8 + - CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc-4.8 + # Minimum Rust supported channel. - os: linux rust: 1.26.0 diff --git a/README.md b/README.md index 8485491d..0638911f 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,8 @@ or install it with [scoop](https://scoop.sh/): scoop install bat ``` +[See below](#using-bat-on-windows) for notes. + ### From binaries Check out the [Release page](https://github.com/sharkdp/bat/releases) for @@ -235,6 +237,28 @@ script as a wrapper, for example: less --tabs 4 -RF "$@" ``` +## Using `bat` on Windows + +`bat` mostly works out-of-the-box on Windows, but a few features may need extra configuration. + +### Paging + +Windows only includes a very limited pager in the form of `more`. You can download a Windows binary +for `less` [from its homepage](http://www.greenwoodsoftware.com/less/download.html) or [through +Chocolatey](https://chocolatey.org/packages/Less). To use it, place the binary in a directory in +your `PATH` or [define an environment variable](#using-a-different-pager). + +### Colours + +Windows 10 natively supports colours in both `conhost.exe` (Command Prompt) and PowerShell since +[v1511](https://en.wikipedia.org/wiki/Windows_10_version_history#Version_1511_(November_Update)), as +well as in newer versions of bash. On earlier versions of Windows, you can use +[Cmder](http://cmder.net/), which includes [ConEmu](https://conemu.github.io/). + +**Note:** The Git and MSYS versions of `less` do not correctly interpret colours on Windows. If you +don’t have any other pagers installed, you can disable paging entirely by passing `--paging=never` +or by setting `BAT_PAGER` to an empty string. + ## Troubleshooting ### Terminals & colors diff --git a/ci/before_deploy.bash b/ci/before_deploy.bash index ea5c1725..16cb261c 100755 --- a/ci/before_deploy.bash +++ b/ci/before_deploy.bash @@ -19,6 +19,8 @@ pack() { if [[ $TARGET == "arm-unknown-linux-gnueabihf" ]]; then gcc_prefix="arm-linux-gnueabihf-" + elif [[ $TARGET == "aarch64-unknown-linux-gnu" ]]; then + gcc_prefix="aarch64-linux-gnu-" else gcc_prefix="" fi @@ -49,13 +51,24 @@ make_deb() { local version local dpkgname local conflictname + local gcc_prefix case $TARGET in x86_64*) architecture=amd64 + gcc_prefix="" ;; i686*) architecture=i386 + gcc_prefix="" + ;; + aarch64*) + architecture=arm64 + gcc_prefix="aarch64-linux-gnu-" + ;; + arm*hf) + architecture=armhf + gcc_prefix="arm-linux-gnueabihf-" ;; *) echo "make_deb: skipping target '${TARGET}'" >&2 @@ -75,7 +88,7 @@ make_deb() { # copy the main binary install -Dm755 "target/$TARGET/release/$PROJECT_NAME" "$tempdir/usr/bin/$PROJECT_NAME" - strip "$tempdir/usr/bin/$PROJECT_NAME" + "${gcc_prefix}"strip "$tempdir/usr/bin/$PROJECT_NAME" # manpage install -Dm644 "doc/$PROJECT_NAME.1" "$tempdir/usr/share/man/man1/$PROJECT_NAME.1" diff --git a/ci/before_install.bash b/ci/before_install.bash index 709be7d5..9acf6025 100755 --- a/ci/before_install.bash +++ b/ci/before_install.bash @@ -27,3 +27,11 @@ if [[ $TARGET == arm-unknown-linux-gnueabihf ]]; then libc6-armhf-cross \ libc6-dev-armhf-cross fi + +# needed for cross-compiling for arm64 +if [[ $TARGET == aarch64-unknown-linux-gnu ]]; then + sudo apt-get install -y \ + gcc-4.8-aarch64-linux-gnu \ + binutils-aarch64-linux-gnu \ + gcc-aarch64-linux-gnu +fi diff --git a/ci/script.bash b/ci/script.bash index 321dcb14..fc874b96 100755 --- a/ci/script.bash +++ b/ci/script.bash @@ -6,7 +6,7 @@ set -ex cargo build --target "$TARGET" --verbose # We cannot run arm executables on linux -if [[ $TARGET != arm-unknown-linux-gnueabihf ]]; then +if [[ $TARGET != arm-unknown-linux-gnueabihf ]] && [[ $TARGET != aarch64-unknown-linux-gnu ]]; then cargo test --target "$TARGET" --verbose # Run 'bat' on its own source code and the README diff --git a/src/printer.rs b/src/printer.rs index bc095def..99901b35 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -114,9 +114,13 @@ impl<'a> InteractivePrinter<'a> { } // Get the Git modifications - let line_changes = match file { - InputFile::Ordinary(filename) => get_git_diff(filename), - _ => None, + let line_changes = if config.output_components.changes() { + match file { + InputFile::Ordinary(filename) => get_git_diff(filename), + _ => None, + } + } else { + None }; // Determine the type of syntax for highlighting @@ -210,11 +214,8 @@ impl<'a> Printer for InteractivePrinter<'a> { line_buffer: &[u8], ) -> Result<()> { let line = String::from_utf8_lossy(&line_buffer).to_string(); - - // Highlight. let regions = self.highlighter.highlight(line.as_ref()); - // Print. if out_of_range { return Ok(()); } @@ -251,6 +252,10 @@ impl<'a> Printer for InteractivePrinter<'a> { as_terminal_escaped(style, &*text, true_color, colored_output,) )?; } + + if line.bytes().next_back() != Some(b'\n') { + write!(handle, "\n")?; + } } else { for &(style, region) in regions.iter() { let mut ansi_iterator = AnsiCodeIterator::new(region);