在mac上使用windows的共享目录时,在terminal中时法使用cd的,会提示"xxx 不是目录",经过一番的查找,发现了Mac Terminal 'cd' to folder alias,

经过本人验证时可以用的,具体步骤参考Make Terminal Follow Aliases Like Symlinks:

This is a two-part process requiring a little familiarity with gcc and bash, but I’ll try to make it as simple as possible. Firstly, you need this file: getTrueName.c. This file was created by Thos Davis and is licensed under the GPLv2. Save it anywhere, then compile it with the following command:

gcc -o getTrueName -framework Carbon getTrueName.c

This will create the ‘getTrueName’ executable in the same directory as the source. You can add it to your PATH, or just copy it directly to /usr/bin so it’s easy to access.

Interestingly, when Terminal opens a new shell, .bashrc is not executed as you might expect. Instead, under the login shell, .bash_profile is executed. So, add the following to .bash_profile in your Home directory. You might need to create it first; it isn’t there by default.

  1. function cd {
  2. if [ ${#1} == 0 ]; then
  3. builtin cd
  4. elif [ -d "${1}" ]; then
  5. builtin cd "${1}"
  6. elif [[ -f "${1}" || -L "${1}" ]]; then
  7. path=$(getTrueName "$1")
  8. builtin cd "$path"
  9. else
  10. builtin cd "${1}"
  11. fi
  12. }

Effectively, this looks for Finder aliases and resolves them before deferring to the builtin cd command. Append it to your .bash_profile, then either execute it or restart Terminal for the changes to take effect. Now you can cd to Finder aliases within Terminal and have them treated just like symlinks. Just like it should be.

在修改完.bashrc后只有在新打开terminal时才会有效,解决方法有:

1 每次操作前执行source .bashrc

2 一劳永逸的方法:将下面代码加到.base_profile文件后面

  1. if [ "${BASH-no}" != "no" ]; then
  2. [ -r ~/.bashrc ] && . ~/.bashrc
  3. fi

__ 注:我是使用hexo写的本篇,应该是hexo的markdown生成引擎有问题,文中的引用部分生成的完全不对,让我找找问题先。。。 __

osx上使用'cd'命令跳转到别名(alias)目录的更多相关文章

  1. Windows下如何用CMD命令跳转到指定的目录下

    以Window7为例说明,想要跳转到I:\adt-bundle-windows-x86-20130219\sdk\platform-tools目录下. 1.在运行中打开CMD命令窗口如下图所示: 2. ...

  2. 如何在Linux上使用scp命令进行服务器之间的文件/目录传输

    1. 本地上传文件到远程: scp [local_file_path] [username]@[server_ip]:[remote_dir] 2. 本地上传目录到远程: scp -r [local_ ...

  3. 每天一个linux命令(2):cd命令

    1. 命令格式: cd [目录名] 2. 命令功能: 切换当前目录至dirName 3. 常用范例 3.1 例一:进入系统根目录 命令: cd / 输出: [root@localhost ~]# cd ...

  4. linux命令(2):cd命令

    Linux cd 命令可以说是Linux中最基本的命令语句,其他的命令语句要进行操作,都是建立在使用 cd 命令上的. 所以,学习Linux 常用命令,首先就要学好 cd 命令的使用方法技巧. 1.  ...

  5. 转每天一个linux命令(2):cd命令

      Linux cd 命令可以说是Linux中最基本的命令语句,其他的命令语句要进行操作,都是建立在使用 cd 命令上的. 所以,学习Linux 常用命令,首先就要学好 cd 命令的使用方法技巧. 1 ...

  6. linux命令学习(4):cd命令

    Linux cd 命令可以说是Linux中最基本的命令语句,其他的命令语句要进行操作,都是建立在使用 cd 命令上的.所以,学习Linux 常用命令,首先就要学好 cd 命令的使用方法技巧. 1. 命 ...

  7. linux常用命令:cd 命令

    Linux cd 命令可以说是Linux中最基本的命令语句,其他的命令语句要进行操作,都是建立在使用 cd 命令上的.所以,学习Linux 常用命令,首先就要学好 cd 命令的使用方法技巧. 1. 命 ...

  8. 每天一个linux命令:cd命令

    Linux cd 命令可以说是Linux中最基本的命令语句,其他的命令语句要进行操作,都是建立在使用 cd 命令上的. 所以,学习Linux 常用命令,首先就要学好 cd 命令的使用方法技巧. 1. ...

  9. 【转】每天一个linux命令(2):cd命令

    原文网址:http://www.cnblogs.com/peida/archive/2012/10/24/2736501.html Linux cd 命令可以说是Linux中最基本的命令语句,其他的命 ...

随机推荐

  1. mysql-8 alter命令

    当我们需要修改数据表名或者修改数据表字段时,就需要用到Mysql alter命令. 查看表结构: -- 以下2个命令是通用的 show columns from test_alter_tbl; des ...

  2. 使用GridFsTemplate在Mongo中存取文件

      Maven依赖(还有一些springboot需要的) <parent> <groupId>org.springframework.boot</groupId> ...

  3. 公司培训lesson 1-代码质量

    课堂讲义 代码质量五大原则 编码规范 命名规范.学会合理科学的命名类名.方法名.变量名.命名宗旨:简洁明了,见名只意:了解常用单词缩写 注释.是否写根据所处工作环境的需要而决定.将以源代码写成以“注释 ...

  4. centos7.3下apache搭建django[未成功]

    1 apache肯定已经按照完毕了, 如果没有  yum install httpd yum install mod_wsgi 安装完成之后,mod_wsgi.so会在Apache的modules目录 ...

  5. 迷你MVVM框架 avalonjs 1.3.4发布

    发现一个以前从来没发现的大BUG,紧急发布此版本. fix getEachProxy BUG,此BUG会导致监控数组在删除某元素然后再添加元素时出现问题. avalon ms-on-*绑定添加一个钩子 ...

  6. JavaScript中call,apply,bind方法

    why?call,apply,bind干什么的?为什么要学这个? 一般用来指定this的环境,在没有学之前,通常会有这些问题. var a = { user:"追梦子", fn:f ...

  7. python之with...as

    [python之with...as] 参考:http://python.42qu.com/11155501

  8. 03-使用html静态页面展示执行效果

    使用工作流框架可以做什么事情?写代码呗,没那么简单.

  9. 110. Balanced Binary Tree (Tree; DFS)

    Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary ...

  10. Marshal.FreeHGlobal 方法 (IntPtr)

    释放以前从进程的非托管内存中分配的内存. 命名空间:   System.Runtime.InteropServices程序集:  mscorlib(位于 mscorlib.dll) 下面的示例演示如何 ...