Ignore CRLF for shell scripts (#315)

This commit is contained in:
Ajeet D'Souza 2021-12-15 01:13:45 +05:30
parent ff28b02801
commit bd54ea3ea9
6 changed files with 31 additions and 17 deletions

7
.gitattributes vendored
View File

@ -1,2 +1,5 @@
contrib/completions/* linguist-generated=true
contrib/completions/README.md linguist-generated=false
/contrib/completions/* eol=lf linguist-generated=true text
/contrib/completions/README.md -eol -linguist-generated -text
/init.fish eol=lf text
/templates/*.txt eol=lf text
/zoxide.plugin.zsh eol=lf text

View File

@ -21,7 +21,7 @@ jobs:
components: rustfmt, clippy
profile: minimal
override: true
- uses: cachix/install-nix-action@v12
- uses: cachix/install-nix-action@v15
if: ${{ matrix.os != 'windows-latest' }}
with:
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/20.09.tar.gz

View File

@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fzf: better default options.
- Fish: interactive completions are only triggered when the last argument is empty.
- PowerShell: installation instructions.
### Fixed
@ -24,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Zsh: fix errors with `set -eu`.
- Fzf: handle early selection.
- PowerShell: correctly handle escape characters in paths.
- Parse error on Cygwin/MSYS due to CRLF line endings.
## [0.7.9] - 2021-11-02

View File

@ -205,6 +205,13 @@ Add this to your configuration (find it by running `echo $profile` in
PowerShell):
```powershell
# For zoxide v0.8.0+
Invoke-Expression (& {
$hook = if ($PSVersionTable.PSVersion.Major -lt 6) { 'prompt' } else { 'pwd' }
(zoxide init --hook $hook powershell | Out-String)
})
# For older versions of zoxide
Invoke-Expression (& {
$hook = if ($PSVersionTable.PSVersion.Major -lt 6) { 'prompt' } else { 'pwd' }
(zoxide init --hook $hook powershell) -join "`n"

View File

@ -46,7 +46,7 @@ PowerShell):
.nf
\fBInvoke-Expression (& {
$hook = if ($PSVersionTable.PSVersion.Major -lt 6) { 'prompt' } else { 'pwd' }
(zoxide init --hook $hook powershell) -join "`n"
(zoxide init --hook $hook powershell | Out-String)
})\fR
.fi
.TP

View File

@ -14,12 +14,14 @@ function __zoxide_pwd {
}
# cd + custom logic based on the value of _ZO_ECHO.
function __zoxide_cd($dir) {
function __zoxide_cd($dir, $literal) {
$dir = if ($literal) {
Set-Location -LiteralPath $dir -Passthru -ErrorAction Stop
} else {
Set-Location -Path $dir -Passthru -ErrorAction Stop
}
{%- if echo %}
$dir = Set-Location -LiteralPath $dir -Passthru -ErrorAction Stop
Write-Output $dir.Path
{%- else %}
Set-Location -LiteralPath $dir -ErrorAction Stop
{%- endif %}
}
@ -72,13 +74,13 @@ if ($__zoxide_hooked -ne 1) {
# Jump to a directory using only keywords.
function __zoxide_z {
if ($args.Length -eq 0) {
__zoxide_cd ~
__zoxide_cd ~ $true
}
elseif ($args.Length -eq 1 -and $args[0] -eq '-') {
__zoxide_cd -
}
elseif ($args.Length -eq 1 -and (Test-Path $args[0] -PathType Container)) {
__zoxide_cd $args[0]
elseif (
$args.Length -eq 1 -and
(($args[0] -eq '-' -or $args[0] -eq '+') -or (Test-Path $args[0] -PathType Container))
) {
__zoxide_cd $args[0] $false
}
else {
$result = __zoxide_pwd
@ -89,7 +91,7 @@ function __zoxide_z {
$result = zoxide query -- @args
}
if ($LASTEXITCODE -eq 0) {
__zoxide_cd $result
__zoxide_cd $result $true
}
}
}
@ -98,7 +100,7 @@ function __zoxide_z {
function __zoxide_zi {
$result = zoxide query -i -- @args
if ($LASTEXITCODE -eq 0) {
__zoxide_cd $result
__zoxide_cd $result $true
}
}
@ -122,4 +124,4 @@ Set-Alias -Name {{cmd}}i -Value __zoxide_zi -Option AllScope -Scope Global -Forc
# To initialize zoxide, add this to your configuration (find it by running
# `echo $profile` in PowerShell):
#
# Invoke-Expression (& { $hook = if ($PSVersionTable.PSVersion.Major -ge 6) { 'pwd' } else { 'prompt' } (zoxide init powershell --hook $hook) -join "`n" })
# Invoke-Expression (& { $hook = if ($PSVersionTable.PSVersion.Major -ge 6) { 'pwd' } else { 'prompt' } (zoxide init powershell --hook $hook | Out-String) })