• Mac python 开发环境一些设置


    dot files

    dot files是指以.开头的文件,比如说.bash_profile。在类Unix系统下,dot files是默认隐藏的。在Shell下,很多的工具使用dot file作为默认导入的配置文件。比如说Bash对应的.bash_profile和.bashrc。在Shell下查看这些文件需要用ls -a。在你的home directory下用这个命令,你可能会看到一些已经存在的dot files。

    .bash_profile & .bashrc

    这两个文件的区别:

    • .bash_profile 是以交互式、login方式进入bash时会调用的
    • .bashrc 是交互式、non-login暗示进入bash时会调用的

    我的.bash_profile里面只有一个调用.bashrc文件的代码,所有的其他设置都放到了.bashrc里面:

    1 if [ -f ~/.bashrc ]; then 
    2 source ~/.bashrc
    3 fi

     

    .bashrc文件的一些内容

     1 alias  ls='ls -G' 
    2 export PS1="\u@\W\$ "
    3 export CLICOLOR=1
    4 export LSCOLORS=ExFxCxDxBxegedabagacad
    5 export EDITOR=/usr/bin/vi
    6 export LC_ALL=en_US.UTF-8
    7 export LANG=en_US.UTF-8
    8
    9 export MANPATH="/usr/local/man:$MANPATH"
    10
    11 alias mr='/Users/goodspeed/mysite/manage.py runserver'
    12 alias ms='/Users/goodspeed/mysite/manage.py syncdb'
    13 alias mvm='/Users/goodspeed/mysite/manage.py validate'
    14 alias hu='hg pull -u'
    15
    16 export PYTHONSTARTUP=~/.pythonstartup
    17 # Set architecture flags
    18 export ARCHFLAGS="-arch x86_64"
    19 export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib"
    20
    21
    22 alias ssh="ssh -X"
    23 alias md="mkdir -p"
    24 alias rd="rmdir"
    25 alias df="df -h"
    26 alias mv="mv -i"
    27 alias slink="link -s"
    28 alias sed="sed -E"
    29 alias l="ls -l"
    30 alias la="ls -lhAF"
    31 alias ll="ls -lhF"
    32 alias lt="ls -lhtrF"
    33 alias l.="ls -lhtrdF .*"
    34 alias cd..="cd .."
    35 alias cd...="cd ../.."
    36 alias cd....="cd http://www.cnblogs.com/.."
    37 alias ..="cd .."
    38 alias ...="cd ../.."
    39 alias ....="cd http://www.cnblogs.com/.."
    40 alias zb="cat /dev/urandom | hexdump -C | grep --color=auto \"ca fe\""
    41 alias emacs23="open -a Emacs"
    42 alias gs="git status"
    43 alias ga='git add'
    44 alias gpl="git pull"
    45 alias gps="git push"
    46 alias gc="git commit -m"
    47 alias rdm="rake db:migrate"
    48 alias rds="rake db:seed"
    49 alias rr="rake routes"



    第2行 让命令行提示显示用户和当前路径就行了, 太长了不好看,

    第三和四行就是让terminal输出显示颜色. 默认编辑器设置成vi, 编码设置utf-8,

    第9行就是python shell启动时调用的文件,

    11~13行是方便我使用django设置的alias,

    16是为了方便使用hg, 最后就是PATH和MANPATH了. 

    剩下的主要是对一些常用的命令添加了缩写的别名,所以以前我和Eric经常会说一些黑话,比如说gps(git push),gpl(git pull)之类的,而其他人不知道我们在说啥:)   

    zb是我找到的一个很酷的装B命令:)

     

    .gitconfig这个文件里面存储了和git相关的配置:

    [user]
    name = Tyrael Tong
    email = Tyrael.Tong@activenetwork.com
    [core]
    quotepath = false
    excludesfile = /Users/tyraeltong/.gitignore_global
    [color]
    diff = auto
    branch = 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
    [merge]
    tool = opendiff
    [alias]
    co = checkout
    ci = commit
    st = status
    br = branch
    type = cat-file -t
    dump = cat-file -p
    hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
    server = daemon --verbose --export-all --base-path=.
    [push]
    default = current
    [difftool "sourcetree"]
    cmd = opendiff \"$LOCAL\" \"$REMOTE\"
    path =
    [mergetool "sourcetree"]
    cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
    trustExitCode = true

    .pythonstartup文件

    # python startup file
    import readline
    import rlcompleter
    import atexit
    import os

    # tab completion08 readline.parse_and_bind('tab: complete')

    # histroy file11 histfile = os.path.join(os.environ['HOME'], '.pythonhistory')
    try:
    readline.read_history_file(histfile)
    except IOError:
    pass
    atexit.register(readline.write_history_file, histfile)
    del os, histfile, readline, rlcompleter

    有了这个文件, 以后使用python shell的时候, tab键就会自动提示了! 

    最后就是vim的配置文件了:

     1 set nocompatible
    2 set encoding=utf8
    3 set autoread
    4 set mouse=a
    5 set paste
    6 set expandtab
    7 set textwidth=0
    8 set tabstop=4
    9 set softtabstop=4
    10 set shiftwidth=4
    11 set autoindent
    12 set backspace=indent,eol,start
    13 set incsearch
    14 set ignorecase
    15 set ruler
    16 set wildmenu
    17 set commentstring=\ #\ %s
    18 set foldlevel=0
    19 set clipboard+=unnamed
    20 syntax enable
    21 set gfn=Panic\ Sans:h14
    22 set nu
    23 set lz
    24 set hid
    25 set magic
    26 set noerrorbells
    27 set novisualbell
    28 set vb t_vb=
    29
    30 set showmatch
    31
    32 set hlsearch
    33
    34 set nobackup
    35 set nowb
    36 set noswapfile
    37
    38 set nofen
    39 set fdl=0
    40
    41 set smarttab
    42 set lbr
    43
    44 set cursorline

    参考文章

    http://blog.tyraeltong.com/blog/2012/01/24/setup-web-development-environment-on-mac/ 

    http://glorywine.blogbus.com/logs/37358384.html











  • 相关阅读:
    poj1191(記憶化搜索)
    poj1088(記憶化搜索)
    二叉樹鏈表
    19_高级映射:一对多查询(使用resultMap)
    18_高级映射:一对一查询(使用resultMap)
    17_高级映射:一对一查询(使用resultType)
    15_CXF和Spring开发手机号查询网站
    14_CXF发布REST服务
    13_CXF和Spring整合发布服务
    12_CXF入门
  • 原文地址:https://www.cnblogs.com/cacique/p/2416992.html
Copyright © 2020-2023  润新知