diff --git a/README.markdown b/README.markdown deleted file mode 100644 index 588d215..0000000 --- a/README.markdown +++ /dev/null @@ -1,16 +0,0 @@ -What is this? -============= - -This is an aggregation of every publishable configuration file used by Caio Romão. These configuration files are generally called 'dotfiles' and that's the reason for this project's name. - -Notes -===== - -Some of these configuration files (which are generally called 'dotfiles') were assembled from different and untracked sources. If you own any piece of code which I haven't credited, please send me a note and I'll gladly give credit where it's due. - -License -======= - -Unless stated otherwise, you're free to copy, modify and distribute anything here that was **created by me**. - -As stated before, some of the content come from untracked sources and I can't (and won't) be responsible for it's licensing, so if you're going to use anything here for non-GPLed projects, please send me a note **AND** use google to see if someone owns a piece of it. diff --git a/bashrc b/bashrc deleted file mode 100644 index abc5e66..0000000 --- a/bashrc +++ /dev/null @@ -1,211 +0,0 @@ -export EDITOR=vim -export PYTHONSTARTUP="${HOME}/.pythonrc.py" - -# {{{ Shell options -shopt -s checkjobs -shopt -s checkwinsize -shopt -s cmdhist -shopt -s extglob -shopt -s histappend -shopt -s no_empty_cmd_completion -# }}} - -# {{{ *PATH variables helpers -pathremove() { - local IFS=':' - local NEWPATH - local DIR - local PATHVARIABLE=${2:-PATH} - for DIR in ${!PATHVARIABLE} ; do - if [ "$DIR" != "$1" ] ; then - NEWPATH=${NEWPATH:+$NEWPATH:}$DIR - fi - done - export $PATHVARIABLE="$NEWPATH" -} - -unckecked_pathappend() { - pathremove "$1" "$2" - local PATHVARIABLE=${2:-PATH} - export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1" -} - -pathprepend() { - test ! -d "${1}" && return 0 - pathremove "$1" "$2" - local PATHVARIABLE=${2:-PATH} - export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}" -} - -pathappend() { - test ! -d "${1}" && return 0 - unckecked_pathappend "$1" "$2" -} - -alias pwdappend='pathappend $(pwd)' -# }}} - -# {{{ Source scripts helper -do_source() { - for file in ${@}; do - test ! -f ${file} -o ! -x ${file} && continue - . ${file} || echo ">>> Error loading ${file}" 1>&2 - done -} -# }}} - -# Custom bin-dir -pathprepend ~/bin - -# Load custom scripts -do_source ~/.source/* - -# Load custom non-versioned scripts -do_source ~/.source.local.d/* - -[ -f ~/.dircolors ] && eval $(dircolors ~/.dircolors) - -# Disable flow control if stdin is a terminal -[ -t 0 ] && (stty -ixon -ixoff; stty werase undef) - -# {{{ Colors -col_txtblk='\[\e[0;30m\]' # Black - Regular -col_txtred='\[\e[0;31m\]' # Red -col_txtgrn='\[\e[0;32m\]' # Green -col_txtylw='\[\e[0;33m\]' # Yellow -col_txtblu='\[\e[0;34m\]' # Blue -col_txtpur='\[\e[0;35m\]' # Purple -col_txtcyn='\[\e[0;36m\]' # Cyan -col_txtwht='\[\e[0;37m\]' # White -col_bldblk='\[\e[1;30m\]' # Black - Bold -col_bldred='\[\e[1;31m\]' # Red -col_bldgrn='\[\e[1;32m\]' # Green -col_bldylw='\[\e[1;33m\]' # Yellow -col_bldblu='\[\e[1;34m\]' # Blue -col_bldpur='\[\e[1;35m\]' # Purple -col_bldcyn='\[\e[1;36m\]' # Cyan -col_bldwht='\[\e[1;37m\]' # White -col_unkblk='\[\e[4;30m\]' # Black - Underline -col_undred='\[\e[4;31m\]' # Red -col_undgrn='\[\e[4;32m\]' # Green -col_undylw='\[\e[4;33m\]' # Yellow -col_undblu='\[\e[4;34m\]' # Blue -col_undpur='\[\e[4;35m\]' # Purple -col_undcyn='\[\e[4;36m\]' # Cyan -col_undwht='\[\e[4;37m\]' # White -col_bakblk='\[\e[40m\]' # Black - Background -col_bakred='\[\e[41m\]' # Red -col_badgrn='\[\e[42m\]' # Green -col_bakylw='\[\e[43m\]' # Yellow -col_bakblu='\[\e[44m\]' # Blue -col_bakpur='\[\e[45m\]' # Purple -col_bakcyn='\[\e[46m\]' # Cyan -col_bakwht='\[\e[47m\]' # White -col_txtrst='\[\e[0m\]' # Text Reset -# }}} - -# {{{ Bash Prompt -bash_prompt_cmd() { - local RETVAL=$? - PS1="" - - append_ps1() { - PS1="${PS1}${1}" - } - - transform_pwd() { - curdir="$@" - curdir=${curdir/#~\/src\//:} - curdir=${curdir/#:personal\//${col_txtcyn}➤${col_txtblu}} - curdir=${curdir/#:work\//${col_txtred}⚒${col_txtblu}} - - curdir=${curdir/#~\/etc\//${col_txtpur}ж${col_txtblu}} - echo $curdir - } - - # Add hostname if connected through SSH - if [ -n "$SSH_CLIENT" ]; then - append_ps1 "${col_bldgrn}$(hostname -s) " - fi - - # CWD - CUR_DIR=${PWD/$HOME/\~} - append_ps1 "${col_txtblu}$(transform_pwd ${CUR_DIR})" - - # Return-code - if [ $RETVAL -ne 0 ]; then - append_ps1 " ${col_bldred}${RETVAL}!" - fi - - # Virtualenv - local envname=$(basename $VIRTUAL_ENV 2>/dev/null) - if [ -n "$envname" ]; then - append_ps1 " ${col_txtylw}·${envname}·" - fi - - # Pythonbrew - local PYBREW="$(which python 2>/dev/null|sed -n 's/.*Python-\([0-9].[0-9]\).*/\1/p')" - if [ ! -z "$PYBREW" ]; then - append_ps1 " ${col_txtpur}∝${PYBREW}" - fi - - # RVM - if [ ! -z $RUBY_VERSION ]; then - append_ps1 " ${col_txtgrn}∼$(echo $RUBY_VERSION |sed 's/.*-\(.\+\)-.*/\1/g')" - fi - - # Source-controlled directories - __vcs_dir - if [ ! -z "$__vcs_prefix" ]; then - append_ps1 " ${col_bldwht}${__vcs_prefix}${__vcs_ref}" - fi - - # Super-user identification - if [ "$UID" -eq "0" ]; then - append_ps1 " ${col_txtred}#" - else - append_ps1 " ${col_txtwht}$" - fi - - # Reset colors - append_ps1 "${col_txtrst} " - - export PS1 -} -PROMPT_COMMAND=bash_prompt_cmd -# }}} - -# {{{ Aliases -alias mv='mv -i' -alias cp=' cp -i' -alias rm='rm -I' -alias j='jobs' -alias grep='egrep' -alias ls='ls --color -h --group-directories-first' -alias l='ls -lh' -alias la='ls -lhA' -alias a='ls -d .*' -alias -- -='cd -' -alias beep="echo -ne '\a'" -alias S="screen -S" -alias p='ps -eo pid,ruser,cmd| grep -i' -alias gg='git grep' -alias G='grep -i' -# }}} - -# {{{ History -_hist_ignore_fullcmd() { - for arg in ${@}; do - unckecked_pathappend "${arg} *" HISTIGNORE - done -} -export HISTSIZE=40000 -export HISTFILESIZE=40000 -export HISTIGNORE="ls:l:c:clear:d:cd:bg:fg:wnext:wprev:alsamixer:history" -export HISTCONTROL="erasedups:ignorespace" -export HISTTIMEFORMAT='%m%d %H%M: ' -_hist_ignore_fullcmd l jk h dl unpack -# }}} - -# avoid carrying over test status -true diff --git a/dircolors b/dircolors deleted file mode 100644 index db0378e..0000000 --- a/dircolors +++ /dev/null @@ -1,258 +0,0 @@ - -# Dark 256 color solarized theme for the color GNU ls utility. -# Used and tested with dircolors (GNU coreutils) 8.5 -# -# @author {@link http://sebastian.tramp.name Sebastian Tramp} -# @license http://sam.zoy.org/wtfpl/ Do What The Fuck You Want To Public License (WTFPL) -# -# More Information at -# https://github.com/seebi/dircolors-solarized - -# Term Section -TERM Eterm -TERM ansi -TERM color-xterm -TERM con132x25 -TERM con132x30 -TERM con132x43 -TERM con132x60 -TERM con80x25 -TERM con80x28 -TERM con80x30 -TERM con80x43 -TERM con80x50 -TERM con80x60 -TERM cons25 -TERM console -TERM cygwin -TERM dtterm -TERM eterm-color -TERM gnome -TERM gnome-256color -TERM jfbterm -TERM konsole -TERM kterm -TERM linux -TERM linux-c -TERM mach-color -TERM mlterm -TERM putty -TERM rxvt -TERM rxvt-256color -TERM rxvt-cygwin -TERM rxvt-cygwin-native -TERM rxvt-unicode -TERM rxvt-unicode256 -TERM rxvt-unicode-256color -TERM screen -TERM screen-256color -TERM screen-256color-bce -TERM screen-bce -TERM screen-w -TERM screen.linux -TERM vt100 -TERM xterm -TERM xterm-16color -TERM xterm-256color -TERM xterm-88color -TERM xterm-color -TERM xterm-debian - -## Documentation -# -# standard colors -# -# Below are the color init strings for the basic file types. A color init -# string consists of one or more of the following numeric codes: -# Attribute codes: -# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed -# Text color codes: -# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white -# Background color codes: -# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white -# -# -# 256 color support -# see here: http://www.mail-archive.com/bug-coreutils@gnu.org/msg11030.html) -# -# Text 256 color coding: -# 38;5;COLOR_NUMBER -# Background 256 color coding: -# 48;5;COLOR_NUMBER - -## Special files - -NORMAL 00;38;5;244 # no color code at all -#FILE 00 # regular file: use no color at all -RESET 0 # reset to "normal" color -DIR 00;38;5;33 # directory 01;34 -LINK 01;38;5;37 # symbolic link. (If you set this to 'target' instead of a - # numerical value, the color is as for the file pointed to.) -MULTIHARDLINK 00 # regular file with more than one link -FIFO 48;5;230;38;5;136;01 # pipe -SOCK 48;5;230;38;5;136;01 # socket -DOOR 48;5;230;38;5;136;01 # door -BLK 48;5;230;38;5;244;01 # block device driver -CHR 48;5;230;38;5;244;01 # character device driver -ORPHAN 48;5;235;38;5;160 # symlink to nonexistent file, or non-stat'able file -SETUID 48;5;160;38;5;230 # file that is setuid (u+s) -SETGID 48;5;136;38;5;230 # file that is setgid (g+s) -CAPABILITY 30;41 # file with capability -STICKY_OTHER_WRITABLE 48;5;64;38;5;230 # dir that is sticky and other-writable (+t,o+w) -OTHER_WRITABLE 48;5;235;38;5;33 # dir that is other-writable (o+w) and not sticky -STICKY 48;5;33;38;5;230 # dir with the sticky bit set (+t) and not other-writable -# This is for files with execute permission: -EXEC 01;38;5;64 - -## Archives or compressed (violet + bold for compression) -.tar 00;38;5;61 -.tgz 01;38;5;61 -.arj 01;38;5;61 -.taz 01;38;5;61 -.lzh 01;38;5;61 -.lzma 01;38;5;61 -.tlz 01;38;5;61 -.txz 01;38;5;61 -.zip 01;38;5;61 -.z 01;38;5;61 -.Z 01;38;5;61 -.dz 01;38;5;61 -.gz 01;38;5;61 -.lz 01;38;5;61 -.xz 01;38;5;61 -.bz2 01;38;5;61 -.bz 01;38;5;61 -.tbz 01;38;5;61 -.tbz2 01;38;5;61 -.tz 01;38;5;61 -.deb 01;38;5;61 -.rpm 01;38;5;61 -.jar 01;38;5;61 -.rar 01;38;5;61 -.ace 01;38;5;61 -.zoo 01;38;5;61 -.cpio 01;38;5;61 -.7z 01;38;5;61 -.rz 01;38;5;61 -.apk 01;38;5;61 - -# Image formats (yellow) -.jpg 00;38;5;136 -.JPG 00;38;5;136 #stupid but needed -.jpeg 00;38;5;136 -.gif 00;38;5;136 -.bmp 00;38;5;136 -.pbm 00;38;5;136 -.pgm 00;38;5;136 -.ppm 00;38;5;136 -.tga 00;38;5;136 -.xbm 00;38;5;136 -.xpm 00;38;5;136 -.tif 00;38;5;136 -.tiff 00;38;5;136 -.png 00;38;5;136 -.svg 00;38;5;136 -.svgz 00;38;5;136 -.mng 00;38;5;136 -.pcx 00;38;5;136 -.dl 00;38;5;136 -.xcf 00;38;5;136 -.xwd 00;38;5;136 -.yuv 00;38;5;136 -.cgm 00;38;5;136 -.emf 00;38;5;136 -.eps 00;38;5;136 -.CR2 00;38;5;136 -.ico 00;38;5;136 - -# Files of special interest (base1 + bold) -.tex 01;38;5;245 -.rdf 01;38;5;245 -.owl 01;38;5;245 -.n3 01;38;5;245 -.ttl 01;38;5;245 -.nt 01;38;5;245 -.torrent 01;38;5;245 -*Makefile 01;38;5;245 -*Rakefile 01;38;5;245 -*build.xml 01;38;5;245 -*rc 01;38;5;245 -*1 01;38;5;245 -.nfo 01;38;5;245 -*README 01;38;5;245 -*README.txt 01;38;5;245 -*readme.txt 01;38;5;245 -*README.md 01;38;5;245 -*README.markdown 01;38;5;245 -*ini 01;38;5;245 -*yml 01;38;5;245 -*cfg 01;38;5;245 -*conf 01;38;5;245 - -# "unimportant" files as logs and backups (base01) -.log 00;38;5;240 -.bak 00;38;5;240 -.aux 00;38;5;240 -.bbl 00;38;5;240 -.blg 00;38;5;240 -*~ 00;38;5;240 -*# 00;38;5;240 -.part 00;38;5;240 -.incomplete 00;38;5;240 -.swp 00;38;5;240 -.tmp 00;38;5;240 -.temp 00;38;5;240 -.o 00;38;5;240 -.pyc 00;38;5;240 -.class 00;38;5;240 -.cache 00;38;5;240 - -# Audio formats (orange) -.aac 00;38;5;166 -.au 00;38;5;166 -.flac 00;38;5;166 -.mid 00;38;5;166 -.midi 00;38;5;166 -.mka 00;38;5;166 -.mp3 00;38;5;166 -.mpc 00;38;5;166 -.ogg 00;38;5;166 -.ra 00;38;5;166 -.wav 00;38;5;166 -.m4a 00;38;5;166 -# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions -.axa 00;38;5;166 -.oga 00;38;5;166 -.spx 00;38;5;166 -.xspf 00;38;5;166 - -# Video formats (as audio + bold) -.mov 01;38;5;166 -.mpg 01;38;5;166 -.mpeg 01;38;5;166 -.m2v 01;38;5;166 -.mkv 01;38;5;166 -.ogm 01;38;5;166 -.mp4 01;38;5;166 -.m4v 01;38;5;166 -.mp4v 01;38;5;166 -.vob 01;38;5;166 -.qt 01;38;5;166 -.nuv 01;38;5;166 -.wmv 01;38;5;166 -.asf 01;38;5;166 -.rm 01;38;5;166 -.rmvb 01;38;5;166 -.flc 01;38;5;166 -.avi 01;38;5;166 -.fli 01;38;5;166 -.flv 01;38;5;166 -.gl 01;38;5;166 -.m2ts 01;38;5;166 -# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions -.axv 01;38;5;166 -.anx 01;38;5;166 -.ogv 01;38;5;166 -.ogx 01;38;5;166 - - diff --git a/source/bashcompletion.sh b/source/bashcompletion.sh deleted file mode 100755 index 66cc84d..0000000 --- a/source/bashcompletion.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -__load_bashcompletion() { - local bashcomp="/etc/bash_completion" - test ! -r ${bashcomp} && return 0 - . ${bashcomp} -} - -__load_bashcompletion diff --git a/source/dircolors.sh b/source/dircolors.sh deleted file mode 100755 index 6f0bf5e..0000000 --- a/source/dircolors.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -dirfile=${HOME}/.dircolors -test -f ${dirfile} && eval $(dircolors $dirfile) || true diff --git a/source/gae.sh b/source/gae.sh deleted file mode 100755 index 3d10066..0000000 --- a/source/gae.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -__load_gae() { - local gaepath="${HOME}/src/sdks/google_appengine" - test ! -d ${gaepath} && return 0 - pathprepend ${gaepath} -} - -__load_gae diff --git a/source/haskell.sh b/source/haskell.sh deleted file mode 100755 index ff7e2e3..0000000 --- a/source/haskell.sh +++ /dev/null @@ -1,8 +0,0 @@ -__load_cabal() { - local cabal_dir="${HOME}/.cabal" - test ! -d ${cabal_dir} && return 0 - pathprepend ${cabal_dir}/bin/ - export MANPATH=${cabal_dir}/share/man/:$(manpath -g) -} - -__load_cabal diff --git a/source/make_dir_complete.sh b/source/make_dir_complete.sh deleted file mode 100755 index 07e460f..0000000 --- a/source/make_dir_complete.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -make_dir_complete() { - local aliasname=$1 - local dirname=$(readlink -f $2) - local prgname="__s_${aliasname}__" - FUNC="function $prgname() { - local cur len wrkdir; - local IFS=\$'\\n' - wrkdir=\"$dirname\" - cur=\${COMP_WORDS[COMP_CWORD]}; - len=\$((\${#wrkdir} + 2)); - COMPREPLY=( \$(compgen -S/ -d \$wrkdir/\$cur| cut -b \$len-) ); - }" - ALIAS="$aliasname () { cd \"$dirname/\$*\"; }" - eval $FUNC - eval $ALIAS - complete -o nospace -F $prgname $aliasname -} - -make_dir_complete dl ~/download/ -make_dir_complete jk ~/src/ -make_dir_complete h ~/etc/ diff --git a/source/nvm.sh b/source/nvm.sh deleted file mode 100755 index abd0a10..0000000 --- a/source/nvm.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -__load_nvm() { - local nvmdir="${HOME}/.nvm" - test ! -d ${nvmdir} && return 0 - . ${nvmdir}/nvm.sh -} - -__load_nvm diff --git a/source/onepiece.sh b/source/onepiece.sh deleted file mode 100755 index 3ded8d1..0000000 --- a/source/onepiece.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash - -__wm_check() { - if [ ! -d WATCHED ]; then - echo "You must create a ./WATCHED dir to use this command" >&2 - return 2 - fi - return 0 -} - -wm() { - video="${@}" - mplayer "${video}" - result=$? - if test $result -eq 0; then - mv "${video}" WATCHED/ - subfile="${video%.*}.srt" - test -f "${subfile}" && mv "${subfile}" WATCHED - fi -} - -wnext() { - __wm_check || return $? - local target="" - while read LINE; do - test -d "${LINE}" && continue - test ! -f "${LINE}" && continue - target=${LINE} - break - done < <(/bin/ls -1 !(*.srt|WATCHED)) - test -z "${target}" && return 1 - wm "${target}" -} - -wprev() { - __wm_check || return $? - local target="" - while read LINE; do - test -d "${LINE}" && continue - test ! -f "${LINE}" && continue - target=${LINE} - break - done < <(ls -1 WATCHED| egrep -v '.+\.srt'| tac| sed 's/^/WATCHED\//g') - test -z "${target}" && return 1 - mplayer "${target}" -} diff --git a/source/perlbrew.sh b/source/perlbrew.sh deleted file mode 100755 index 149a621..0000000 --- a/source/perlbrew.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -__load_perlbrew() { - local perlbrew_root="${HOME}/.perl5/perlbrew" - test ! -d ${perlbrew_root} && return 0 - export PERLBREW_ROOT=${perlbrew_root} - . ${PERLBREW_ROOT}/etc/bashrc - . ${PERLBREW_ROOT}/etc/perlbrew-completion.bash -} - -__load_perlbrew diff --git a/source/pip.sh b/source/pip.sh deleted file mode 100755 index ad3abb7..0000000 --- a/source/pip.sh +++ /dev/null @@ -1,11 +0,0 @@ - -# pip bash completion start -_pip_completion() -{ - COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \ - COMP_CWORD=$COMP_CWORD \ - PIP_AUTO_COMPLETE=1 $1 ) ) -} -complete -o default -F _pip_completion pip -# pip bash completion end - diff --git a/source/power.sh b/source/power.sh deleted file mode 100755 index b14dbba..0000000 --- a/source/power.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -_dbus_send() { - local cmd=${1} - local tmp=${1%.*} - local dest=${tmp/.Manager/} - local mgr="/${tmp//.//}" - dbus-send --system --print-reply --dest=${dest} ${mgr} ${cmd} -} - -power() { - case "$1" in - shutdown) - _dbus_send org.freedesktop.ConsoleKit.Manager.Stop - ;; - restart) - _dbus_send org.freedesktop.ConsoleKit.Manager.Restart - ;; - sleep) - _dbus_send org.freedesktop.UPower.Suspend - ;; - hibernate) - _dbus_send org.freedesktop.UPower.Hibernate - ;; - *) - return 1 - esac -} - -complete -W "shutdown${IFS}restart${IFS}sleep${IFS}hibernate" power diff --git a/source/pythonbrew.sh b/source/pythonbrew.sh deleted file mode 100755 index 161128b..0000000 --- a/source/pythonbrew.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -__load_pybrew() { - local pybrewinit="${HOME}/.pythonbrew/etc/bashrc" - test ! -r ${pybrewinit} && return 0 - . ${pybrewinit} -} - -__load_pybrew diff --git a/source/rvm.sh b/source/rvm.sh deleted file mode 100755 index 000aec9..0000000 --- a/source/rvm.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -__load_rvm() { - local rvm_load_path="${HOME}/.rvm" - test ! -d ${rvm_load_path} && return 0 - . ${rvm_load_path}/scripts/rvm - . ${rvm_load_path}/scripts/completion -} - -__load_rvm diff --git a/source/service.sh b/source/service.sh deleted file mode 100644 index 752ce5b..0000000 --- a/source/service.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -__services() { - local cur - local IFS=$'\n' - cur=${COMP_WORDS[COMP_CWORD]}; - - if [ $COMP_CWORD -eq 1 ]; then - COMPREPLY=( $(compgen -W "$(find /etc/rc.d -type f -printf '%P\n')" -- ${cur}) ) - elif [ $COMP_CWORD -eq 2 ]; then - COMPREPLY=( $(compgen -W "$(echo -e 'start\nstatus\nstop\nrestart')" -- ${cur}) ) - else - COMPREPLY=() - fi -} - -service() { - [ ${#} -ne 2 ] && return 1; - sudo /etc/rc.d/$1 $2 -} - -complete -F __services service diff --git a/source/task.sh b/source/task.sh deleted file mode 100755 index 9a1b7fb..0000000 --- a/source/task.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -__load_task() { - local taskrc="/usr/share/doc/task/scripts/bash/task_completion.sh" - test ! -f ${taskrc} && return 0 - . ${taskrc} -} diff --git a/source/telnets.sh b/source/telnets.sh deleted file mode 100755 index 039b834..0000000 --- a/source/telnets.sh +++ /dev/null @@ -1,5 +0,0 @@ -telnets() { - local host=$1 - local port=${2-443} - openssl s_client -quiet -connect $host:$port -} diff --git a/source/tmux.sh b/source/tmux.sh deleted file mode 100755 index 43bfd79..0000000 --- a/source/tmux.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# Force tmux to use 256 colors -test -n "$TMUX" && export TERM=screen-256color || true diff --git a/source/unpack.sh b/source/unpack.sh deleted file mode 100755 index 4dfe4cb..0000000 --- a/source/unpack.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash - -unpack() { - # Usage: unpack [-r] [extra_options] - # extra_options are filetype/extration-command -dependant - local remove_archive=0 - - if [ "$1" = "-r" ]; then - remove_archive=1 - shift - fi - - filename="$1" - shift - - if [ ! -f "$filename" ]; then - echo "File not found: $filename" 1>&2 - return 1 - fi - - options=${@} - - case "$filename" in - *.tar.bz2) - tar xvjf "$filename" $options;; - *.tar.gz) - tar xvzf "$filename" $options;; - *.tar.xz) - tar xvJf "$filename" $options;; - *.tar.lzma) - tar --lzma -xvf "$filename" $options;; - *.bz2) - bunzip $options "$filename";; - *.rar) - unrar x $options "$filename";; - *.gz) - gunzip $options "$filename";; - *.tar) - tar xvf "$filename" $options;; - *.tbz2) - tar xvjf "$filename" $options;; - *.tgz) - tar xvzf "$filename" $options;; - *.zip) - unzip "$filename" $options;; - *.Z) - uncompress $options "$filename";; - *.7z) - 7z x $options "$filename";; - *.rpm) - rpm2cpio "$filename" | cpio -ivd $options;; - *.deb) - ar vx "$filename";; - *) - echo "Unknown filetype: $filename" 1>&2 - return 1;; - esac - - local retcode=$? - - if [ $retcode -ne 0 ]; then - echo "Error extracting: $filename" 1>&2 - return $retcode - fi - - if [ $remove_archive -eq 1 ]; then - echo "Removing: $filename" - rm "$filename" - fi -} diff --git a/source/uumount.sh b/source/uumount.sh deleted file mode 100755 index 6d3ebbc..0000000 --- a/source/uumount.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -__umountables() { - local cur - local IFS=$'\n' - wrkdir='/media/' - cur=${COMP_WORDS[COMP_CWORD]}; - len=$((${#wrkdir} + 1)); - - if [ $COMP_CWORD -eq 1 ]; then - COMPREPLY=( $(compgen -d /media/${cur}| cut -b $len-) ) - else - COMPREPLY=() - fi -} - -uumount() { - [ ${#} -ne 1 ] && return 1; - udiskie-umount /media/${1} -} - -complete -F __umountables uumount - diff --git a/source/vcsinfo.sh b/source/vcsinfo.sh deleted file mode 100755 index a38cd92..0000000 --- a/source/vcsinfo.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/bash -# References -# * http://gist.github.com/31934 -# * http://glandium.org/blog/?p=170 - -__vcs_dir() { - local vcs base_dir sub_dir ref RED YELLOW GREEN BLUE - local LIGHT_RED LIGHT_GREEN WHITE LIGHT_GRAY COLOR_NONE - - RED="\[\033[0;31m\]" - YELLOW="\[\033[0;35m\]" - GREEN='\[\e[0;36m\]' - BLUE="\[\033[0;34m\]" - LIGHT_RED="\[\033[1;31m\]" - LIGHT_GREEN="\[\033[1;32m\]" - WHITE="\[\033[1;37m\]" - LIGHT_GRAY="\[\033[0;37m\]" - COLOR_NONE="\[\e[0m\]" - - sub_dir() { - local sub_dir - sub_dir=$(readlink -f "${PWD}") - sub_dir=${sub_dir#$1} - echo ${sub_dir#/} - } - - git_dir() { - - parse_git_branch() { - # Capture the output of the "git status" command. - git_status="$(git status --ignore-submodules 2> /dev/null)" - - # Set color based on clean/staged/dirty. - if [[ ${git_status} =~ "working directory clean" ]]; then - state="${GREEN}" - elif [[ ${git_status} =~ "Changes to be committed" ]]; then - state="${YELLOW}" - else - state="${RED}" - fi - - # Set arrow icon based on status against remote. - remote_pattern="# Your branch is (ahead of|behind)" - if [[ ${git_status} =~ ${remote_pattern} ]]; then - if [[ ${BASH_REMATCH[1]} == "ahead of" ]]; then - remote="↑" - else - remote="↓" - fi - fi - diverge_pattern="# Your branch and (.*) have diverged" - if [[ ${git_status} =~ ${diverge_pattern} ]]; then - remote="↕" - fi - - # Get the name of the branch. - branch_pattern="^# On branch ([^${IFS}]*)" - if [[ ${git_status} =~ ${branch_pattern} ]]; then - branch=${BASH_REMATCH[1]} - fi - - # Display the prompt. - echo "${state}${branch}${remote}${COLOR_NONE}" - } - base_dir=$(git rev-parse --git-dir 2>/dev/null) || return 1 - base_dir=$(readlink -f "$base_dir/..") - sub_dir=$(git rev-parse --show-prefix) - sub_dir=${sub_dir%/} - ref=$(parse_git_branch) - vcs="±" - } - - svn_dir() { - [ -d ".svn" ] && [ -d $(readlink .) ] || return 1 - base_dir="." - while [ -d "$base_dir/../.svn" ]; do base_dir="$base_dir/.."; done - base_dir=$(readlink -f "$base_dir") - sub_dir=$(sub_dir "${base_dir}") - ref=$(svn info "$base_dir" | awk '/^Revision/ { sub("[^0-9]*","",$0); print $0 }') - vcs="⚒" - } - - hg_dir() { - base_dir="." - while [ ! -d "$base_dir/.hg" ]; do base_dir="$base_dir/.."; b=$(readlink -f "${base_dir}"); [ "$b" = "/" ] && return 1; done - base_dir=$(readlink -f "$base_dir") - sub_dir=$(sub_dir "${base_dir}") - ref=$(hg_prompt_info) - [ "$ref" == "" ] && ref="${GREEN}default" - vcs="∇" - } - - hg_prompt_info() { - hg prompt --angle-brackets "${col_txtgrn}\ -${col_txtpur}@\ -${col_txtylw}< -${col_txtred}✉:>" 2>/dev/null - } - - git_dir || - svn_dir || - hg_dir || - base_dir="$PWD" - - __vcs_base_dir="${base_dir/$HOME/~}" - if [ -n "$vcs" ]; then - __vcs_prefix="$vcs" - __vcs_ref="$ref" - __vcs_sub_dir="${sub_dir}" - else - __vcs_prefix="" - __vcs_ref="" - __vcs_sub_dir="" - fi -} diff --git a/source/virtualenvwrapper.sh b/source/virtualenvwrapper.sh deleted file mode 100755 index 34d9d8b..0000000 --- a/source/virtualenvwrapper.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -__load_venvwrapper() { - local venvbase="${HOME}/.source/virtualenvwrapper" - test ! -d ${venvbase} && return 0 - export WORKON_HOME=${HOME}/.virtualenvs - export PIP_VIRTUALENV_BASE=$WORKON_HOME - mkdir -p $WORKON_HOME - pathappend ${venvbase} PYTHONPATH - . ${venvbase}/virtualenvwrapper.sh -} - -__load_venvwrapper diff --git a/source/virtualenvwrapper/virtualenvwrapper.sh b/source/virtualenvwrapper/virtualenvwrapper.sh deleted file mode 100644 index 867b9c9..0000000 --- a/source/virtualenvwrapper/virtualenvwrapper.sh +++ /dev/null @@ -1,956 +0,0 @@ -# -*- mode: shell-script -*- -# -# Shell functions to act as wrapper for Ian Bicking's virtualenv -# (http://pypi.python.org/pypi/virtualenv) -# -# -# Copyright Doug Hellmann, All Rights Reserved -# -# Permission to use, copy, modify, and distribute this software and its -# documentation for any purpose and without fee is hereby granted, -# provided that the above copyright notice appear in all copies and that -# both that copyright notice and this permission notice appear in -# supporting documentation, and that the name of Doug Hellmann not be used -# in advertising or publicity pertaining to distribution of the software -# without specific, written prior permission. -# -# DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -# EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR -# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. -# -# -# Project home page: http://www.doughellmann.com/projects/virtualenvwrapper/ -# -# -# Setup: -# -# 1. Create a directory to hold the virtual environments. -# (mkdir $HOME/.virtualenvs). -# 2. Add a line like "export WORKON_HOME=$HOME/.virtualenvs" -# to your .bashrc. -# 3. Add a line like "source /path/to/this/file/virtualenvwrapper.sh" -# to your .bashrc. -# 4. Run: source ~/.bashrc -# 5. Run: workon -# 6. A list of environments, empty, is printed. -# 7. Run: mkvirtualenv temp -# 8. Run: workon -# 9. This time, the "temp" environment is included. -# 10. Run: workon temp -# 11. The virtual environment is activated. -# - -# Locate the global Python where virtualenvwrapper is installed. -if [ "$VIRTUALENVWRAPPER_PYTHON" = "" ] -then - VIRTUALENVWRAPPER_PYTHON="$(\which python2)" -fi - -# Set the name of the virtualenv app to use. -if [ "$VIRTUALENVWRAPPER_VIRTUALENV" = "" ] -then - VIRTUALENVWRAPPER_VIRTUALENV="virtualenv2" -fi - -# Define script folder depending on the platorm (Win32/Unix) -VIRTUALENVWRAPPER_ENV_BIN_DIR="bin" -if [ "$OS" = "Windows_NT" ] && [ "$MSYSTEM" = "MINGW32" ] -then - # Only assign this for msys, cygwin use standard Unix paths - # and its own python installation - VIRTUALENVWRAPPER_ENV_BIN_DIR="Scripts" -fi - -function virtualenvwrapper_derive_workon_home { - typeset workon_home_dir="$WORKON_HOME" - - # Make sure there is a default value for WORKON_HOME. - # You can override this setting in your .bashrc. - if [ "$workon_home_dir" = "" ] - then - workon_home_dir="$HOME/.virtualenvs" - fi - - # If the path is relative, prefix it with $HOME - # (note: for compatibility) - if echo "$workon_home_dir" | (unset GREP_OPTIONS; \grep '^[^/~]' > /dev/null) - then - workon_home_dir="$HOME/$WORKON_HOME" - fi - - # Only call on Python to fix the path if it looks like the - # path might contain stuff to expand. - # (it might be possible to do this in shell, but I don't know a - # cross-shell-safe way of doing it -wolever) - if echo "$workon_home_dir" | (unset GREP_OPTIONS; \egrep '([\$~]|//)' >/dev/null) - then - # This will normalize the path by: - # - Removing extra slashes (e.g., when TMPDIR ends in a slash) - # - Expanding variables (e.g., $foo) - # - Converting ~s to complete paths (e.g., ~/ to /home/brian/ and ~arthur to /home/arthur) - workon_home_dir=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os; print os.path.expandvars(os.path.expanduser(\"$workon_home_dir\"))") - fi - - echo "$workon_home_dir" - return 0 -} - -# Check if the WORKON_HOME directory exists, -# create it if it does not -# seperate from creating the files in it because this used to just error -# and maybe other things rely on the dir existing before that happens. -function virtualenvwrapper_verify_workon_home { - RC=0 - if [ ! -d "$WORKON_HOME/" ] - then - if [ "$1" != "-q" ] - then - echo "NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." 1>&2 - fi - mkdir -p $WORKON_HOME - RC=$? - fi - return $RC -} - -#HOOK_VERBOSE_OPTION="-q" - -# Expects 1 argument, the suffix for the new file. -function virtualenvwrapper_tempfile { - # Note: the 'X's must come last - typeset suffix=${1:-hook} - typeset file="`\mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX`" - if [ $? -ne 0 ] - then - echo "ERROR: virtualenvwrapper could not create a temporary file name." 1>&2 - return 1 - fi - trap "\rm -f '$file' >/dev/null 2>&1" EXIT - echo $file - return 0 -} - -# Run the hooks -function virtualenvwrapper_run_hook { - typeset hook_script="$(virtualenvwrapper_tempfile ${1}-hook)" - if [ -z "$hook_script" ] - then - echo "ERROR: Could not create temporary file name. Make sure TMPDIR is set." 1>&2 - return 1 - fi - if [ -z "$VIRTUALENVWRAPPER_LOG_DIR" ] - then - echo "ERROR: VIRTUALENVWRAPPER_LOG_DIR is not set." 1>&2 - return 1 - fi - "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION --script "$hook_script" "$@" - result=$? - - if [ $result -eq 0 ] - then - if [ ! -f "$hook_script" ] - then - echo "ERROR: virtualenvwrapper_run_hook could not find temporary file $hook_script" 1>&2 - return 2 - fi - # cat "$hook_script" - source "$hook_script" - fi - \rm -f "$hook_script" >/dev/null 2>&1 - return $result -} - -# Set up tab completion. (Adapted from Arthur Koziel's version at -# http://arthurkoziel.com/2008/10/11/virtualenvwrapper-bash-completion/) -function virtualenvwrapper_setup_tab_completion { - if [ -n "$BASH" ] ; then - _virtualenvs () { - local cur="${COMP_WORDS[COMP_CWORD]}" - COMPREPLY=( $(compgen -W "`virtualenvwrapper_show_workon_options`" -- ${cur}) ) - } - _cdvirtualenv_complete () { - local cur="$2" - COMPREPLY=( $(cdvirtualenv && compgen -d -- "${cur}" ) ) - } - _cdsitepackages_complete () { - local cur="$2" - COMPREPLY=( $(cdsitepackages && compgen -d -- "${cur}" ) ) - } - complete -o nospace -F _cdvirtualenv_complete -S/ cdvirtualenv - complete -o nospace -F _cdsitepackages_complete -S/ cdsitepackages - complete -o default -o nospace -F _virtualenvs workon - complete -o default -o nospace -F _virtualenvs rmvirtualenv - complete -o default -o nospace -F _virtualenvs cpvirtualenv - complete -o default -o nospace -F _virtualenvs showvirtualenv - elif [ -n "$ZSH_VERSION" ] ; then - _virtualenvs () { - reply=( $(virtualenvwrapper_show_workon_options) ) - } - _cdvirtualenv_complete () { - reply=( $(cdvirtualenv && ls -d ${1}*) ) - } - _cdsitepackages_complete () { - reply=( $(cdsitepackages && ls -d ${1}*) ) - } - compctl -K _virtualenvs workon rmvirtualenv cpvirtualenv showvirtualenv - compctl -K _cdvirtualenv_complete cdvirtualenv - compctl -K _cdsitepackages_complete cdsitepackages - fi -} - -# Set up virtualenvwrapper properly -function virtualenvwrapper_initialize { - export WORKON_HOME="$(virtualenvwrapper_derive_workon_home)" - - virtualenvwrapper_verify_workon_home -q || return 1 - - # Set the location of the hook scripts - if [ "$VIRTUALENVWRAPPER_HOOK_DIR" = "" ] - then - export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME" - fi - - # Set the location of the hook script logs - if [ "$VIRTUALENVWRAPPER_LOG_DIR" = "" ] - then - export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME" - fi - - virtualenvwrapper_run_hook "initialize" - if [ $? -ne 0 ] - then - echo "virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON and that PATH is set properly." 1>&2 - return 1 - fi - - virtualenvwrapper_setup_tab_completion - -} - - -# Verify that virtualenv is installed and visible -function virtualenvwrapper_verify_virtualenv { - typeset venv=$(\which "$VIRTUALENVWRAPPER_VIRTUALENV" | (unset GREP_OPTIONS; \grep -v "not found")) - if [ "$venv" = "" ] - then - echo "ERROR: virtualenvwrapper could not find $VIRTUALENVWRAPPER_VIRTUALENV in your path" >&2 - return 1 - fi - if [ ! -e "$venv" ] - then - echo "ERROR: Found $VIRTUALENVWRAPPER_VIRTUALENV in path as \"$venv\" but that does not exist" >&2 - return 1 - fi - return 0 -} - -# Verify that the requested environment exists -function virtualenvwrapper_verify_workon_environment { - typeset env_name="$1" - if [ ! -d "$WORKON_HOME/$env_name" ] - then - echo "ERROR: Environment '$env_name' does not exist. Create it with 'mkvirtualenv $env_name'." >&2 - return 1 - fi - return 0 -} - -# Verify that the active environment exists -function virtualenvwrapper_verify_active_environment { - if [ ! -n "${VIRTUAL_ENV}" ] || [ ! -d "${VIRTUAL_ENV}" ] - then - echo "ERROR: no virtualenv active, or active virtualenv is missing" >&2 - return 1 - fi - return 0 -} - -# Help text for mkvirtualenv -function mkvirtualenv_help { - echo "Usage: mkvirtualenv [-i package] [-r requirements_file] [virtualenv options] env_name" - echo - echo " -i package" - echo - echo " Install a package after the environment is created." - echo " This option may be repeated." - echo - echo " -r requirements_file" - echo - echo " Provide a pip requirements file to install a base set of packages" - echo " into the new environment." - echo; - echo 'virtualenv help:'; - echo; - virtualenv -h; -} - -# Create a new environment, in the WORKON_HOME. -# -# Usage: mkvirtualenv [options] ENVNAME -# (where the options are passed directly to virtualenv) -# -function mkvirtualenv { - typeset -a in_args - typeset -a out_args - typeset -i i - typeset tst - typeset a - typeset envname - typeset requirements - typeset packages - - in_args=( "$@" ) - - if [ -n "$ZSH_VERSION" ] - then - i=1 - tst="-le" - else - i=0 - tst="-lt" - fi - while [ $i $tst $# ] - do - a="${in_args[$i]}" - # echo "arg $i : $a" - case "$a" in - -h) - mkvirtualenv_help; - return;; - -i) - i=$(( $i + 1 )); - packages="$packages ${in_args[$i]}";; - -r) - i=$(( $i + 1 )); - requirements="${in_args[$i]}";; - *) - if [ ${#out_args} -gt 0 ] - then - out_args=( "${out_args[@]-}" "$a" ) - else - out_args=( "$a" ) - fi;; - esac - i=$(( $i + 1 )) - done - - set -- "${out_args[@]}" - - eval "envname=\$$#" - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_virtualenv || return 1 - ( - [ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT - \cd "$WORKON_HOME" && - "$VIRTUALENVWRAPPER_VIRTUALENV" $VIRTUALENVWRAPPER_VIRTUALENV_ARGS "$@" && - [ -d "$WORKON_HOME/$envname" ] && \ - virtualenvwrapper_run_hook "pre_mkvirtualenv" "$envname" - ) - typeset RC=$? - [ $RC -ne 0 ] && return $RC - - # If they passed a help option or got an error from virtualenv, - # the environment won't exist. Use that to tell whether - # we should switch to the environment and run the hook. - [ ! -d "$WORKON_HOME/$envname" ] && return 0 - # Now activate the new environment - workon "$envname" - - if [ ! -z "$requirements" ] - then - pip install -r "$requirements" - fi - - for a in $packages - do - pip install $a - done - - virtualenvwrapper_run_hook "post_mkvirtualenv" -} - -# Remove an environment, in the WORKON_HOME. -function rmvirtualenv { - typeset env_name="$1" - virtualenvwrapper_verify_workon_home || return 1 - if [ "$env_name" = "" ] - then - echo "Please specify an enviroment." >&2 - return 1 - fi - env_dir="$WORKON_HOME/$env_name" - if [ "$VIRTUAL_ENV" = "$env_dir" ] - then - echo "ERROR: You cannot remove the active environment ('$env_name')." >&2 - echo "Either switch to another environment, or run 'deactivate'." >&2 - return 1 - fi - - # Move out of the current directory to one known to be - # safe, in case we are inside the environment somewhere. - typeset prior_dir="$(pwd)" - \cd "$WORKON_HOME" - - virtualenvwrapper_run_hook "pre_rmvirtualenv" "$env_name" - \rm -rf "$env_dir" - virtualenvwrapper_run_hook "post_rmvirtualenv" "$env_name" - - # If the directory we used to be in still exists, move back to it. - if [ -d "$prior_dir" ] - then - \cd "$prior_dir" - fi -} - -# List the available environments. -function virtualenvwrapper_show_workon_options { - virtualenvwrapper_verify_workon_home || return 1 - # NOTE: DO NOT use ls here because colorized versions spew control characters - # into the output list. - # echo seems a little faster than find, even with -depth 3. - (\cd "$WORKON_HOME"; for f in */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate; do echo $f; done) 2>/dev/null | \sed 's|^\./||' | \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate||" | \sort | (unset GREP_OPTIONS; \egrep -v '^\*$') - -# (\cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort -} - -function _lsvirtualenv_usage { - echo "lsvirtualenv [-blh]" - echo " -b -- brief mode" - echo " -l -- long mode" - echo " -h -- this help message" -} - -# List virtual environments -# -# Usage: lsvirtualenv [-l] -function lsvirtualenv { - - typeset long_mode=true - if command -v "getopts" &> /dev/null - then - # Use getopts when possible - OPTIND=1 - while getopts ":blh" opt "$@" - do - case "$opt" in - l) long_mode=true;; - b) long_mode=false;; - h) _lsvirtualenv_usage; - return 1;; - ?) echo "Invalid option: -$OPTARG" >&2; - _lsvirtualenv_usage; - return 1;; - esac - done - else - # fallback on getopt for other shell - typeset -a args - args=($(getopt blh "$@")) - if [ $? != 0 ] - then - _lsvirtualenv_usage - return 1 - fi - for opt in $args - do - case "$opt" in - -l) long_mode=true;; - -b) long_mode=false;; - -h) _lsvirtualenv_usage; - return 1;; - esac - done - fi - - if $long_mode - then - for env_name in $(virtualenvwrapper_show_workon_options) - do - showvirtualenv "$env_name" - done - else - virtualenvwrapper_show_workon_options - fi -} - -# Show details of a virtualenv -# -# Usage: showvirtualenv [env] -function showvirtualenv { - typeset env_name="$1" - if [ -z "$env_name" ] - then - if [ -z "$VIRTUAL_ENV" ] - then - echo "showvirtualenv [env]" - return 1 - fi - env_name=$(basename $VIRTUAL_ENV) - fi - - echo -n "$env_name" - virtualenvwrapper_run_hook "get_env_details" "$env_name" - echo -} - -# List or change working virtual environments -# -# Usage: workon [environment_name] -# -function workon { - typeset env_name="$1" - if [ "$env_name" = "" ] - then - lsvirtualenv -b - return 1 - fi - - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_workon_environment $env_name || return 1 - - activate="$WORKON_HOME/$env_name/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate" - if [ ! -f "$activate" ] - then - echo "ERROR: Environment '$WORKON_HOME/$env_name' does not contain an activate script." >&2 - return 1 - fi - - # Deactivate any current environment "destructively" - # before switching so we use our override function, - # if it exists. - type deactivate >/dev/null 2>&1 - if [ $? -eq 0 ] - then - deactivate - unset -f deactivate >/dev/null 2>&1 - fi - - virtualenvwrapper_run_hook "pre_activate" "$env_name" - - source "$activate" - - # Save the deactivate function from virtualenv under a different name - virtualenvwrapper_original_deactivate=`typeset -f deactivate | sed 's/deactivate/virtualenv_deactivate/g'` - eval "$virtualenvwrapper_original_deactivate" - unset -f deactivate >/dev/null 2>&1 - - # Replace the deactivate() function with a wrapper. - eval 'deactivate () { - - # Call the local hook before the global so we can undo - # any settings made by the local postactivate first. - virtualenvwrapper_run_hook "pre_deactivate" - - env_postdeactivate_hook="$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postdeactivate" - old_env=$(basename "$VIRTUAL_ENV") - - # Call the original function. - virtualenv_deactivate $1 - - virtualenvwrapper_run_hook "post_deactivate" "$old_env" - - if [ ! "$1" = "nondestructive" ] - then - # Remove this function - unset -f virtualenv_deactivate >/dev/null 2>&1 - unset -f deactivate >/dev/null 2>&1 - fi - - }' - - virtualenvwrapper_run_hook "post_activate" - - return 0 -} - - -# Prints the Python version string for the current interpreter. -function virtualenvwrapper_get_python_version { - # Uses the Python from the virtualenv because we're trying to - # determine the version installed there so we can build - # up the path to the site-packages directory. - python -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d. -} - -# Prints the path to the site-packages directory for the current environment. -function virtualenvwrapper_get_site_packages_dir { - echo "$VIRTUAL_ENV/lib/python`virtualenvwrapper_get_python_version`/site-packages" -} - -# Path management for packages outside of the virtual env. -# Based on a contribution from James Bennett and Jannis Leidel. -# -# add2virtualenv directory1 directory2 ... -# -# Adds the specified directories to the Python path for the -# currently-active virtualenv. This will be done by placing the -# directory names in a path file named -# "virtualenv_path_extensions.pth" inside the virtualenv's -# site-packages directory; if this file does not exist, it will be -# created first. -function add2virtualenv { - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_active_environment || return 1 - - site_packages="`virtualenvwrapper_get_site_packages_dir`" - - if [ ! -d "${site_packages}" ] - then - echo "ERROR: currently-active virtualenv does not appear to have a site-packages directory" >&2 - return 1 - fi - - # Prefix with _ to ensure we are loaded as early as possible, - # and at least before easy_install.pth. - path_file="$site_packages/_virtualenv_path_extensions.pth" - - if [ "$*" = "" ] - then - echo "Usage: add2virtualenv dir [dir ...]" - if [ -f "$path_file" ] - then - echo - echo "Existing paths:" - cat "$path_file" | grep -v "^import" - fi - return 1 - fi - - remove=0 - if [ "$1" = "-d" ] - then - remove=1 - shift - fi - - if [ ! -f "$path_file" ] - then - echo "import sys; sys.__plen = len(sys.path)" >> "$path_file" - echo "import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)" >> "$path_file" - fi - - for pydir in "$@" - do - absolute_path=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os; print os.path.abspath(\"$pydir\")") - if [ "$absolute_path" != "$pydir" ] - then - echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2 - fi - - if [ $remove -eq 1 ] - then - sed -i.tmp "\:^$absolute_path$: d" "$path_file" - else - sed -i.tmp '1 a\ -'$absolute_path' -' "$path_file" - fi - rm -f "${path_file}.tmp" - done - return 0 -} - -# Does a ``cd`` to the site-packages directory of the currently-active -# virtualenv. -function cdsitepackages { - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_active_environment || return 1 - typeset site_packages="`virtualenvwrapper_get_site_packages_dir`" - \cd "$site_packages"/$1 -} - -# Does a ``cd`` to the root of the currently-active virtualenv. -function cdvirtualenv { - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_active_environment || return 1 - \cd $VIRTUAL_ENV/$1 -} - -# Shows the content of the site-packages directory of the currently-active -# virtualenv -function lssitepackages { - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_active_environment || return 1 - typeset site_packages="`virtualenvwrapper_get_site_packages_dir`" - ls $@ $site_packages - - path_file="$site_packages/_virtualenv_path_extensions.pth" - if [ -f "$path_file" ] - then - echo - echo "_virtualenv_path_extensions.pth:" - cat "$path_file" - fi -} - -# Toggles the currently-active virtualenv between having and not having -# access to the global site-packages. -function toggleglobalsitepackages { - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_active_environment || return 1 - typeset no_global_site_packages_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" - if [ -f $no_global_site_packages_file ]; then - rm $no_global_site_packages_file - [ "$1" = "-q" ] || echo "Enabled global site-packages" - else - touch $no_global_site_packages_file - [ "$1" = "-q" ] || echo "Disabled global site-packages" - fi -} - -# Duplicate the named virtualenv to make a new one. -function cpvirtualenv { - typeset env_name="$1" - if [ "$env_name" = "" ] - then - virtualenvwrapper_show_workon_options - return 1 - fi - typeset new_env="$2" - if [ "$new_env" = "" ] - then - echo "Please specify target virtualenv" - return 1 - fi - if echo "$WORKON_HOME" | (unset GREP_OPTIONS; \grep "/$" > /dev/null) - then - typeset env_home="$WORKON_HOME" - else - typeset env_home="$WORKON_HOME/" - fi - typeset source_env="$env_home$env_name" - typeset target_env="$env_home$new_env" - - if [ ! -e "$source_env" ] - then - echo "$env_name virtualenv doesn't exist" - return 1 - fi - - \cp -r "$source_env" "$target_env" - for script in $( \ls $target_env/$VIRTUALENVWRAPPER_ENV_BIN_DIR/* ) - do - newscript="$script-new" - \sed "s|$source_env|$target_env|g" < "$script" > "$newscript" - \mv "$newscript" "$script" - \chmod a+x "$script" - done - - "$VIRTUALENVWRAPPER_VIRTUALENV" "$target_env" --relocatable - \sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate" > "$target_env/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate" - - (\cd "$WORKON_HOME" && ( - virtualenvwrapper_run_hook "pre_cpvirtualenv" "$env_name" "$new_env"; - virtualenvwrapper_run_hook "pre_mkvirtualenv" "$new_env" - )) - workon "$new_env" - virtualenvwrapper_run_hook "post_mkvirtualenv" - virtualenvwrapper_run_hook "post_cpvirtualenv" -} - -# -# virtualenvwrapper project functions -# - -# Verify that the PROJECT_HOME directory exists -function virtualenvwrapper_verify_project_home { - if [ -z "$PROJECT_HOME" ] - then - echo "ERROR: Set the PROJECT_HOME shell variable to the name of the directory where projects should be created." >&2 - return 1 - fi - if [ ! -d "$PROJECT_HOME" ] - then - [ "$1" != "-q" ] && echo "ERROR: Project directory '$PROJECT_HOME' does not exist. Create it or set PROJECT_HOME to an existing directory." >&2 - return 1 - fi - return 0 -} - -# Given a virtualenv directory and a project directory, -# set the virtualenv up to be associated with the -# project -function setvirtualenvproject { - typeset venv="$1" - typeset prj="$2" - if [ -z "$venv" ] - then - venv="$VIRTUAL_ENV" - fi - if [ -z "$prj" ] - then - prj="$(pwd)" - fi - echo "Setting project for $(basename $venv) to $prj" - echo "$prj" > "$venv/.project" -} - -# Show help for mkproject -function mkproject_help { - echo "Usage: mkproject [-t template] [virtualenv options] project_name" - echo "" - echo "Multiple templates may be selected. They are applied in the order" - echo "specified on the command line." - echo; - echo "mkvirtualenv help:" - echo - mkvirtualenv -h; - echo - echo "Available project templates:" - echo - "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' -l project.template -} - -# Create a new project directory and its associated virtualenv. -function mkproject { - typeset -a in_args - typeset -a out_args - typeset -i i - typeset tst - typeset a - typeset t - typeset templates - - in_args=( "$@" ) - - if [ -n "$ZSH_VERSION" ] - then - i=1 - tst="-le" - else - i=0 - tst="-lt" - fi - while [ $i $tst $# ] - do - a="${in_args[$i]}" - # echo "arg $i : $a" - case "$a" in - -h) - mkproject_help; - return;; - -t) - i=$(( $i + 1 )); - templates="$templates ${in_args[$i]}";; - *) - if [ ${#out_args} -gt 0 ] - then - out_args=( "${out_args[@]-}" "$a" ) - else - out_args=( "$a" ) - fi;; - esac - i=$(( $i + 1 )) - done - - set -- "${out_args[@]}" - - # echo "templates $templates" - # echo "remainder $@" - # return 0 - - eval "typeset envname=\$$#" - virtualenvwrapper_verify_project_home || return 1 - - if [ -d "$PROJECT_HOME/$envname" ] - then - echo "Project $envname already exists." >&2 - return 1 - fi - - mkvirtualenv "$@" || return 1 - - cd "$PROJECT_HOME" - - virtualenvwrapper_run_hook project.pre_mkproject $envname - - echo "Creating $PROJECT_HOME/$envname" - mkdir -p "$PROJECT_HOME/$envname" - setvirtualenvproject "$VIRTUAL_ENV" "$PROJECT_HOME/$envname" - - cd "$PROJECT_HOME/$envname" - - for t in $templates - do - echo - echo "Applying template $t" - # For some reason zsh insists on prefixing the template - # names with a space, so strip them out before passing - # the value to the hook loader. - virtualenvwrapper_run_hook --name $(echo $t | sed 's/^ //') project.template $envname - done - - virtualenvwrapper_run_hook project.post_mkproject -} - -# Change directory to the active project -function cdproject { - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_active_environment || return 1 - if [ -f "$VIRTUAL_ENV/.project" ] - then - project_dir=$(cat "$VIRTUAL_ENV/.project") - if [ ! -z "$project_dir" ] - then - cd "$project_dir" - else - echo "Project directory $project_dir does not exist" 1>&2 - return 1 - fi - else - echo "No project set in $VIRTUAL_ENV/.project" 1>&2 - return 1 - fi - return 0 -} - -# -# Temporary virtualenv -# -# Originally part of virtualenvwrapper.tmpenv plugin -# -mktmpenv() { - typeset tmpenvname - typeset RC - - # Generate a unique temporary name - tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import uuid; print uuid.uuid4()' 2>/dev/null) - if [ -z "$tmpenvname" ] - then - # This python does not support uuid - tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import random; print hex(random.getrandbits(64))[2:-1]' 2>/dev/null) - fi - - # Create the environment - mkvirtualenv "$@" "$tmpenvname" - RC=$? - if [ $RC -ne 0 ] - then - return $RC - fi - - # Change working directory - cdvirtualenv - - # Create the tmpenv marker file - echo "This is a temporary environment. It will be deleted when you run 'deactivate'." | tee "$VIRTUAL_ENV/README.tmpenv" - - # Update the postdeactivate script - cat - >> "$VIRTUAL_ENV/bin/postdeactivate" <', - dest='script_filename', - default=None, - ) - parser.add_option('-s', '--source', - help='Print the shell commands to be run in the current shell', - action='store_true', - dest='sourcing', - default=False, - ) - parser.add_option('-l', '--list', - help='Print a list of the plugins available for the given hook', - action='store_true', - default=False, - dest='listing', - ) - parser.add_option('-v', '--verbose', - help='Show more information on the console', - action='store_const', - const=2, - default=1, - dest='verbose_level', - ) - parser.add_option('-q', '--quiet', - help='Show less information on the console', - action='store_const', - const=0, - dest='verbose_level', - ) - parser.add_option('-n', '--name', - help='Only run the hook from the named plugin', - action='append', - dest='names', - default=[], - ) - parser.disable_interspersed_args() # stop when we hit an option without an '-' - options, args = parser.parse_args() - - root_logger = logging.getLogger('') - - # Set up logging to a file - root_logger.setLevel(logging.DEBUG) - file_handler = logging.handlers.RotatingFileHandler( - os.path.expandvars(os.path.join('$VIRTUALENVWRAPPER_LOG_DIR', 'hook.log')), - maxBytes=10240, - backupCount=1, - ) - formatter = logging.Formatter('%(asctime)s %(levelname)s %(name)s %(message)s') - file_handler.setFormatter(formatter) - root_logger.addHandler(file_handler) - - # Send higher-level messages to the console, too - console = logging.StreamHandler() - console_level = [ logging.WARNING, - logging.INFO, - logging.DEBUG, - ][options.verbose_level] - console.setLevel(console_level) - formatter = logging.Formatter('%(name)s %(message)s') - console.setFormatter(formatter) - root_logger.addHandler(console) - - #logging.getLogger(__name__).debug('cli args %s', args) - - # Determine which hook we're running - if not args: - parser.error('Please specify the hook to run') - hook = args[0] - - if options.sourcing and options.script_filename: - parser.error('--source and --script are mutually exclusive.') - - if options.sourcing: - hook += '_source' - - log = logging.getLogger(__name__) - - log.debug('Running %s hooks', hook) - run_hooks(hook, options, args) - - if options.script_filename: - log.debug('Saving sourcable %s hooks to %s', hook, options.script_filename) - options.sourcing = True - output = open(options.script_filename, "w") - try: - output.write('# %s\n' % hook) - run_hooks(hook + '_source', options, args, output) - finally: - output.close() - - return 0 - -def run_hooks(hook, options, args, output=None): - if output is None: - output = sys.stdout - - for ep in pkg_resources.iter_entry_points('virtualenvwrapper.%s' % hook): - if options.names and ep.name not in options.names: - continue - plugin = ep.load() - if options.listing: - print ' %-10s -- %s' % (ep.name, inspect.getdoc(plugin) or '') - continue - if options.sourcing: - # Show the shell commands so they can - # be run in the calling shell. - contents = (plugin(args[1:]) or '').strip() - if contents: - output.write('# %s\n' % ep.name) - output.write(contents) - output.write("\n") - else: - # Just run the plugin ourselves - plugin(args[1:]) - -if __name__ == '__main__': - main() diff --git a/source/virtualenvwrapper/virtualenvwrapper/project.py b/source/virtualenvwrapper/virtualenvwrapper/project.py deleted file mode 100644 index fb47f8b..0000000 --- a/source/virtualenvwrapper/virtualenvwrapper/project.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python -# encoding: utf-8 -# -# Copyright (c) 2010 Doug Hellmann. All rights reserved. -# -"""virtualenvwrapper.project -""" - -import logging -import os - -import pkg_resources - -from virtualenvwrapper.user_scripts import make_hook, run_global - -log = logging.getLogger(__name__) - -GLOBAL_HOOKS = [ - # mkproject - ("premkproject", - "This hook is run after a new project is created and before it is activated."), - ("postmkproject", - "This hook is run after a new project is activated."), - - # rmproject - ("prermproject", - "This hook is run before a project is deleted."), - ("postrmproject", - "This hook is run after a project is deleted."), - ] - -def initialize(args): - """Set up user hooks - """ - for filename, comment in GLOBAL_HOOKS: - make_hook(os.path.join('$VIRTUALENVWRAPPER_HOOK_DIR', filename), comment) - return - - -def pre_mkproject(args): - log.debug('pre_mkproject %s', str(args)) - envname=args[0] - run_global('premkproject', *args) - return - -def post_mkproject_source(args): - return """ -# -# Run user-provided scripts -# -[ -f "$WORKON_HOME/postmkproject" ] && source "$WORKON_HOME/postmkproject" -""" - -def post_activate_source(args): - return """ -# -# Change to the project directory -# -[ -f "$VIRTUAL_ENV/.project" ] && cd "$(cat \"$VIRTUAL_ENV/.project\")" -""" diff --git a/source/virtualenvwrapper/virtualenvwrapper/user_scripts.py b/source/virtualenvwrapper/virtualenvwrapper/user_scripts.py deleted file mode 100644 index 44d9016..0000000 --- a/source/virtualenvwrapper/virtualenvwrapper/user_scripts.py +++ /dev/null @@ -1,261 +0,0 @@ -#!/usr/bin/env python -# encoding: utf-8 -# -# Copyright (c) 2010 Doug Hellmann. All rights reserved. -# -"""Plugin to handle hooks in user-defined scripts. -""" - -import logging -import os -import re -import stat -import subprocess -import sys - -import pkg_resources - -log = logging.getLogger(__name__) - - -# Are we running under msys -if sys.platform == 'win32' and os.environ.get('OS') == 'Windows_NT' and os.environ.get('MSYSTEM') == 'MINGW32': - is_msys = True - script_folder = 'Scripts' -else: - is_msys = False - script_folder = 'bin' - - -def run_script(script_path, *args): - """Execute a script in a subshell. - """ - if os.path.exists(script_path): - cmd = [script_path] + list(args) - if is_msys: - cmd = [get_path(os.environ['MSYS_HOME'],'bin','sh.exe')] + cmd - log.debug('running %s', str(cmd)) - try: - return_code = subprocess.call(cmd) - except OSError, msg: - log.error('could not run "%s": %s', script_path, str(msg)) - #log.debug('Returned %s', return_code) - return - - -def run_global(script_name, *args): - """Run a script from $VIRTUALENVWRAPPER_HOOK_DIR. - """ - script_path = get_path('$VIRTUALENVWRAPPER_HOOK_DIR', script_name) - run_script(script_path, *args) - return - - -PERMISSIONS = stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH | stat.S_IXOTH - - -GLOBAL_HOOKS = [ - # initialize - ("initialize", - "This hook is run during the startup phase when loading virtualenvwrapper.sh."), - - # mkvirtualenv - ("premkvirtualenv", - "This hook is run after a new virtualenv is created and before it is activated."), - ("postmkvirtualenv", - "This hook is run after a new virtualenv is activated."), - - # rmvirtualenv - ("prermvirtualenv", - "This hook is run before a virtualenv is deleted."), - ("postrmvirtualenv", - "This hook is run after a virtualenv is deleted."), - - # deactivate - ("predeactivate", - "This hook is run before every virtualenv is deactivated."), - ("postdeactivate", - "This hook is run after every virtualenv is deactivated."), - - # activate - ("preactivate", - "This hook is run before every virtualenv is activated."), - ("postactivate", - "This hook is run after every virtualenv is activated."), - - # get_env_details - ("get_env_details", - "This hook is run when the list of virtualenvs is printed so each name can include details."), - ] - - -LOCAL_HOOKS = [ - # deactivate - ("predeactivate", - "This hook is run before this virtualenv is deactivated."), - ("postdeactivate", - "This hook is run after this virtualenv is deactivated."), - - # activate - ("preactivate", - "This hook is run before this virtualenv is activated."), - ("postactivate", - "This hook is run after this virtualenv is activated."), - - # get_env_details - ("get_env_details", - "This hook is run when the list of virtualenvs is printed in 'long' mode so each name can include details."), - ] - - -def make_hook(filename, comment): - """Create a hook script. - - :param filename: The name of the file to write. - :param comment: The comment to insert into the file. - """ - filename = get_path(filename) - if not os.path.exists(filename): - log.info('creating %s', filename) - f = open(filename, 'w') - try: - f.write("""#!%(shell)s -# %(comment)s - -""" % {'comment':comment, 'shell':os.environ.get('SHELL', '/bin/sh')}) - finally: - f.close() - os.chmod(filename, PERMISSIONS) - return - - - -# HOOKS - - -def initialize(args): - for filename, comment in GLOBAL_HOOKS: - make_hook(get_path('$VIRTUALENVWRAPPER_HOOK_DIR', filename), comment) - return - - -def initialize_source(args): - return """ -# -# Run user-provided scripts -# -[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/initialize" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/initialize" -""" - -def pre_mkvirtualenv(args): - log.debug('pre_mkvirtualenv %s', str(args)) - envname=args[0] - for filename, comment in LOCAL_HOOKS: - make_hook(get_path('$WORKON_HOME', envname, script_folder, filename), comment) - run_global('premkvirtualenv', *args) - return - - -def post_mkvirtualenv_source(args): - return """ -# -# Run user-provided scripts -# -[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postmkvirtualenv" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/postmkvirtualenv" -""" - -def pre_cpvirtualenv(args): - log.debug('pre_cpvirtualenv %s', str(args)) - envname=args[0] - for filename, comment in LOCAL_HOOKS: - make_hook(get_path('$WORKON_HOME', envname, script_folder, filename), comment) - run_global('precpvirtualenv', *args) - return - - -def post_cpvirtualenv_source(args): - return """ -# -# Run user-provided scripts -# -[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postcpvirtualenv" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/postcpvirtualenv" -""" - - -def pre_rmvirtualenv(args): - log.debug('pre_rmvirtualenv') - run_global('prermvirtualenv', *args) - return - - -def post_rmvirtualenv(args): - log.debug('post_rmvirtualenv') - run_global('postrmvirtualenv', *args) - return - - -def pre_activate(args): - log.debug('pre_activate') - run_global('preactivate', *args) - script_path = get_path('$WORKON_HOME', args[0], script_folder, 'preactivate') - run_script(script_path, *args) - return - - -def post_activate_source(args): - log.debug('post_activate') - return """ -# -# Run user-provided scripts -# -[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postactivate" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/postactivate" -[ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postactivate" ] && source "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postactivate" -""" - - -def pre_deactivate_source(args): - log.debug('pre_deactivate') - return """ -# -# Run user-provided scripts -# -[ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/predeactivate" ] && source "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/predeactivate" -[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/predeactivate" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/predeactivate" -""" - - -def post_deactivate_source(args): - log.debug('post_deactivate') - return """ -# -# Run user-provided scripts -# -VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV="$WORKON_HOME/%(env_name)s" -[ -f "$WORKON_HOME/%(env_name)s/bin/postdeactivate" ] && source "$WORKON_HOME/%(env_name)s/bin/postdeactivate" -[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postdeactivate" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/postdeactivate" -unset VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV -""" % { 'env_name':args[0] } - - -def get_env_details(args): - log.debug('get_env_details') - run_global('get_env_details', *args) - script_path = get_path('$WORKON_HOME', args[0], script_folder, 'get_env_details') - run_script(script_path, *args) - return - -def get_path(*args): - ''' - Get a full path from args. - Path separator is determined according to the os and the shell and allow to use is_msys. - Variables and user are expanded during the process. - ''' - path = os.path.expanduser(os.path.expandvars(os.path.join(*args))) - if is_msys: - # MSYS accept unix or Win32 and sometimes it drives to mixed style paths - if re.match(r'^/[a-zA-Z](/|^)', path): - # msys path could starts with '/c/'-form drive letter - path = ''.join((path[1],':',path[2:])) - path = path.replace('/', os.sep) - - return os.path.abspath(path)