标签: .bash-profile

在路径中添加〜/ bin目录

我需要在你的路径中添加〜/ bin目录.

但我不确定这个实际的命令是什么,我知道它在我的.bash_profile中

有没有人知道这个,或者有关如何在新mac上为终端设置新的.bash_profile的教程(UNIX)

macos terminal .bash-profile

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

"$ bin/rails"中的"bin"是什么意思?

我正在尝试按照"入门引擎"Rails指南的教程进行操作,并发现:

$ bin/rails plugin new blorgh --mountable
Run Code Online (Sandbox Code Playgroud)

当我在终端上输入时,我得到:

bash: bin/rails: No such file or directory
Run Code Online (Sandbox Code Playgroud)

当我尝试$ rails它只是 工作正常.

我一直在使用命令行几个月,还有Rails.我知道$符号,但我对此之后"bin"的含义感到困惑.我习惯在$之后输入"Rails",但本教程说使用"bin"...

什么bin/意思?

ruby ruby-on-rails .bash-profile

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

sudo open -e~/.bash_profile Permission denied mac

我正在尝试编辑bash_profile文件,通过我的mac机器上的以下命令添加到我的sdk的路径.sudo touch~/.bash_profile; 打开-e~/.bash_profile

它在TextEdit中打开文件,但不允许我编辑它.虽然我在运行上述命令时已经给出了超级用户权限和密码.当我尝试编辑它时它会给我以下消息.

"您不拥有".bash_profile"文件,并且无权写入该文件.您可以复制此文档并编辑副本.只有副本才会包含您的更改." 我是mac的新手.所以请详细说明你的答案.

permissions macos sudo path .bash-profile

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

通过 Homebrew 模块化和分发 bash 脚本

语境

我在 my~/.bashrc中定义了一些函数,我想将它们转换为 Homebrew 包。目前,这些函数在我的命令行上充当自定义命令:

# .bashrc
function foo() {
    # do something interesting
}

# at terminal
$ foo
# => does the interesting thing
Run Code Online (Sandbox Code Playgroud)

方法

我已经使用brew create. 我目前的做法如下:

  1. 将函数定义移动到一个单独的文件中script,在一个目录中,brew-script
  2. 使可brew-script下载为 tarball,brew-script.tar.gz
  3. 让我的 brew 公式在终端会话开始时将文本附加到末尾~/.bash_profile以包含script

顾虑

  1. .bash_profile在 brew 配方中修改是不好的做法吗?(例如,当用 卸载时brew uninstall script, brew 应该以某种方式删除附加到的文本.bash_profile......解析.bash_profile似乎不是很有趣。)

  2. 是否已经建立了在 bash 脚本中包含函数的约定,以便它们可以从命令行使用?

  3. 简单地要求用户在他们的.bash_profile或 中添加一些文本是常见的.bashrc吗?

想要的结果

应该能够使用 brew 干净地安装,然后foo作为命令运行: …

bash homebrew .bash-profile

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

附加到 $PATH 与使用别名:哪个更好?

至少在某些情况下,别名和添加 $PATH 位置可以互换使用。例如,查看 python 工具couchapp,我需要为可执行文件添加别名(如这里有用的描述)或通过 $PATH 使可执行文件可用。

这些是可以实现这一目标的两条线:

alias couchapp="~/Library/Python/2.7/bin/couchapp"
Run Code Online (Sandbox Code Playgroud)

或者

export PATH=$PATH:~/Library/Python/2.7/bin/
Run Code Online (Sandbox Code Playgroud)

这两者是否有非常明确的“更好”选择?为什么或者为什么不?

bash alias path .bash-profile

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

如何按文件状态为`git diff --name-status`的bash输出添加颜色?

我想风格bash的输出,git diff --name-status使之与地位的文件DMA不同的颜色。

款式一般的git bash中我使用color的选项.gitconfig

