From d494d318ceedcfc18c81440eb29bd681084ff65c Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 1 Jul 2014 22:52:29 +0200 Subject: Rename .zsh --- zsh/functions/add-to-list | 10 ++++++++++ zsh/functions/emacs-backward-kill-word | 3 +++ zsh/functions/env | 3 +++ zsh/functions/venv | 15 +++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 zsh/functions/add-to-list create mode 100644 zsh/functions/emacs-backward-kill-word create mode 100644 zsh/functions/env create mode 100644 zsh/functions/venv (limited to 'zsh/functions') diff --git a/zsh/functions/add-to-list b/zsh/functions/add-to-list new file mode 100644 index 0000000..18720e0 --- /dev/null +++ b/zsh/functions/add-to-list @@ -0,0 +1,10 @@ +# -*- mode: sh; -*- +if [[ ! "${(P)${1}}" =~ (^|:)"$2"(:|$) ]]; then + if [ -n "$3" ]; then + # Append + typeset -g $1="${(P)${1}}:$2" + else + # Prepend + typeset -g $1="$2:${(P)${1}}" + fi +fi diff --git a/zsh/functions/emacs-backward-kill-word b/zsh/functions/emacs-backward-kill-word new file mode 100644 index 0000000..8453454 --- /dev/null +++ b/zsh/functions/emacs-backward-kill-word @@ -0,0 +1,3 @@ +# -*- mode: sh; -*- +local WORDCHARS="${WORDCHARS:s#/#}" +zle backward-delete-word diff --git a/zsh/functions/env b/zsh/functions/env new file mode 100644 index 0000000..a79fd5d --- /dev/null +++ b/zsh/functions/env @@ -0,0 +1,3 @@ +# -*- mode: shell-script -*- + +/usr/bin/env "$@" | grep -v \^LESS_TERMCAP_ diff --git a/zsh/functions/venv b/zsh/functions/venv new file mode 100644 index 0000000..03ec83d --- /dev/null +++ b/zsh/functions/venv @@ -0,0 +1,15 @@ +# -*- mode: sh; -*- +if [ "${#}" -eq 1 ]; then + local venv_activate="$HOME/.virtualenv/$1/bin/activate" + + if [ -r "$venv_activate" ]; then + source $venv_activate + else + echo "$1 is not a know virtual environment" + fi +else + echo "Virtual environments: " + for itm in ~/.virtualenv/*; do + echo " $(basename $itm)" + done +fi -- cgit v1.2.3-54-g00ecf