別名檔案在 WSL 上的 Bash 中不起作用 (Opensuse Leap 42.3)

別名檔案在 WSL 上的 Bash 中不起作用 (Opensuse Leap 42.3)

我在 WSL 中的 Bash 中設定了別名檔:

alias gvim='/mnt/d/Vim/vim81/gvim.exe'
alias vim='/mnt/d/Vim/vim81/vim.exe'
alias pngcrush='/mnt/c/Users/nathan/Downloads/pngcrush_1_8_11_w64.exe -reduce -brute -ow'

但是當我嘗試在 Bash 中執行 gvim 或 vim 時,出現以下錯誤:

:No such file or directorym.exe(gvim)

`:沒有這樣的檔案或目錄.exe' (vim)

但是,pngcrush 別名可以正常運作。但由於一些奇怪的原因,我的~/.alias 檔案中定義的別名將別名中的第一個“a”替換為單引號,並且當我在不帶參數的bash 中運行alias 命令時,結尾的單引號遺失。

有人知道為什麼 gvim 和 vim 可執行檔沒有被正確找到嗎?如果我直接在 bash 中輸入 .exe 的路徑,它可以工作,但是這兩個別名不起作用

重擊版本:

> bash --version
GNU bash, version 4.3.42(1)-release (x86_64-suse-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

OpenSUSE版本:

> cat /etc/*release
NAME="openSUSE Leap"
VERSION="42.3"
ID=opensuse
ID_LIKE="suse"
VERSION_ID="42.3"
PRETTY_NAME="openSUSE Leap 42.3"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:leap:42.3"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"
openSUSE 42.3 (x86_64)
VERSION = 42.3
CODENAME = Malachite
# /etc/SuSE-release is deprecated and will be removed in the future, use /etc/os-release instead

我所有的 bash 別名如下:

>alias
alias +='pushd .'
alias -='popd'
alias ..='cd ..'
alias ...='cd ../..'
alias beep='echo -en "\007"'
alias cd..='cd ..'
alias dir='ls -l'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
'lias gvim='/mnt/d/Vim/vim81/gvim.exe
alias l='ls -alF'
alias la='ls -la'
alias ll='ls -l'
alias ls='_ls'
alias ls-l='ls -l'
alias md='mkdir -p'
alias o='less'
'lias pngcrush='/mnt/c/Users/nathan/Downloads/pngcrush_1_8_11_w64.exe -reduce -brute -ow
alias rd='rmdir'
alias rehash='hash -r'
alias unmount='echo "Error: Try the command: umount" 1>&2; false'
'lias vim='/mnt/d/Vim/vim81/vim.exe
alias you='if test "$EUID" = 0 ; then /sbin/yast2 online_update ; else su - -c "/sbin/yast2 online_update" ; fi'

微軟 Windows 10 家用版 10.0.17134

答案1

快速回答:只需從 bash 中開啟 vim 即可。

您與 WSL 一起使用的 Linux 發行版可能包含 vim。沒有理由使用 WSL 和 bash 開啟 Windows 版本的 vim。

相關內容