标签: .bash-profile

Cygwin 找不到 /.bashrc

我在 Windows 7 64 位上安装 Cygwin,我在 location 上的/.bashrc位置是C:/cygwin64/home/admin/bashrc,但我无法从 Cygwin 看到它,它说:

bash: /.bashrc: 没有那个文件或目录

我尝试使用以下命令导航到该文件夹​​:

cd /cygdrive/c/cygwin64/home/admin/
Run Code Online (Sandbox Code Playgroud)

然后使用:

/.bashrc
Run Code Online (Sandbox Code Playgroud)

但它说:

无此文件或目录

怎么做才能看到那个文件?

windows bash cygwin .bash-profile

2
推荐指数
1
解决办法
1万
查看次数

~/.bashrc 别名更改目录不起作用

这可能是一个无聊的问题,但我找不到我完全理解以下查询的答案。

我搬到了一个新的研究所,我正在访问虚拟机进行研究。我想创建一个方便的 bashrc 来让生活更轻松。

因此,使用以下内容编辑 ~/.bashrc 文件:

alias lhcb = "cd ~/vols/lhcb/bd1316/B2ppKgamma/"
alias work_space = "cd ~/home/hep/bd1316/Public/Project/"
alias Code = "cd ~/home/hep/bd1316/Public/Project/Scripts/"
Run Code Online (Sandbox Code Playgroud)

并打开一个新终端以使用更新的 bashrc 文件,我收到以下错误:

-bash: alias: alias: not found
-bash: alias: =: not found
-bash: alias: cd ~/vols/lhcb/bd1316/B2ppKgamma/: not found
-bash: alias: work_space: not found
-bash: alias: =: not found
-bash: alias: cd ~/home/hep/bd1316/Public/Project/: not found
-bash: alias: Code: not found
-bash: alias: =: not found
-bash: alias: cd ~/home/hep/bd1316/Public/Project/Scripts/: not found
Run Code Online (Sandbox Code Playgroud)

我不明白出了什么问题。请您向我解释一下,如果可能,请提供修复程序?多谢。

bash alias .bash-profile

2
推荐指数
1
解决办法
2355
查看次数

为什么我的 Bash 提示颜色使光标出现在错误的位置

我有以下 bash 提示:

# helper function to set colors
function ps1c() {
    tput setaf $1;
}

PS1='$(ps1c 243)\h $(ps1c 177)\W $(ps1c 214)$ \[\e[m\]';
Run Code Online (Sandbox Code Playgroud)

打字时,有时我的光标会返回到屏幕左侧,看起来像是覆盖了提示。此外,当使用向上箭头浏览我的历史时,事情变得很奇怪,光标到处都是。

我已经检查了以下内容,但他们并没有真正提供有关如何解决问题的明确答案:

我知道这个问题与提示的长度不是 bash 所期望的有关,但我是一个完整的 bash 菜鸟。我能做些什么来解决这个问题?

bash terminal .bash-profile

2
推荐指数
1
解决办法
639
查看次数

RVM和bash_profile

我在Mac上安装RVM时遇到问题.我带着我的电脑修好了风扇,所以我正在用我的妻子试图建立我的环境来完成一些工作.

我遇到的问题是bash_profile.每次我添加函数: [[ - - "$ HOME/.rvm/scripts/rvm"]] &&."$ HOME/.rvm/scripts/rvm"#Load RVM功能

然后重新加载shell我收到以下错误:

-bash:export:-s': not a valid identifier -bash: export:/Users/Christine/.rvm/scripts/rvm':不是有效的标识符-bash:export:`]]':不是有效的标识符Christines-MacBook:~Christine $

这是我目前的环境:

  • OSX Lion 10.7.2
  • git版本1.7.5.4
  • 安装了最新的RVM
  • xcode版本4.2.1
  • bash_profile:export PATH =/usr/local/bin:/ usr/local/sbin:/ usr/bin:/ bin:/ sbin:/ usr/sbin [[-s"$ HOME/.rvm/scripts/rvm"] ] &&."$ HOME/.rvm/scripts/rvm"#Load RVM功能

提前致谢.

installation .bash-profile rvm

1
推荐指数
1
解决办法
1万
查看次数

转义Bash文件夹变量中的空格

我试图在Bash中创建一个变量来快速访问某些文件夹并将其保存到我的bash_profile脚本文件中.这就是脚本的样子

Documents=~/Documents
Apps=~/Library/Application\ Support/iPhone\ Simulator/5.1/Applications
Run Code Online (Sandbox Code Playgroud)

运行脚本后,$ Documents变量有效,而$ Apps则无效.它说:

-bash: cd: /Users/myusername/Library/Application: No such file or directory
Run Code Online (Sandbox Code Playgroud)

这是文件夹的路径:

/Users/myusername/Library/Application Support/iPhone Simulator/5.1/Applications
Run Code Online (Sandbox Code Playgroud)

我应该如何逃离空间?我使用Vim并输入"cd $ Apps".

macos bash terminal .bash-profile

1
推荐指数
1
解决办法
4461
查看次数

如何测试 Bash 中是否存在进程?

我想确保node在登录时正在运行。所以在我的.bashrc文件中我有:

pkill node
sleep 1
node server.js &
Run Code Online (Sandbox Code Playgroud)

当然,这不会检查是否node正在运行......它只是杀死它并重新启动它。相反,我想要这样的东西:

node_process = $(pidof node)
if [not_exists node_process]; then
  node server.js &
fi
Run Code Online (Sandbox Code Playgroud)

问题是该not_exists方法似乎不存在:)。如何在 Bash 中测试数字或字符串是否存在,这是确保节点在登录时启动并运行的最佳方法吗?

bash shell process .bash-profile

1
推荐指数
1
解决办法
2万
查看次数

如何使用Python打开"〜/ .bash_profile"

我想用Python编辑~/.bash_profile,但是当我运行这些代码时:

f = open('~/.bash_profile', 'rb')
Run Code Online (Sandbox Code Playgroud)

它告诉我:

IOError: [Errno 2] No such file or directory: '~/.bash_profile'
Run Code Online (Sandbox Code Playgroud)

我以为是因为~/.bash_profile是一个系统保护文件.有没有方法可以使用Python打开这个文件?

python .bash-profile

1
推荐指数
1
解决办法
671
查看次数

我需要手动源〜/ .bashrc来在我的命令提示符下显示和更新GIT分支

当我登录我的CentOS服务器时,我的~/.bashrc文件正在被采购.这是显而易见的,因为1.)我有一条logger "sourcing ~/.bashrc"消息~/.bash_profile,我看到了这个消息/var/log/messages; 2.)我的提示确实显示了我当前的工作目录,这是我的提示所特有的众多事情之一.

但是,当我进入Git仓库时,当前的Git分支没有显示:

(/home/jenkins/GitLab/testing-scripts/tests) jenkins-tests $
Run Code Online (Sandbox Code Playgroud)

当我在这个回购中时,如果我找到我的~/.bashrc文件,我会看到我的Git分支,就像我预期的那样:

(/home/jenkins/GitLab/testing-scripts/tests) jenkins-tests  $ . ~/.bashrc
(/home/jenkins/GitLab/testing-scripts/tests) jenkins-tests (devel)$
Run Code Online (Sandbox Code Playgroud)

如果我机会我的分支,为了显示当前分支,我必须source ~/.bashrc再次.

~/.bashrc执行__git_ps1这里获取的公共命令.

~/.bash_profile包含以下内容:

GP=~/.git-prompt.sh
if [ -f $GP ]; then
  . $GP;
  logger "sourced $GP";
fi
BRC=~/.bashrc
if [ -f $BRC ]; then
  . $BRC;
  logger "sourced $BRC";
fi
BA=~/.bash_aliases
if [ -f $BA ]; then
  . $BA;
  logger "sourced $BA";
fi …
Run Code Online (Sandbox Code Playgroud)

git bash centos command-prompt .bash-profile

1
推荐指数
1
解决办法
334
查看次数

登录脚本使用机器密码为kinit在登录时获取票证

我同步了我的密码/密码用于登录我的机器,解锁我的ssh密钥文件(~/.ssh/id_rsa,参见man ssh-keygen)和kerberos.当我登录时,我输入一次密码来访问我的本地计算机帐户,作为奖励我的ssh密钥文件也被解锁.

我还想自动化我的kerberos身份验证,它也使用相同的密码.基本上,我想要一种安全的方法来实现将它放在我的'〜/ .bash_profile`中的相同效果:

# PASSWORD SHOULD NEVER BE HARDCODED - FOR EXPLANATION PURPOSE ONLY
PASSWORD="qwerty" # NEVER DO THIS!!!
echo "$PASSWORD" | kinit -u $KRBUSR
Run Code Online (Sandbox Code Playgroud)

有什么建议?关于如何解锁密钥文件的见解?

linux kerberos ssh-keys .bash-profile

1
推荐指数
1
解决办法
7157
查看次数

调用多个Bash别名

我想使用一个命令在终端的三个新终端上打开三个不同的文件夹.所有这些都应该彼此独立运行,这意味着一个命令不依赖于它之前的命令.

这是我的.bash_aliases,它是从.bashrc调用的

alias cmd1=gnome-terminal && cd ~/Desktop/

alias cmd2=gnome-terminal && cd ~/Documents/

alias cmd3=gnome-terminal && cd ~/Music/

alias runcmds='cmd1 & cmd2 & cmd3'
Run Code Online (Sandbox Code Playgroud)

但这会在Music目录中打开三个终端,并且不会正确执行命令.我怎样才能使runcms彼此分开运行所有3个命令?

此外,我什么时候需要使用引号,什么时候不需要?

linux bash terminal ubuntu .bash-profile

1
推荐指数
1
解决办法
141
查看次数