Cas*_*all 4 windows terminal python msysgit
我最近升级了运行 32 位 Win7 的笔记本电脑,而我的新笔记本电脑运行了 64 位 Win7 安装。
我正在从 git-scm.com 安装 git 2.5.1 和最新的 python 版本(3.4.3 和 2.7.10)。
在安装过程中,我选择使用以前安装时没有的新(默认)终端,安装完成后启动终端。python但是,当我输入时,我没有看到任何输出(当我按 Enter 时,光标移动到下一行)。
我曾尝试输入print('hello world')诸如a.4. 似乎 python 正在运行,但我没有得到任何输出。我运行的任一版本的 python 都会发生这种情况。
Python 似乎可以使用基于 Windows cmd 的替代 git 正常运行,但我的普通控制台包装器 Console2 似乎无法正常工作,因此我无法轻松复制/粘贴它。
关于为什么 msys 控制台不工作的任何想法,或者我如何解决这个问题?
从安装向导:
如果你想使用 MSys2/Git 自带的 MinTTY 终端,你必须使用 winpty 启动像 Python 这样的控制台程序。
从 Git for Windows 2.7.1 开始,Winpty 是开箱即用的,可以像这样运行:
winpty /path/to/python.exe
Run Code Online (Sandbox Code Playgroud)
winpty 可以安装在 Git\usr\bin
或者,您始终可以使用 bash 别名在 .bashrc 中编写一个可以执行您想要的功能的函数。这是我解决此新限制的解决方案:
function maybe_python34() {
if [ $# -eq 0 ]; then
/c/Python34/python.exe -i
else
/c/Python34/python.exe $@
fi
}
alias python=maybe_python34
Run Code Online (Sandbox Code Playgroud)
请注意,在 python 交互模式下使用箭头键检索命令历史记录存在一些问题。
小智 5
Git 使用 Msys,现在有一个更好的,Msys2!
使用它以及 Git-SCM 对 Msys 相关的修改.profile,.bashrc似乎是适合我的方法。
您现在可以使用 pacman 轻松升级 Msys2
pacman -Syuu
pacman -S winpty
Run Code Online (Sandbox Code Playgroud)
Git 为 winpty 添加了一个很好的别名:
case "$TERM" in
xterm*)
# The following *.exe programs are known to require a Win32 Console
# for interactive usage, therefore let's launch them through winpty
# when run inside `mintty`.
for name in node python ipython php php5 psql
do
case "$(type -p "$name".exe 2>/dev/null)" in
''|/usr/bin/*) continue;;
esac
alias $name="winpty $name.exe"
done
;;
esac
Run Code Online (Sandbox Code Playgroud)
要让 Git 分支在提示中显示,请复制 Git 人员将提示放入其中的文件并将其来源到您的.bashrc( .git-prompt.sh)
if test -f /etc/profile.d/git-sdk.sh
then
TITLEPREFIX=SDK-${MSYSTEM#MINGW}
else
TITLEPREFIX=$MSYSTEM
fi
PS1='\[\033]0;$TITLEPREFIX:${PWD//[^[:ascii:]]/?}\007\]' # set window title
PS1="$PS1"'\n' # new line
PS1="$PS1"'\[\033[32m\]' # change to green
PS1="$PS1"'\u@\h ' # user@host<space>
PS1="$PS1"'\[\033[35m\]' # change to purple
PS1="$PS1"'$MSYSTEM ' # show MSYSTEM
# PS1="$PS1"'\[\033[33m\]' # change to brownish yellow
PS1="$PS1"'\[\033[34m\]' # change to pale blue
PS1="$PS1"'\w' # current working directory
if test -z "$WINELOADERNOEXEC"
then
GIT_EXEC_PATH="$(git --exec-path 2>/dev/null)"
COMPLETION_PATH="${GIT_EXEC_PATH%/libexec/git-core}"
COMPLETION_PATH="${COMPLETION_PATH%/lib/git-core}"
COMPLETION_PATH="$COMPLETION_PATH/share/git/completion"
if test -f "$COMPLETION_PATH/git-prompt.sh"
then
. "$COMPLETION_PATH/git-completion.bash"
. "$COMPLETION_PATH/git-prompt.sh"
PS1="$PS1"'\[\033[36m\]' # change color to cyan
PS1="$PS1"'`__git_ps1`' # bash function
fi
fi
PS1="$PS1"'\[\033[0m\]' # change color
PS1="$PS1"'\n' # new line
PS1="$PS1"'$ ' # prompt: always $
MSYS2_PS1="$PS1" # for detection by MSYS2 SDK's bash.basrc
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6950 次 |
| 最近记录: |