Windows 10 上的 Bash 文件路径不正确

Windows 10 上的 Bash 文件路径不正确

我正在尝试在 Windows 10 上设置开发环境。我安装了 Ubuntu,并使用 Hyper 作为 CLI。我的主要目标是让我的 CLI 在打开窗口时默认指向我的开发目录,即C:/Users/linds/Development

.hyper.js 设置

shell: 'C:\\Windows\\System32\\bash.exe',
shellArgs: ['~', '--login'],

Hyper 中的默认 shellArgs 为:

shellArgs: ['--login'],

。轮廓

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

.bash_配置文件

cd ~/C:/Users/linds/Development

.bashrc

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

当我启动终端时,收到以下消息:

bash: cd: /home/scribbles/C:/Users/linds/Development: No such file or directory
scribbles@DESKTOP-IQ51GOV:~$

我不确定它/home/scribbles/来自哪里,但我认为它可能与 .profile 有关 - 但我也不太确定。

任何帮助将不胜感激!

编辑:澄清一下,scribbles 是我的 Ubuntu 用户名。

答案1

所以我发现 bash 存储文件的方式不同。要更改默认文件路径,cd ~/C:/Users/linds/Development我不必尝试,而是必须将其更改.bash_profilecd /mnt/c/Users/linds/Development- 这样每次都会在正确的目录中打开我的 CLI。

经过测试mkdir test并且效果很好!=)希望这对其他人有帮助!

相关内容