我喜欢Checkoutmanager和Dotfiles

本文详细介绍了一位开发者如何在全新的Macbook Air或Pro上搭建OSX开发工作站,包括更改Shell为Zsh,安装XCode和Python解释器,配置Git,利用Homebrew安装软件,管理SSH密钥,以及设置路径和开发工具。
摘要由CSDN通过智能技术生成

An ode to my OS X development workstation setup [1]

我的OS X开发工作站设置的颂歌 [1]

I am big on setting up my development environment, and enjoying the environment I work in. And I’m very thankful to the folks who make my life easier, including the authors of:

我致力于建立自己的开发环境,并享受工作环境。我非常感谢使我的生活更加轻松的人们,其中包括:

I also love repetition. So picture if you will, a new Macbook Air or Pro ready to serve as my development workstation. I like to perform, and study, the steps required to turn a new laptop in to my development workstation. So here we go. In this article, I will walk through the steps required to turn a new machine in to my developer workstation. Do follow along!

我也喜欢重复 。 因此,如果可以的话,请准备一个新的Macbook Air或Pro作为我的开发工作站。 我喜欢执行和研究将新笔记本电脑带入开发工作站所需的步骤。 所以我们开始。 在本文中,我将逐步完成将一台新计算机放入开发人员工作站所需的步骤。 跟随!

贝壳 (Shell)

One of the first things I do on a new system is change my shell to Zsh in System Preferences -> Users & Groups -> Current User -> Right Click -> Advanced Options.... Don’t forget to Click the lock to make changes first.

我在新系统上要做的第一件事是在System Preferences -> Users & Groups -> Current User -> Right Click -> Advanced Options...中将Shell更改为Zsh 。 不要忘记Click the lock to make changes第一。

alternate text

sh (Zsh)

Why Zsh? One of my favorite features is shared history between open sessions. So I can run a command in one window, and then run the same command from another window by fetching it from the history (with CTRL-R).

为什么选择Zsh ? 我最喜欢的功能之一是在开放会话之间共享历史记录 。 因此,我可以在一个窗口中运行命令,然后通过从历史记录中获取它(使用CTRL-R)在另一个窗口中运行同一命令。

XCode (XCode)

After I take possession of my new laptop (running Mountain Lion, the newest OS X at the time of this writing), I head to the App Store to download XCode. [2] Among many other things, XCode gives me the GNU C Compiler and allows me to type “gcc” in my Applications -> Utilities -> Terminal.

拥有新笔记本电脑(在撰写本文时,正在运行最新的OS X Mountain Lion )后,我前往App Store下载XCode。 [2]除其他外,XCode还为我提供了GNU C编译器,并允许我在Applications -> Utilities -> Terminal键入“ gcc”。

alternate text

Python (Python)

alternate text

Now I need a Python interpreter [3]. For development I use the Collective Python Buildout but I also enjoy using Homebrew’s Python 2.7. I use Homebrew for a variety of other things too (e.g. mobile-shell AKA mosh) so here we go:

现在,我需要一个Python解释器[3] 。 对于开发,我使用Collective Python Buildout,但我也喜欢使用Homebrew的 Python 2.7。 我也将Homebrew用于其他各种用途(例如,移动外壳AKA mosh),所以我们开始:

$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

… follow instructions …

… 遵守指示 …

吉特 (Git)

I think OS X (or XCode) includes git, but just in case:

我认为OS X(或XCode)包括git,但以防万一:

$ brew install git
$ brew install git

Which reminds me, don’t forget that installing the command line utilities in Mountain Lion’s XCode requires an additional step in Preferences -> Downloads -> Command Line Tools -> Install:

这使我想起了,不要忘记在Mountain Lion的XCode中安装命令行实用程序需要在Preferences -> Downloads -> Command Line Tools -> Install执行额外的步骤:

替代文字

点文件 (Dotfiles)

At this point, I can begin to get serious about turning this new machine in to my developer workstation. And that means: installing my private ssh key so I can check out code without typing a password, of course. Normally this would be tedious, but with git and dotfiles it’s not so bad. This is what I do from my home directory:

在这一点上,我可以开始认真考虑将这台新机器转入我的开发人员工作站。 这意味着: 安装我的ssh私钥,这样我当然可以在不输入密码的情况下签出代码。 通常这会很乏味,但是使用git和dotfiles并没有那么糟。 这是我在主目录中执行的操作:

I use https which requires a password for the first time only. Then I edit Dotfiles/.git/config and change the repository URL to git@super_secret_url/dotfiles.git. So every subsequent pull and push will require no password. And to “install” these dotfiles, I do [6]:

我使用https,这仅是第一次需要密码。 然后,我编辑Dotfiles/.git/config并将存储库URL更改为git@super_secret_url/dotfiles.git 。 因此,随后的所有推拉操作都不需要密码。 为了“安装”这些点文件,我要做[6]

$ pip install dotfiles
$ dotfiles -s --force
$ pip install dotfiles
$ dotfiles -s --force

Note: the dotfiles command finds my dotfiles in the default directory “Dotfiles” and create symbolic links to them.

注意:dotfiles命令在默认目录“ Dotfiles”中找到我的dotfile,并创建指向它们的符号链接。

