add bat for Windows 10

This commit is contained in:
AJ ONeal
2020-07-05 01:36:40 +00:00
parent 6314667c78
commit 7fd81bbd90
2 changed files with 56 additions and 3 deletions
+12 -3
View File
@@ -4,10 +4,19 @@ homepage: https://github.com/sharkdp/bat
tagline: |
bat: A cat(1) clone with syntax highlighting and Git integration.
description: |
`bat` is pretty much what `cat` would be if it were developed today in the world of Markdown, git, etc.
`bat` is pretty much what `cat` would be if it were developed today's in the world of Markdown, git, etc.
---
## How to alias as `cat`
### How to run on Windows 10
On Windows 10 you'll get an error like this:
> execution cannot proceed run because vcruntime140.dll was not found
You need to download and install the
[Microsoft Visual C++ Redistributable](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads)
### How to alias as `cat`
Update your `.bashrc`, `.zshrc`, or `.profile`
@@ -15,7 +24,7 @@ Update your `.bashrc`, `.zshrc`, or `.profile`
alias cat="bat --style=plain"
```
## How to change the default behavior
### How to change the default behavior
Take a look at the config options:
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env pwsh
$VERNAME = "$Env:PKG_NAME-v$Env:WEBI_VERSION.exe"
$EXENAME = "$Env:PKG_NAME.exe"
# Fetch archive
IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"))
{
# TODO: arch detection
echo "Downloading $Env:PKG_NAME from $Env:WEBI_PKG_URL to $Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"
& curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE.part"
& move "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE.part" "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"
}
IF (!(Test-Path -Path "$Env:USERPROFILE\.local\xbin\$VERNAME"))
{
echo "Installing $Env:PKG_NAME"
# TODO: temp directory
# Enter tmp
pushd .local\tmp
# Remove any leftover tmp cruft
Remove-Item -Path "$Env:PKG_NAME-v*" -Recurse -ErrorAction Ignore
# Unpack archive
# Windows BSD-tar handles zip. Imagine that.
echo "Unpacking $Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"
& tar xf "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"
# Move single binary into root of temporary folder
& move "bat.exe" "$VERNAME"
& dir
# Settle unpacked archive into place
echo "New Name: $VERNAME"
echo "New Location: $Env:USERPROFILE\.local\xbin\$VERNAME"
Move-Item -Path "$VERNAME" -Destination "$Env:USERPROFILE\.local\xbin"
# Exit tmp
popd
}
echo "Copying into '$Env:USERPROFILE\.local\bin\$EXENAME' from '$Env:USERPROFILE\.local\xbin\$VERNAME'"
Remove-Item -Path "$Env:USERPROFILE\.local\bin\$EXENAME" -Recurse -ErrorAction Ignore
Copy-Item -Path "$Env:USERPROFILE\.local\xbin\$VERNAME" -Destination "$Env:USERPROFILE\.local\bin\$EXENAME" -Recurse