diff --git a/custom/plugins/gitignore/gitignore.plugin.zsh b/custom/plugins/gitignore/gitignore.plugin.zsh new file mode 100644 index 000000000..332497cec --- /dev/null +++ b/custom/plugins/gitignore/gitignore.plugin.zsh @@ -0,0 +1,12 @@ +function gi() { curl http://gitignore.io/api/$@ ;} + +_gitignireio_get_command_list() { + curl -s http://gitignore.io/api/list | tr "," "\n" +} + +_gitignireio () { + compset -P '*,' + compadd -S '' `_gitignireio_get_command_list` +} + +compdef _gitignireio gi \ No newline at end of file diff --git a/custom/plugins/sfffe/sfffe.plugin.zsh b/custom/plugins/sfffe/sfffe.plugin.zsh new file mode 100644 index 000000000..a0f034908 --- /dev/null +++ b/custom/plugins/sfffe/sfffe.plugin.zsh @@ -0,0 +1,28 @@ +# ------------------------------------------------------------------------------ +# FILE: sfffe.plugin.zsh +# DESCRIPTION: search file for FE +# AUTHOR: yleo77 (ylep77@gmail.com) +# VERSION: 0.1 +# REQUIRE: ack +# ------------------------------------------------------------------------------ + +if [ ! -x $(which ack) ]; then + echo \'ack\' is not installed! + exit -1 +fi + +ajs() { + ack "$@" --type js +} + +acss() { + ack "$@" --type css +} + +fjs() { + find ./ -name "$@*" -type f | grep '\.js' +} + +fcss() { + find ./ -name "$@*" -type f | grep '\.css' +} diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh index 28131ff80..a4482319a 100644 --- a/plugins/debian/debian.plugin.zsh +++ b/plugins/debian/debian.plugin.zsh @@ -5,9 +5,19 @@ # # Debian-related zsh aliases and functions for zsh +# Function to check if a command exists +exists() { + if command -v $1 >/dev/null 2>&1 + then + return 0 + else + return 1 + fi +} + # Use aptitude if installed, or apt-get if not. # You can just set apt_pref='apt-get' to override it. -if [[ -e $( which -p aptitude 2>&1 ) ]]; then +if exists aptitude; then apt_pref='aptitude' apt_upgr='safe-upgrade' else @@ -16,7 +26,7 @@ else fi # Use sudo by default if it's installed -if [[ -e $( which -p sudo 2>&1 ) ]]; then +if exists sudo; then use_sudo=1 fi diff --git a/plugins/fortune/fortune.plugin.zsh b/plugins/fortune/fortune.plugin.zsh new file mode 100644 index 000000000..25a7c5193 --- /dev/null +++ b/plugins/fortune/fortune.plugin.zsh @@ -0,0 +1,4 @@ +if type fortune &> /dev/null; then + fortune + echo +fi diff --git a/plugins/gnu-colors/gnu-colors.plugin.zsh b/plugins/gnu-colors/gnu-colors.plugin.zsh new file mode 100644 index 000000000..fe5293eef --- /dev/null +++ b/plugins/gnu-colors/gnu-colors.plugin.zsh @@ -0,0 +1,6 @@ +if type dircolors &> /dev/null; then + eval `dircolors ~/.dir_colors` +fi + +# Temporary workaround for tab completion LS_COLORS; Issue #1563 +zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh index fb514a44c..203e09b9a 100644 --- a/plugins/tmux/tmux.plugin.zsh +++ b/plugins/tmux/tmux.plugin.zsh @@ -34,7 +34,7 @@ if which tmux &> /dev/null # The TERM to use for 256 color terminals. # Tmux states this should be screen-256color, but you may need to change it on # systems without the proper terminfo - [[ -n "$ZSH_TMUX_FIXTERM_WITH_256COLOR" ]] || ZSH_TMUX_FIXTERM_WITH_256COLOR="screen-256color" + [[ -n "$ZSH_TMUX_FIXTERM_WITH_256COLOR" ]] || ZSH_TMUX_FIXTERM_WITH_256COLOR="xterm-256color" # Get the absolute path to the current directory @@ -49,7 +49,7 @@ if which tmux &> /dev/null fi # Set the correct local config file to use. - if [[ "$ZSH_TMUX_ITERM2" == "false" ]] && [[ -f $HOME/.tmux.conf || -h $HOME/.tmux.conf ]] + if [[ "$ZSH_TMUX_ITERM2" == "false" ]] && [[ -e "$HOME/.tmux.conf" ]] then #use this when they have a ~/.tmux.conf export _ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.extra.conf" @@ -61,19 +61,37 @@ if which tmux &> /dev/null # Wrapper function for tmux. function _zsh_tmux_plugin_run() { + if [[ "$ZSH_TMUX_ITERM2" == "true" ]] + then _fix='-CC' + else _fix='' + fi + if [[ "$ZSH_TMUX_FIXTERM" == "true" && "$ZSH_TMUX_ITERM2" == "false" ]] + then _file="-f $_ZSH_TMUX_FIXED_CONFIG" + else _file='' # Can't use -f with -CC + fi + if [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] + then _exit='exit' + else _exit='' + fi # We have other arguments, just run them if [[ -n "$@" ]] then - \tmux $@ + tmux "$@" # Try to connect to an existing session. elif [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] then - \tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` attach || \tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` `[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && echo '-f '$_ZSH_TMUX_FIXED_CONFIG` new-session - [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit + if (tmux has) + then + \tmux $_fix attach + $_exit + else + \tmux $_fix $_file new + $_exit + fi # Just run tmux, fixing the TERM variable if requested. else - \tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` `[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && echo '-f '$_ZSH_TMUX_FIXED_CONFIG` - [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit + \tmux $_fix $_file new + $_exit fi } diff --git a/themes/agnoster_beta.zsh-theme b/themes/agnoster_beta.zsh-theme new file mode 100644 index 000000000..4f832ec97 --- /dev/null +++ b/themes/agnoster_beta.zsh-theme @@ -0,0 +1,116 @@ +# vim:ft=zsh ts=2 sw=2 sts=2 +# +# agnoster's Theme - https://gist.github.com/3712874 +# A Powerline-inspired theme for ZSH +# +# # README +# +# In order for this theme to render correctly, you will need a +# [Powerline-patched font](https://gist.github.com/1595572). +# +# In addition, I recommend the +# [Solarized theme](https://github.com/altercation/solarized/) and, if you're +# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app - +# it has significantly better color fidelity. +# +# # Goals +# +# The aim of this theme is to only show you *relevant* information. Like most +# prompts, it will only show git information when in a git working directory. +# However, it goes a step further: everything from the current user and +# hostname to whether the last call exited with an error to whether background +# jobs are running in this shell will all be displayed automatically when +# appropriate. + +### Segment drawing +# A few utility functions to make it easy and re-usable to draw segmented prompts + +CURRENT_BG='NONE' +SEGMENT_SEPARATOR='' +BRANCH_SYMBOL='' + +# Begin a segment +# Takes two arguments, background and foreground. Both can be omitted, +# rendering default background/foreground. +prompt_segment() { + local bg fg + [[ -n $1 ]] && bg="%K{$1}" || bg="%k" + [[ -n $2 ]] && fg="%F{$2}" || fg="%f" + if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then + echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} " + else + echo -n "%{$bg%}%{$fg%} " + fi + CURRENT_BG=$1 + [[ -n $3 ]] && echo -n $3 +} + +# End the prompt, closing any open segments +prompt_end() { + if [[ -n $CURRENT_BG ]]; then + echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" + else + echo -n "%{%k%}" + fi + echo -n "%{%f%}" + CURRENT_BG='' +} + +### Prompt components +# Each component will draw itself, and hide itself if no information needs to be shown + +# Context: user@hostname (who am I and where am I) +prompt_context() { + local user=`whoami` + + if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then + prompt_segment black default "%(!.%{%F{yellow}%}.)$user@%m" + fi +} + +# Git: branch/detached head, dirty status +prompt_git() { + local ref dirty + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + ZSH_THEME_GIT_PROMPT_DIRTY='±' + dirty=$(parse_git_dirty) + ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)" + if [[ -n $dirty ]]; then + prompt_segment yellow black + else + prompt_segment green black + fi + echo -n "${ref/refs\/heads\//$BRANCH_SYMBOL }$dirty" + fi +} + +# Dir: current working directory +prompt_dir() { + prompt_segment blue black '%~' +} + +# Status: +# - was there an error +# - am I root +# - are there background jobs? +prompt_status() { + local symbols + symbols=() + [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" + [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" + [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" + + [[ -n "$symbols" ]] && prompt_segment black default "$symbols" +} + +## Main prompt +build_prompt() { + RETVAL=$? + prompt_status + prompt_context + prompt_dir + prompt_git + prompt_end +} + +PROMPT='%{%f%b%k%}$(build_prompt) '