分配和点 (Distribute & Pip)

Homebrew’s Python includes pip, but even if it didn’t:

自制软件的Python包含pip,但即使没有:

In other words, you can always install Distribute [4]. After which you can use easy_install or pip to install dotfiles. (You can read up on the differences. TL;DR: neither is “better” or “worse”, it’s just a question of which tradeoffs you are willing to make. I tend to use pip just because it’s newer and I like its requirements.txt feature, but easy_install is still very well supported as part of the Distribute project.)

换句话说,您可以始终安装Distribute [4] 。 之后,您可以使用easy_installpip安装pip文件。 (您可以阅读其中的区别。TL; DR:都不是“更好”或“更差”,这只是您愿意进行哪些折衷的问题。我倾向于使用pip只是因为它是新的并且我喜欢它的要求.txt功能,但作为Distribute项目的一部分,仍非常容易地支持easy_install。)

结帐经理 (Checkoutmanager)

Now I need some things to develop. Since I work on a bunch of different projects, I need a way to keep track of what should be checked out at any given time. So I do this [5]:

现在我需要一些东西来发展。 由于我从事许多不同的项目,因此我需要一种方法来跟踪在任何给定时间应检查的内容。 所以我这样做[5]

$ pip install checkoutmanager
$ checkoutmanager co
$ pip install checkoutmanager
$ checkoutmanager co

This creates and populates my ~/Developer directory with code. And it “just works” because I keep a .checkoutmanager.cfg in my Dotfiles repository. It currently looks like this:

这将使用代码创建并填充我的~/Developer目录。 它“ .checkoutmanager.cfg ”,因为我在Dotfiles存储库中保留了一个.checkoutmanager.cfg 。 当前看起来像这样:

Now it’s time to bootstrap the Collective Python Buildout, which gives me all versions of Python, ever [7]. And off we go:

现在是时候启动Collective Python Buildout了,它为我提供了所有版本的Python [7] 。 然后我们开始:

$ cd Developer/buildout.python
$ python bootstrap.py
$ cd Developer/buildout.python
$ python bootstrap.py

Finally, there is some PATH configuration required to make all of this seemless. The Collective Python Buildout gets installed in /opt while brew’s stuff is in /usr/local. My PATH config currently looks like this:

最后,需要进行一些PATH配置,以使所有这些一切变得不明显。 当brew的东西位于/ usr / local时,Collective Python Buildout安装在/ opt中。 我的PATH配置当前看起来像这样:

With the above configuration, I default to the Python 2.7 in the Collective Python Buildout. That means that is the “python” or “virtualenv” I get when I type those commands. I use the full path or expanded binary name when I need them e.g. /usr/local/bin/python or python3.3.

通过以上配置,我默认使用Collective Python Buildout中的Python 2.7。 这意味着当我键入这些命令时得到的是“ python”或“ virtualenv”。 我在需要它们时使用完整路径或扩展二进制名称,例如/ usr / local / bin / python或python3.3。

That’s it! I hope you will check out dotfiles and checkoutmanager for all your development needs.

而已! 我希望您可以签出dotfile和checkoutmanager来满足您的所有开发需求。

[1][1] Not really an ode: http://en.wikipedia.org/wiki/Ode 并非真正的颂歌: http : //en.wikipedia.org/wiki/Ode
[2][2] I know about Kenneth Reitz’s XCode Command line Tools only, but if I recall correctly there is some “gotcha” that has bitten me more than once if I use that instead of the full XCode. I wish I could remember what it was now, but it’s not coming to me. If it works for you though, great! 我只知道Kenneth Reitz的XCode命令行工具,但是如果我没记错的话,如果我使用它而不是完整的XCode,有一些“陷阱”会咬我一次。 我希望我能记住现在的情况,但现在还没想到。 如果它对您有用,那就太好了!
[3][3] I know about the system Python, and for small things like checkoutmanager and dotfiles I don’t mind using it. But there is merit in avoiding it because Apple treats it like “their” Python and makes decisions for you that you may prefer to make yourself. E.g. I believe they use a crippled version of the readline library. 我了解系统Python,对于诸如checkoutmanager和dotfiles之类的小事情,我不介意使用它。 但是避免使用它是有好处的,因为Apple将其视为“他们的” Python并为您做出可能更喜欢自己做的决定。 例如,我相信他们使用的是readline库的残缺版本。
[4][4] Distribute is a more actively maintained fork of the venerable setuptools library (which itself is built on top of the Python standard library’s distutils). Are we having fun yet? Distribute是古老的setuptools库(它本身是建立在Python标准库的distutils之上)的一个更积极维护的分支。 我们刚才玩的高兴吗?
[5][5] I also alias checkoutmanager to cm 我也将checkoutmanager别名为cm
[6][6] I force because I want to replace the newly created .ssh dir with the one I keep in my Dotfiles repository. 我强迫是因为我想用我保存在Dotfiles存储库中的目录替换新创建的.ssh目录。
[7][7] Well, 2.4 through 3.3 at last count. 好吧,最后一次从2.4到3.3。

翻译自: https://www.pybloggers.com/2013/02/i-love-checkoutmanager-and-dotfiles/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值