osx上使用'cd'命令跳转到别名(alias)目录
在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.
function cd {
if [ ${#1} == 0 ]; then
builtin cd
elif [ -d "${1}" ]; then
builtin cd "${1}"
elif [[ -f "${1}" || -L "${1}" ]]; then
path=$(getTrueName "$1")
builtin cd "$path"
else
builtin cd "${1}"
fi
}
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文件后面
if [ "${BASH-no}" != "no" ]; then
[ -r ~/.bashrc ] && . ~/.bashrc
fi
__ 注:我是使用hexo写的本篇,应该是hexo的markdown生成引擎有问题,文中的引用部分生成的完全不对,让我找找问题先。。。 __
osx上使用'cd'命令跳转到别名(alias)目录的更多相关文章
- Windows下如何用CMD命令跳转到指定的目录下
以Window7为例说明,想要跳转到I:\adt-bundle-windows-x86-20130219\sdk\platform-tools目录下. 1.在运行中打开CMD命令窗口如下图所示: 2. ...
- 如何在Linux上使用scp命令进行服务器之间的文件/目录传输
1. 本地上传文件到远程: scp [local_file_path] [username]@[server_ip]:[remote_dir] 2. 本地上传目录到远程: scp -r [local_ ...
- 每天一个linux命令(2):cd命令
1. 命令格式: cd [目录名] 2. 命令功能: 切换当前目录至dirName 3. 常用范例 3.1 例一:进入系统根目录 命令: cd / 输出: [root@localhost ~]# cd ...
- linux命令(2):cd命令
Linux cd 命令可以说是Linux中最基本的命令语句,其他的命令语句要进行操作,都是建立在使用 cd 命令上的. 所以,学习Linux 常用命令,首先就要学好 cd 命令的使用方法技巧. 1. ...
- 转每天一个linux命令(2):cd命令
Linux cd 命令可以说是Linux中最基本的命令语句,其他的命令语句要进行操作,都是建立在使用 cd 命令上的. 所以,学习Linux 常用命令,首先就要学好 cd 命令的使用方法技巧. 1 ...
- linux命令学习(4):cd命令
Linux cd 命令可以说是Linux中最基本的命令语句,其他的命令语句要进行操作,都是建立在使用 cd 命令上的.所以,学习Linux 常用命令,首先就要学好 cd 命令的使用方法技巧. 1. 命 ...
- linux常用命令:cd 命令
Linux cd 命令可以说是Linux中最基本的命令语句,其他的命令语句要进行操作,都是建立在使用 cd 命令上的.所以,学习Linux 常用命令,首先就要学好 cd 命令的使用方法技巧. 1. 命 ...
- 每天一个linux命令:cd命令
Linux cd 命令可以说是Linux中最基本的命令语句,其他的命令语句要进行操作,都是建立在使用 cd 命令上的. 所以,学习Linux 常用命令,首先就要学好 cd 命令的使用方法技巧. 1. ...
- 【转】每天一个linux命令(2):cd命令
原文网址:http://www.cnblogs.com/peida/archive/2012/10/24/2736501.html Linux cd 命令可以说是Linux中最基本的命令语句,其他的命 ...
随机推荐
- 学习笔记之SQL / MySQL
SQL Fiddle(在线执行SQL语句的网站) http://www.sqlfiddle.com/ MySQL https://www.mysql.com/ MySQL :: MySQL 5.7 R ...
- 常见的加密和解密算法—AES
一.AES加密概述 高级加密标准(英语:Advanced Encryption Standard,缩写:AES),在密码学中又称Rijndael加密法,是美国联邦政府采用的一种区块加密标准.这个标准用 ...
- delete删除属性
/* 删除实例属性 */ function MyObject() { this.name = "我是实例的name"; } var obj = new MyObject(); al ...
- 32位ubuntu14.04手动编译hadoop2.6.0
下载官方编译好的包安装老是报错:Unable to load native-hadoop library for your platform 用file命令查看发现官方包里的libhadoop.so. ...
- ES6系列_2之新的声明方式
在ES5中我们在声明时只有一种方法,就是使用var来进行声明,ES6对声明的进行了扩展,现在可以有三种声明方式. (1)var:它是variable的简写,可以理解成变量的意思. (2)let:它在英 ...
- Spring cloud Hystrix的配置属性优先级和详解
Hystrix配置属性详解 Hystrix可以配置属性的有以下类型: Execution:控制HystrixCommand.run() 的如何执行 Fallback: 控制HystrixCommand ...
- jeesite快速开发平台(五)----用户-角色-部门-区域-菜单-权限表关系
转自: https://blog.csdn.net/u011781521/article/details/78994904
- Java常用的转义字符
以下为常用的转义字符对照表: 字母前面加上捺斜线"\"来表示常见的那些不能显示的ASCII字符.称为转义字符.如\0,\t,\n等,就称为转义字符. 转义字符 意义 ASCII码值 ...
- html5 filereader 读取图片信息
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 怎样给oracle数据库的用户解锁
找到并进入运行窗口:(可以用windows+r快捷键哦)输入sqlplus命令:如图 进入新窗口后使用scott/tiger用户和密码进行登录会发现登录不成功:如图 这时我们可以使用syste ...