在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
InstallationThe Fontoh-my-git is shipped with 3 themes. The one showed above is called oppa-lana-style. It's based on the Awesome-Terminal-Fonts by @gabrielelana. The screenshots above use the font Source Code Pro by Adobe patched to include additional glyphs from Powerline and from Awesome-Terminal-Fonts, but you can choose any other of the Awesome-Terminal-Fonts. You can freely download the fonts from the original repo. To install one of the fonts, on OS X just double click on the corresponding On Linux you can either install the patched font or you can apply the Awesome-Terminal-Fonts fallback strategy. Then, configure your terminal with the desired font, and restart it. BashOne liner for OS X: git clone https://github.com/arialdomartini/oh-my-git.git ~/.oh-my-git && echo source ~/.oh-my-git/prompt.sh >> ~/.profile One liner for Ubuntu: git clone https://github.com/arialdomartini/oh-my-git.git ~/.oh-my-git && echo source ~/.oh-my-git/prompt.sh >> ~/.bashrc Then restart your Terminal. Manual installationFork the repo and git clone it in your home directory. Then add source $HOME/oh-my-git/prompt.sh to the bash startup file ( If you prefer to keep oh-my-git repository in a different directory, just modify the startup file accordingly to the chosen position source /wherever-you-want/oh-my-git/prompt.sh zshWith antigen installed, just add antigen use oh-my-zshantigen bundle arialdomartini/oh-my-gitantigen theme arialdomartini/oh-my-git-themes oppa-lana-style to your
How to install antigenantigen is a plugin manager for cd ~ && git clone https://github.com/zsh-users/antigen.git .antigen Then, edit your source "$HOME/.antigen/antigen.zsh"antigen use oh-my-zshantigen bundle arialdomartini/oh-my-gitantigen theme arialdomartini/oh-my-git-themes oppa-lana-styleantigen apply When you restart zsh, antigen will download and install all that's needed. Customizing symbolsYou can easily change any symbols used by the prompt. Take a look to the file prompt.sh (or to oppa-lana-style.zsh-theme if you use zsh). You will find a bunch of variables, each of them with its default value. The variables names should be auto-explanatory. Something like : ${omg_is_a_git_repo_symbol:='❤'}: ${omg_has_untracked_files_symbol:='∿'}: ${omg_has_adds_symbol:='+'}: ${omg_has_deletions_symbol:='-'}: ${omg_has_cached_deletions_symbol:='✖'}: ${omg_has_modifications_symbol:='✎'}: ${omg_has_cached_modifications_symbol:='☲'}: ${omg_ready_to_commit_symbol:='→'}: ${omg_is_on_a_tag_symbol:='⌫'} You can override any of those variables in your shell startup file. For example, just add a omg_is_on_a_tag_symbol='#' to your Disabling oh-my-gitoh-my-git can be disabled on a per-repository basis. Just add a [oh-my-git]enabled = false in the UninstallBash
zshRemove the lines antigen use oh-my-zshantigen bundle arialdomartini/oh-my-gitantigen theme arialdomartini/oh-my-git-themes oppa-lana-style from your TroubleshootingHelp, I installed oh-my-git but this is what I see:A: It's likely that you forgot to install the font. I don't want to install a new font!A: "No prob. You may select another theme, or you can customize symbols. Take a look to the prompt.sh file. It contains a list of pre-defined symbols, similar to: # Symbols: ${omg_is_a_git_repo_symbol:='❤'}: ${omg_has_untracked_files_symbol:='∿'}: ${omg_has_adds_symbol:='+'}: ${omg_has_deletions_symbol:='-'}: ${omg_has_modifications_symbol:='✎'} Those are just default values. If you wish to use another glyph for untracked file, just define a omg_has_untracked_files_symbol="whatever" in your shell startup file. With Bash the last symbol looks very bad, like thisA: Unfortunately, I haven't find a way to tell bash "print the next symbol using the background color currently used by the terminal" and as far as I know there's no way to achieve this result. Zsh is not affected by this issue, but bash is. As a consequence, when printing the last symbol, oh-my-git has no choice but setting explicitly the foreground and background colors. Currently, the standard background color is black. This is unfortunate, because if the terminal uses a different background color than black, the result is bad, as showed in the above screenshot. A smart solution is the one proposed by @Sgiath: in the color palette set the first color (the one in the top-left corner) same as background color, like this This in fact sets the "black" color to the same color used as the terminal background. If for any reasons you cannot change the palette, you can override the colors used to render the last symbol with the variable For example, if the terminal is using a gray background, you can add a background=240red='\e[0;31m'omg_last_symbol_color="${red}\[\033[48;5;${background}m\]" to your You can use foreground=160background=240omg_last_symbol_color="\[\033[38;5;${foreground}m\]\[\033[48;5;${background}m\]" if you want a more detailed control on the colors. Finding the right value is not trivial. Please, refer to this page for a the 256 colors code table. On OS X, I configured iTerm2 with the patched font, but the prompt is still broken.A: iTerm2 preferences have 2 sections for setting the font: one for Help! On Linux I can't install the font!A: You should refer to the documentation of Awesome-Terminal-Fonts. Anyway, this is how I personally setup the prompt on Ubuntu # Copy the awesome fonts to ~/.fontscd /tmpgit clone http://github.com/gabrielelana/awesome-terminal-fontscd awesome-terminal-fontsgit checkout patching-strategymkdir -p ~/.fontscp patched/*.ttf ~/.fonts# update the font-info cachesudo fc-cache -fv ~/.fonts Then, run Finally, install oh-my-zsh with the one-liner (if you use Bash) or with Antigen if you love zsh, and restart the Terminal. When I'm not in a git repo, I want to use my old, beloved prompt...A: Sure! Use the variable Help! I used the one-liner for OS X, but the prompt doesn't start!A: The one-liner for OS X adds the startup command in cd ~ && git clone https://github.com/arialdomartini/oh-my-git.git && echo source $HOME/oh-my-git/prompt.sh >> .bash_profile or just move the startup command echo source $HOME/oh-my-git/prompt.sh from Hey, where's my current virtualenv name? It disappeared from the prompt! Or it appears like thisA: Yes, actually the virtualenv's approach with prompts is pretty disappointing (see Virtualenv's bin/activate is Doing It Wrong): in fact, the script PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" that arrogantly prepends the virtualenv name to the current You can solve this problem disabling the standart virtualenv prompt injection and using the callback function Add VIRTUAL_ENV_DISABLE_PROMPT=truefunction omg_prompt_callback() { if [ -n "${VIRTUAL_ENV}" ]; then echo "\e[0;31m(`basename ${VIRTUAL_ENV}`)\e[0m " fi} to your shell startup script. It should render the prompt inside an active virtualenv like this ] You can use the call back function to inject whatever you want at the beginning of the second line. Known bugs and limitations
|
请发表评论