Add project manager module

This commit is contained in:
crater2150 2017-10-23 10:28:55 +02:00
parent 5cdd11b655
commit 4ceed76221
3 changed files with 65 additions and 12 deletions

View file

@ -215,15 +215,6 @@ cropdetect() {
# programming # programming
##############################################################################{{{ ##############################################################################{{{
# cd for /code/projects dir with completion
pp(){
if [ -d $HOME/code/projects/$* ]; then
cd $HOME/code/projects/$*
else
vim $HOME/code/projects/$*
fi
};
# watch latex file for changes and rebuild # watch latex file for changes and rebuild
latexwatch() { latexwatch() {
maindoc=$1 maindoc=$1

56
modules/project/init Executable file
View file

@ -0,0 +1,56 @@
#!/bin/zsh
typeset -ag ZP_LIST
local load-project-list() {
ZP_LIST=( $ZDOTDIR/projects/*(N:t) )
}
load-project-list
project() {
case "$1" in
reload)
load-project-list
echo "${(j:\n:)ZP_LIST}"
;;
close)
unset ZPROJECT
;;
open)
shift
open-project "$@"
;;
esac
}
_project_open() {
_arguments "2:project:($ZP_LIST)"
#_alternative "project:project:($ZP_LIST)"
}
_project() {
_arguments "1:Action:->action" \
"*: :->args"
case "$state" in
action)
_arguments '1:action:(open close reload)'
;;
args)
_project_$words[2]
;;
esac
}
compdef _project project
local open-project() {
typeset -gA ZPROJECT
ZPROJECT[name]="$1"
source $ZDOTDIR/projects/$1
pcd
}
pcd() {
cd ${ZPROJECT[path]}
}
alias pp=project

View file

@ -116,8 +116,14 @@ function setprompt() {
#middle info line #middle info line
if mod_loaded vcs; then middleline+=( "${rpscolor}${PR_VBAR} ")
middleline+=( "${rpscolor}${PR_VBAR} $(vcs_char) ${vcs_info_msg_0_}${reset}" )
if mod_loaded vcs && [[ -n ${vcs_info_msg_0_} ]]; then
middleline+=( "$(vcs_char) ${vcs_info_msg_0_}${reset}" )
fi
if mod_loaded project && [[ -n $ZPROJECT ]]; then
middleline+=( "${pathcolor}❰${ZPROJECT[name]}❱${reset}" )
fi fi
i_width=${(S)middleline//\%\{*\%\}} # search-and-replace color escapes i_width=${(S)middleline//\%\{*\%\}} # search-and-replace color escapes
@ -128,7 +134,7 @@ function setprompt() {
lines+=( ${(j::)infoline} ) lines+=( ${(j::)infoline} )
[[ -n ${vcs_info_msg_0_} ]] && lines+=( "${middleline}${filler}${rpscolor}${PR_VBAR}" ) [[ $#middleline > 1 ]] && lines+=( "${middleline}${filler}${rpscolor}${PR_VBAR}" )
lines+=( "${CORNER_LD}${PVPREFIX} %(1j.${rpscolor}%j${reset} .)${usercolor}%#${reset} " ) lines+=( "${CORNER_LD}${PVPREFIX} %(1j.${rpscolor}%j${reset} .)${usercolor}%#${reset} " )
### Finally, set the prompt ### Finally, set the prompt