-
-
Save dw/81f9b8cc0d957c41a7b2f6dc85b53358 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
note () | |
{ | |
local note_path base; | |
if test -z "$1"; then | |
base="$(basename "$(pwd)")"; | |
else | |
base="$1"; | |
fi; | |
local note_path="${HOME}/link/$base"; | |
if [ ! -d "${HOME}/link" ]; then | |
mkdir "${HOME}/link"; | |
fi; | |
if [ -e "${note_path}" ]; then | |
echo "Error: already exists: ${note_path}" 1>&2; | |
return 1; | |
else | |
( set -e; | |
command cd -P .; | |
ln -vs "`pwd`" "${note_path}" ); | |
fi | |
} | |
cd () | |
{ | |
if [ "$1" = . -o "$1" = .. -o "$1" = "" ]; then | |
command cd "$@" || return 1; | |
else | |
if [ ! -e "$1" -a -d "${HOME}/link/$1" ]; then | |
command cd -P "${HOME}/link/$1" || return 1; | |
pwd; | |
else | |
command cd "$@" || return 1; | |
fi; | |
fi; | |
deactivate; | |
local p="$(pwd)"; | |
while ! [ -d "$p/dev" ]; do | |
if [ -d "$p/.venv" ]; then | |
VIRTUAL_ENV="$(command cd -P "$p"/.venv; pwd)"; | |
PATH="$VIRTUAL_ENV/bin:$PATH"; | |
break; | |
fi; | |
p="$p/.."; | |
done | |
} | |
f () | |
{ | |
local pat="$1"; | |
shift; | |
find . -name "*$pat*" -and ! -path "*.svn*" -and ! -path "*.hg*" -and ! -path "*/.git" -and ! -path "*.git/*" -and ! -path "*.py[co]" "$@" | |
} | |
vf () | |
{ | |
vim $(f "$1" | grep -v \\.swp | grep -v \\.swo ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment