Commit 3b6a695b authored by Ashley Valent's avatar Ashley Valent
Browse files

Merge branch 'master' of github.com:avalent/oh-my-zsh

parents 3ba10ad0 ef7e53a7
# web_search from terminal # web_search from terminal
function web_search() { function web_search() {
# get the open command emulate -L zsh
local open_cmd
if [[ "$OSTYPE" = darwin* ]]; then # define search engine URLS
open_cmd='open' typeset -A urls
else urls=(
open_cmd='xdg-open' google "https://www.google.com/search?q="
fi bing "https://www.bing.com/search?q="
yahoo "https://search.yahoo.com/search?p="
duckduckgo "https://www.duckduckgo.com/?q="
yandex "https://yandex.ru/yandsearch?text="
)
# define the open command
case "$OSTYPE" in
darwin*) open_cmd="open" ;;
cygwin*) open_cmd="cygstart" ;;
linux*) open_cmd="xdg-open" ;;
*) echo "Platform $OSTYPE not supported"
return 1
;;
esac
# check whether the search engine is supported # check whether the search engine is supported
if [[ ! $1 =~ '(google|bing|yahoo|duckduckgo)' ]]; if [[ -z "$urls[$1]" ]]; then
then
echo "Search engine $1 not supported." echo "Search engine $1 not supported."
return 1 return 1
fi fi
local url="http://www.$1.com" # search or go to main page depending on number of arguments passed
if [[ $# -gt 1 ]]; then
# no keyword provided, simply open the search engine homepage # build search url:
if [[ $# -le 1 ]]; then # join arguments passed with '+', then append to search engine URL
$open_cmd "$url" url="${urls[$1]}${(j:+:)@[2,-1]}"
return
fi
if [[ $1 == 'duckduckgo' ]]; then
#slightly different search syntax for DDG
url="${url}/?q="
else else
url="${url}/search?q=" # build main page url:
# split by '/', then rejoin protocol (1) and domain (2) parts with '//'
url="${(j://:)${(s:/:)urls[$1]}[1,2]}"
fi fi
shift # shift out $1
while [[ $# -gt 0 ]]; do
url="${url}$1+"
shift
done
url="${url%?}" # remove the last '+' nohup $open_cmd "$url" &>/dev/null
nohup $open_cmd "$url" >/dev/null 2&>1
} }
...@@ -45,6 +48,8 @@ alias bing='web_search bing' ...@@ -45,6 +48,8 @@ alias bing='web_search bing'
alias google='web_search google' alias google='web_search google'
alias yahoo='web_search yahoo' alias yahoo='web_search yahoo'
alias ddg='web_search duckduckgo' alias ddg='web_search duckduckgo'
alias yandex='web_search yandex'
#add your own !bang searches here #add your own !bang searches here
alias wiki='web_search duckduckgo \!w' alias wiki='web_search duckduckgo \!w'
alias news='web_search duckduckgo \!n' alias news='web_search duckduckgo \!n'
......
...@@ -99,10 +99,7 @@ prompt_context () { ...@@ -99,10 +99,7 @@ prompt_context () {
set_prompt () { set_prompt () {
# required for the prompt # required for the prompt
setopt prompt_subst setopt prompt_subst
autoload colors zsh/terminfo autoload zsh/terminfo
if [[ "$terminfo[colors]" -gt 8 ]]; then
colors
fi
# ######### PROMPT ######### # ######### PROMPT #########
PROMPT='${PROMPT_HEAD} PROMPT='${PROMPT_HEAD}
......
...@@ -7,7 +7,6 @@ get_git_dirty() { ...@@ -7,7 +7,6 @@ get_git_dirty() {
} }
autoload -Uz vcs_info autoload -Uz vcs_info
autoload -U colors && colors
zstyle ':vcs_info:*' check-for-changes true zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' unstagedstr '%F{red}*' # display this when there are unstaged changes zstyle ':vcs_info:*' unstagedstr '%F{red}*' # display this when there are unstaged changes
zstyle ':vcs_info:*' stagedstr '%F{yellow}+' # display this when there are staged changes zstyle ':vcs_info:*' stagedstr '%F{yellow}+' # display this when there are staged changes
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
# Based on bira theme # Based on bira theme
# load some modules # load some modules
autoload -U colors zsh/terminfo # Used in the colour alias below autoload -U zsh/terminfo # Used in the colour alias below
colors
setopt prompt_subst setopt prompt_subst
# make some aliases for the colours: (could use normal escape sequences too) # make some aliases for the colours: (could use normal escape sequences too)
......
...@@ -13,8 +13,6 @@ function virtualenv_info { ...@@ -13,8 +13,6 @@ function virtualenv_info {
PR_GIT_UPDATE=1 PR_GIT_UPDATE=1
setopt prompt_subst setopt prompt_subst
autoload colors
colors
autoload -U add-zsh-hook autoload -U add-zsh-hook
autoload -Uz vcs_info autoload -Uz vcs_info
......
...@@ -44,10 +44,7 @@ setprompt () { ...@@ -44,10 +44,7 @@ setprompt () {
### ###
# See if we can use colors. # See if we can use colors.
autoload colors zsh/terminfo autoload zsh/terminfo
if [[ "$terminfo[colors]" -ge 8 ]]; then
colors
fi
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE GREY; do for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE GREY; do
eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}' eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}' eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
......
autoload -U colors && colors
autoload -Uz vcs_info autoload -Uz vcs_info
zstyle ':vcs_info:*' stagedstr '%F{green}●' zstyle ':vcs_info:*' stagedstr '%F{green}●'
......
...@@ -13,7 +13,6 @@ local c7=$(printf "\033[38;5;149m") ...@@ -13,7 +13,6 @@ local c7=$(printf "\033[38;5;149m")
local c8=$(printf "\033[38;5;126m") local c8=$(printf "\033[38;5;126m")
local c9=$(printf "\033[38;5;162m") local c9=$(printf "\033[38;5;162m")
local foopath=$(perl /home/scp1/bin/foopath)
if [ "$TERM" = "linux" ]; then if [ "$TERM" = "linux" ]; then
c1=$(printf "\033[34;1m") c1=$(printf "\033[34;1m")
......
setopt prompt_subst setopt prompt_subst
autoload colors
colors
autoload -U add-zsh-hook autoload -U add-zsh-hook
autoload -Uz vcs_info autoload -Uz vcs_info
......
...@@ -16,13 +16,15 @@ ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}✗" ...@@ -16,13 +16,15 @@ ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}✗"
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}➦" ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}➦"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[magenta]%}✂" ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[magenta]%}✂"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[grey]%}✈" ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[grey]%}✈"
ZSH_THEME_GIT_PROMPT_SHA_BEFORE=" %{$fg[grey]%}"
ZSH_THEME_GIT_PROMPT_SHA_AFTER="%{$reset_color%}"
function mygit() { function mygit() {
ref1=$(git symbolic-ref HEAD 2> /dev/null) || return if [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]]; then
ref2=$(git rev-parse HEAD | head -c 6) || return ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref="$ref1 %{$fg[grey]%}$ref2" ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
#ref=$(git symbolic-ref HEAD 2> /dev/null) $(git rev-parse HEAD | head -c 6) || return echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(git_prompt_short_sha)$( git_prompt_status )%{$reset_color%}$ZSH_THEME_GIT_PROMPT_SUFFIX "
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$( git_prompt_status )%{$reset_color%}$ZSH_THEME_GIT_PROMPT_SUFFIX " fi
} }
function retcode() {} function retcode() {}
......
...@@ -63,10 +63,7 @@ setprompt () { ...@@ -63,10 +63,7 @@ setprompt () {
### ###
# See if we can use colors. # See if we can use colors.
autoload colors zsh/terminfo autoload zsh/terminfo
if [[ "$terminfo[colors]" -ge 8 ]]; then
colors
fi
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}' eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}' eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
......
...@@ -15,8 +15,6 @@ function virtualenv_info { ...@@ -15,8 +15,6 @@ function virtualenv_info {
PR_GIT_UPDATE=1 PR_GIT_UPDATE=1
setopt prompt_subst setopt prompt_subst
autoload colors
colors
autoload -U add-zsh-hook autoload -U add-zsh-hook
autoload -Uz vcs_info autoload -Uz vcs_info
......
autoload -U colors && colors
autoload -Uz vcs_info autoload -Uz vcs_info
zstyle ':vcs_info:*' stagedstr '%F{green}●' zstyle ':vcs_info:*' stagedstr '%F{green}●'
......
...@@ -23,8 +23,8 @@ fi ...@@ -23,8 +23,8 @@ fi
echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m" echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m"
cp $ZSH/templates/zshrc.zsh-template ~/.zshrc cp $ZSH/templates/zshrc.zsh-template ~/.zshrc
sed -i -e "/^ZSH=/ c\\ sed -i -e "/^export ZSH=/ c\\
ZSH=$ZSH export ZSH=$ZSH
" ~/.zshrc " ~/.zshrc
echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m" echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment