在Fabric中,当我尝试使用我的.bash_profile文件中的任何别名或函数时,它们无法识别.例如我的.bash_profile包含alias c='workon django-canada',所以当我输入ciTerm或终端时,workon django-canada执行.
我的fabfile.py包含
def test():
local('c')
Run Code Online (Sandbox Code Playgroud)
但是当我尝试fab test它时会向我抛出:[localhost] local:c
/bin/sh: c: command not found
Fatal error: local() encountered an error (return code 127) while executing 'c'
Aborting.
Run Code Online (Sandbox Code Playgroud)
其他Fabric功能正常.我是否必须在布料的某处指定我的bash配置文件?
今天我想编写一个函数,将我的博客页面(以nanoc开发)自动部署到github页面 - 这是脚本:
function cmit()
{
nanoc compile;
git add .;
git commit -am $1;
git push origin source;
cd output; git add .;
git commit -am $1;
git push origin master;
cd ..;
echo 'new version deployed! now starting nanoc locally..';
nanoc aco;
}
Run Code Online (Sandbox Code Playgroud)
用法示例: cmit "my example commit!"
我真的不知道如何在系统(OSX)注册我的功能-在.bashrc,.bash_profile也许别的地方?请帮忙!
我不确定发生了什么,但我的〜/ .profile不再加载了.
以下任何人都可以看到错误吗?
export PS1="\u@local [\w]# "
export EDITOR="subl -w"
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
alias vst="ssh -i ~/.ssh/vst root@vst"
Run Code Online (Sandbox Code Playgroud)
我知道使用PS1这样的事实,就像我试图做的那样应该这样做,Peter@local [~/path/to/file]#但事实并非如此.
有任何想法吗?
我刚开始使用jenv,我跟着一篇博客文章,解释了如何jenv在MacOSX上使用和设置多个java版本.但是我现在遇到的问题是设置JAVA_HOME.当我切换java环境时,jenv我想确保JAVA_HOME我的bash_profile也相应地改变.
我怎么做?
我跟着我 ~/.bash_profile
if which jenv > /dev/null; then eval "$(jenv init -)"; fi
Run Code Online (Sandbox Code Playgroud) 看来我们会放
source ~/.bashrc
Run Code Online (Sandbox Code Playgroud)
无论如何,在我们的.bash_profile中.那么为什么不使用一个文件,比如说.bashrc?
我经常发现自己使用以下命令将历史命令复制到剪贴板:
echo !123 | pbcopy
终端可以正常工作.假设!123 = cd ..它看起来像这样:
$ echo !123 | pbcopy
echo cd .. | pbcopy
//result: `cd ..` is in the clipboard
Run Code Online (Sandbox Code Playgroud)
为了让生活更轻松,我将这个bash函数添加到我的.bashrc中:
function pb() {
echo $1 | pbcopy
}
Run Code Online (Sandbox Code Playgroud)
理想情况下,将调用此命令,如下所示:pb !!.但是,这不起作用.这是发生的事情:
$ pb !123
pb cd .. | pbcopy
//result: `!!` is in the clipboard
Run Code Online (Sandbox Code Playgroud)
无论我调用什么历史命令,它总是返回!!到剪贴板.我也试过制作别名,但是它有同样的问题:
alias pb='echo !! | pbcopy'
有什么指针吗?
我无法让我的.bash_profile别名在我的Mac OSX终端上运行.我在〜/目录中创建了一个.bash_profile文件,然后写了两行:
echo bash profile has loaded
alias prof=“open ~/.bash_profile”
Run Code Online (Sandbox Code Playgroud)
我保存并输入终端命令:
. ~/.bash_profile
Run Code Online (Sandbox Code Playgroud)
终端显示:
bash profile has loaded
-bash: alias: /Users/kennethlarose/.bash_profile”: not found
Run Code Online (Sandbox Code Playgroud)
我一直在阅读别名配置文件,我相信我的语法是有效的.我知道配置文件是源代码,因为它显示了echo,但是无论在别名中保存什么命令,终端都会显示相同的"未找到"消息.有谁知道我还能尝试什么?
我编辑了我的$ Home .bash_profile以包含一些git别名命令.我对此很陌生,我无法弄清楚出了什么问题.
.bash_profile中
alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gd='git diff'
alias go='git checkout '
alias gk='gitk --all&'
alias gx='gitx --all'
alias got='git '
alias get='git '
PS1="\u$ "
alias ll="ls -lahG"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && \
. "$HOME/.rvm/scripts/rvm"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && \
. "$HOME/.rvm/scripts/rvm"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && \
. "$HOME/.rvm/scripts/rvm"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && \
. "$HOME/.rvm/scripts/rvm"
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" …Run Code Online (Sandbox Code Playgroud) 我一直在尝试更改我的根目录中的.bash_profile,但是遇到了一些问题.我在Macbook Pro上的OS X,Yosemite上.据我所知,.bash_profile文件包含每当打开终端应用程序并启动bash shell时自动调用的脚本.这是我目前在该文件中编写的内容:
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
Run Code Online (Sandbox Code Playgroud)
这完全没问题.但是,我想添加一个别名(在上面的两行下面),如下所示:
alias test='cd ..'
Run Code Online (Sandbox Code Playgroud)
但是,当我保存并启动终端时,我收到以下消息:
-bash: alias: ..": not found
Run Code Online (Sandbox Code Playgroud)
用双引号替换单引号并没有帮助,也没有完全取消它们.但奇怪的是,以下别名有效:
alias c=clear
Run Code Online (Sandbox Code Playgroud)
当我在终端中键入c时,它会清除屏幕,正如您所期望的那样.但是,如果我在bash配置文件中使用引号输入此行,则:
alias c='clear'
Run Code Online (Sandbox Code Playgroud)
每当我进入终端时,我都会得到以下信息:
-bash: 'clear': command not found
Run Code Online (Sandbox Code Playgroud)
请注意,我在启动时没有收到此别名的错误消息.
我究竟做错了什么?是否有一个设置我需要在某处更改以使别名正常工作?我已经看过以前的别名示例,它们根本不适用于我.
我经常需要对我进行更改~/.bash_profile,并且我必须重新启动终端以进行更改传播.是否有任何命令可以重新启动我的命令~/.bash_profile?