diff options
-rw-r--r-- | plugins/bundler/bundler.plugin.zsh | 48 | ||||
-rw-r--r-- | plugins/jira/jira.plugin.zsh | 2 | ||||
-rw-r--r-- | plugins/osx/osx.plugin.zsh | 34 | ||||
-rw-r--r-- | plugins/python/python.plugin.zsh | 1 | ||||
-rw-r--r-- | plugins/ssh-agent/ssh-agent.plugin.zsh | 2 | ||||
-rwxr-xr-x | plugins/wd2/wd2/wd.plugin.zsh | 9 | ||||
-rwxr-xr-x | plugins/wd2/wd2/wd.sh | 201 | ||||
-rw-r--r-- | themes/agnoster.zsh-theme | 4 | ||||
-rw-r--r-- | themes/linuxonly.zsh-theme (renamed from themes/linuxonly) | 0 |
9 files changed, 274 insertions, 27 deletions
diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh index 2e657e5a8..e390f8620 100644 --- a/plugins/bundler/bundler.plugin.zsh +++ b/plugins/bundler/bundler.plugin.zsh @@ -4,18 +4,6 @@ alias bp="bundle package" alias bo="bundle open" alias bu="bundle update" -bundler_version=`bundle version | cut -d' ' -f3` -if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then - if [[ "$(uname)" == 'Darwin' ]] - then - local cores_num="$(sysctl hw.ncpu | awk '{print $2}')" - else - local cores_num="$(nproc)" - fi - eval "alias bi='bundle install --jobs=$cores_num'" -else - alias bi='bundle install' -fi # The following is based on https://github.com/gma/bundler-exec @@ -44,14 +32,28 @@ _run-with-bundler() { fi } -## Main program -for cmd in $bundled_commands; do - eval "function unbundled_$cmd () { $cmd \$@ }" - eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}" - alias $cmd=bundled_$cmd - - if which _$cmd > /dev/null 2>&1; then - compdef _$cmd bundled_$cmd=$cmd - fi -done - +if _bundler-installed; then + bundler_version=`bundle version | cut -d' ' -f3` + if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then + if [[ "$(uname)" == 'Darwin' ]] + then + local cores_num="$(sysctl hw.ncpu | awk '{print $2}')" + else + local cores_num="$(nproc)" + fi + eval "alias bi='bundle install --jobs=$cores_num'" + else + alias bi='bundle install' + fi + + ## Main program + for cmd in $bundled_commands; do + eval "function unbundled_$cmd () { $cmd \$@ }" + eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}" + alias $cmd=bundled_$cmd + + if which _$cmd > /dev/null 2>&1; then + compdef _$cmd bundled_$cmd=$cmd + fi + done +fi diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 9aa192c1e..739ee7142 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -31,7 +31,7 @@ open_jira_issue () { if [ -z "$1" ]; then echo "Opening new issue" - `open $jira_url/secure/CreateIssue!default.jspa` + $open_cmd "$jira_url/secure/CreateIssue!default.jspa" else echo "Opening issue #$1" if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index dd785f911..608ec3789 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -157,3 +157,37 @@ function trash() { function vncviewer() { open vnc://$@ } + +# iTunes control function +function itunes() { + local opt=$1 + shift + case "$opt" in + launch|play|pause|stop|rewind|resume|quit) + ;; + mute) + opt="set mute to true" + ;; + unmute) + opt="set mute to false" + ;; + next|previous) + opt="$opt track" + ;; + ""|-h|--help) + echo "Usage: itunes <option>" + echo "option:" + echo "\tlaunch|play|pause|stop|rewind|resume|quit" + echo "\tmute|unmute\tcontrol volume set" + echo "\tnext|previous\tplay next or previous track" + echo "\thelp\tshow this message and exit" + return 0 + ;; + *) + print "Unkonwn option: $opt" + return 1 + ;; + esac + osascript -e "tell application \"iTunes\" to $opt" +} + diff --git a/plugins/python/python.plugin.zsh b/plugins/python/python.plugin.zsh index 852c8b919..a8f9760ad 100644 --- a/plugins/python/python.plugin.zsh +++ b/plugins/python/python.plugin.zsh @@ -6,6 +6,7 @@ alias pyfind='find . -name "*.py"' function pyclean() { ZSH_PYCLEAN_PLACES=${*:-'.'} find ${ZSH_PYCLEAN_PLACES} -type f -name "*.py[co]" -delete + find ${ZSH_PYCLEAN_PLACES} -type d -name "__pycache__" -delete } # Grep among .py files diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 3b0042a7d..a1e64ad0f 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -57,7 +57,7 @@ if [[ ${_plugin__forwarding} == "yes" && -n "$SSH_AUTH_SOCK" ]]; then elif [ -f "${_plugin__ssh_env}" ]; then # Source SSH settings, if applicable . ${_plugin__ssh_env} > /dev/null - ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || { + ps x | grep ${SSH_AGENT_PID} | grep ssh-agent > /dev/null || { _plugin__start_agent; } else diff --git a/plugins/wd2/wd2/wd.plugin.zsh b/plugins/wd2/wd2/wd.plugin.zsh new file mode 100755 index 000000000..e0846ffd9 --- /dev/null +++ b/plugins/wd2/wd2/wd.plugin.zsh @@ -0,0 +1,9 @@ +#!/bin/zsh + +# WARP +# ==== +# oh-my-zsh plugin +# +# @github.com/mfaerevaag/wd + +alias wd='. ~/.oh-my-zsh/plugins/wd/wd.sh' diff --git a/plugins/wd2/wd2/wd.sh b/plugins/wd2/wd2/wd.sh new file mode 100755 index 000000000..7852028c0 --- /dev/null +++ b/plugins/wd2/wd2/wd.sh @@ -0,0 +1,201 @@ +#!/bin/zsh + +# WARP +# ==== +# Jump to custom directories in terminal +# because `cd` takes too long... +# +# @github.com/mfaerevaag/wd + + +## variables +CONFIG=$HOME/.warprc + +## colors +BLUE="\033[96m" +GREEN="\033[92m" +YELLOW="\033[93m" +RED="\033[91m" +NOC="\033[m" + + +## load warp points +typeset -A points +while read line +do + arr=(${(s,:,)line}) + key=${arr[1]} + val=${arr[2]} + + points[$key]=$val +done < $CONFIG + + +## functions +# prepended wd_ to not conflict with your environment (no sub shell) + +wd_warp() +{ + if [[ $1 =~ "^\.+$" ]] + then + if [[ $#1 < 2 ]] + then + wd_print_msg $YELLOW "Warping to current directory?" + else + (( n = $#1 - 1 )) + wd_print_msg $BLUE "Warping..." + cd -$n > /dev/null + fi + elif [[ ${points[$1]} != "" ]] + then + wd_print_msg $BLUE "Warping..." + cd ${points[$1]} + else + wd_print_msg $RED "Unkown warp point '$1'" + fi +} + +wd_add() +{ + if [[ $1 =~ "^\.+$" ]] + then + wd_print_msg $RED "Illeagal warp point (see README)." + elif [[ ${points[$1]} == "" ]] || $2 + then + wd_remove $1 > /dev/null + print "$1:$PWD" >> $CONFIG + wd_print_msg $GREEN "Warp point added" + else + wd_print_msg $YELLOW "Warp point '$1' alredy exists. Use 'add!' to overwrite." + fi +} + +wd_remove() +{ + if [[ ${points[$1]} != "" ]] + then + if wd_tmp=`sed "/^$1:/d" $CONFIG` + then + echo $wd_tmp > $CONFIG + wd_print_msg $GREEN "Warp point removed" + else + wd_print_msg $RED "Warp point unsuccessfully removed. Sorry!" + fi + else + wd_print_msg $RED "Warp point was not found" + fi +} + +wd_show() +{ + wd_print_msg $BLUE "Warp points to current directory:" + wd_list_all | grep $PWD$ +} + +wd_list_all() +{ + wd_print_msg $BLUE "All warp points:" + while read line + do + if [[ $line != "" ]] + then + arr=(${(s,:,)line}) + key=${arr[1]} + val=${arr[2]} + + print "\t" $key "\t -> \t" $val + fi + done < $CONFIG +} + +wd_print_msg() +{ + if [[ $1 == "" || $2 == "" ]] + then + print " $RED*$NOC Could not print message. Sorry!" + else + print " $1*$NOC $2" + fi +} + +wd_print_usage() +{ + print "Usage: wd [add|-a|--add] [rm|-r|--remove] [ls|-l|--list] <point>" + print "\nCommands:" + print "\t add \t Adds the current working directory to your warp points" + print "\t add! \t Overwrites existing warp point" + print "\t remove Removes the given warp point" + print "\t list \t Outputs all stored warp points" + print "\t help \t Show this extremely helpful text" +} + + +## run + +# get opts +args=`getopt -o a:r:lhs -l add:,remove:,list,help,show -- $*` + +if [[ $? -ne 0 || $#* -eq 0 ]] +then + wd_print_usage +else + # can't exit, as this would exit the excecuting shell + # e.i. your terminal + + #set -- $args # WTF + + for i + do + case "$i" + in + -a|--add|add) + wd_add $2 false + shift + shift + break + ;; + -a!|--add!|add!) + wd_add $2 true + shift + shift + break + ;; + -r|--remove|rm) + wd_remove $2 + shift + shift + break + ;; + -l|--list|ls) + wd_list_all + shift + break + ;; + -h|--help|help) + wd_print_usage + shift + break + ;; + -s|--show|show) + wd_show + shift + break + ;; + *) + wd_warp $i + shift + break + ;; + --) + shift; break;; + esac + done +fi + + +## garbage collection +# if not, next time warp will pick up variables from this run +# remember, there's no sub shell +points="" +args="" +unhash -d val &> /dev/null # fixes issue #1 diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 2db565266..762f63c5b 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -124,7 +124,7 @@ prompt_hg() { else prompt_segment green black fi - echo -n " $rev@$branch" $st + echo -n "☿ $rev@$branch" $st fi fi } @@ -137,7 +137,7 @@ prompt_dir() { # Virtualenv: current working virtualenv prompt_virtualenv() { local virtualenv_path="$VIRTUAL_ENV" - if [[ -n $virtualenv_path && -z $VIRTUAL_ENV_DISABLE_PROMPT ]]; then + if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then prompt_segment blue black "(`basename $virtualenv_path`)" fi } diff --git a/themes/linuxonly b/themes/linuxonly.zsh-theme index a11b80d7f..a11b80d7f 100644 --- a/themes/linuxonly +++ b/themes/linuxonly.zsh-theme |