# .gitconfig
[color]
  branch = auto
  diff = auto
  status = auto
[color "branch"]
  current = yellow reverse
  local = yellow
  remote = green
[color "diff"]
  meta = yellow bold
  frag = magenta bold
  old = red bold
  new = green bold
[color "status"]
  added = yellow
  changed = green
  untracked = cyan
Run Code Online (Sandbox Code Playgroud)

要为git log我可以--pretty=format在如下别名中使用的命令设置输出样式:

# .gitconfig
[alias]
  log …
Run Code Online (Sandbox Code Playgroud)

git bash github .bash-profile git-bash

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

在OSX上安装了scala_home homebrew在哪里?

尽管在终端scala成功打开scala>,我仍然无法让scalac工作.我怀疑这与.bash_profile在我的Mac上设置scala_home 有关. 当前的bash_profile 什么是正确的值SCALA_HOME,或者我如何找到正确的值?(这是自制的)

并且是缩放编译以下的方法: 在此输入图像描述 要进入下层src文件夹scalac IntroducingScala.HelloWorld.scala

scala .bash-profile

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

适当的Unix(.profile,.bash_profile)会改变Python的用法

Python一般都是编程的新手.我是一个新手,不参与编程,只是想自学如何编程作为一种爱好.在此之前Python,我曾与我合作过Ruby一段时间,我了解到最大的挑战之一是实际上正确设置了我的电脑.

背景:我使用的是OSX 10.7的Macbook.

有了Ruby,你必须(或者更确切地说,你应该),编辑你的./profile并添加PATH信息.安装和使用时RVM,您需要添加其他项目bash_profile.

你必须做出类似的改变Python吗?我正在安装/开始确保可以正确安装模块和软件包的最佳实践是什么?

python profile .bash-profile

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

由rvm打开新的tab终端重置gemset

当我打开终端然后进入rails应用程序时,rvm会将gemset加载到.ruby-gemset文件中,如下所示:

> cd my_application/ 
> rvm gemset list
Run Code Online (Sandbox Code Playgroud)

输出如下:

gemsets for ruby-2.2.2 (found in /home/yakout/.rvm/gems/ruby-2.2.2)
   (default)
=> my_gemset
   global
Run Code Online (Sandbox Code Playgroud)

然后我在终端打开新标签,然后运行rvm gemset list,输出将是:

gemsets for ruby-2.2.1 (found in /home/yakout/.rvm/gems/ruby-2.2.1)
=> (default)
   global
Run Code Online (Sandbox Code Playgroud)

我把以下行放在.profile文件中:

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Run Code Online (Sandbox Code Playgroud)

我将以下行放在.bash_profile文件中:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails .bash-profile rvm gemset

5
推荐指数
2
解决办法
877
查看次数

Bash提示缩短

我刚刚从移动tcshbash和使用我特别想念目录缩短提示选项%c02(带ellipsis也成立).

我看到这PROMPT_DIRTRIM几乎是正确的(除了省略号,我认为)但我只在bash3(在OS X上).我在SO的其他地方找到了这个食谱,缩短了总长度,所以打破了目录中间的路径名,这是我不喜欢的.

所以我想出了这个:

PROMPT_DIRTRIM=2   ## from bash4, but used here
dirtrim() 
{
    local NAME="$1" start= endelts=
    [[ "$NAME" =~ ^"$HOME"(/|$) ]] && NAME="~${NAME#$HOME}"  ## $HOME ==> ~
    IFS=/ read -ra elts <<< "$NAME";          ## split $PWD on "/"
    start=$((${#elts[@]}-${PROMPT_DIRTRIM}))  ## first element to retain
    if [ ${start} -gt 1 ]; then     
        for ((i=${start}; i<${#elts[@]}; i++)); do 
            endelts="${endelts}/${elts[$i]}"; ## concat together the trailing path …
Run Code Online (Sandbox Code Playgroud)

bash .bash-profile

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