summaryrefslogtreecommitdiff
path: root/01_Functions.zsh
diff options
context:
space:
mode:
Diffstat (limited to '01_Functions.zsh')
-rw-r--r--01_Functions.zsh66
1 files changed, 52 insertions, 14 deletions
diff --git a/01_Functions.zsh b/01_Functions.zsh
index 958403b..f781358 100644
--- a/01_Functions.zsh
+++ b/01_Functions.zsh
@@ -19,7 +19,26 @@
cmd_exists ()
{
- which -p $1 >/dev/null 2>&1
+ \which -p $1 >/dev/null 2>&1
+}
+
+git () {
+ GIT=$(\which -p git)
+ case $1 in
+ init|clone|config)
+ ;;
+ *)
+ if [ "$( ( $GIT ls-files ; $GIT ls-tree HEAD . ) 2>&- | head -n1)" = ""\
+ -a \( ! -d .git -o "$($GIT rev-parse --git-dir 2>&-)" != ".git" \)\
+ -a "$($GIT rev-parse --is-inside-git-dir 2>&-)" != "true" ]
+ then
+ echo >&2 "git $1: the current folder is not managed by git"
+ return
+ fi
+ ;;
+ esac
+
+ $(\which -p git) $@
}
term_title()
@@ -52,22 +71,22 @@ term_title()
screen*)
local _sep=""
[ $# -gt 0 ] && _sep=$1 && shift # gets and discards the separator, if any.
- if [ ! -z "$TMUX" ]
- then
+ #if [ ! -z "$TMUX" ]
+ #then
# Tmux
#print -Pn "\e]0;%n@%m (%l) %~${_sep:+$_sep #[fg=yellow,bold]}$@\a" # Sets term title
print -Pn "\e]0;#[fg=red]%n#[fg=default,bold]@#[fg=red]%m#[default] (#[fg=cyan]%l#[fg=default]) #[fg=red]%~${_sep:+#[default,fg=default]$_sep #[fg=yellow,bold]$@}#[default,fg=default]\a"
- else
+ #else
# Classic screen
# hardstatus
#print -Pn "\e]2;{+b W}SCREEN #n {-b W}| {R}?u(u) ?{W}{r}%n@%m{W} ({c}%l{W}) {R}%~{W}${_sep:+$_sep \{+b Y\}}$@{-b W}\a" # Sets hardstatus line (term title)
- print -Pn "\e]2;{R}?u(u) ?{W}{r}%n{R}@{r}%m{-b W} ({+b c}%l{-b W}) {R}%~{W}${_sep:+$_sep \{+b Y\}}$@{-b W}\a" # Sets hardstatus line (term title)
+ # print -Pn "\e]2;{R}?u(u) ?{W}{r}%n{R}@{r}%m{-b W} ({+b c}%l{-b W}) {R}%~{W}${_sep:+$_sep \{+b Y\}}$@{-b W}\a" # Sets hardstatus line (term title)
# caption
- print -Pn "\ek"
- [ "$SUDO_USER" != "" ] && print -Pn "($USER) "
- print -Pn "${@:-%~}"
- print -Pn "\e\\"
- fi
+ # print -Pn "\ek"
+ # [ "$SUDO_USER" != "" ] && print -Pn "($USER) "
+ # print -Pn "${@:-%~}"
+ # print -Pn "\e\\"
+ #fi
;;
*)
;;
@@ -93,14 +112,32 @@ preprint()
fi
}
-get_git_branch ()
+get_gcl_branch ()
{
- local my_git_branch checkouted_branch="yes"
+ case $1 in
+ git)
+ get_git_branch
+ ;;
+ hg)
+ get_hg_branch
+ ;;
+ *)
+ ;;
+ esac
+}
- if [ ! -z "$DO_NOT_CHECK_GIT_BRANCH" ]
+get_hg_branch ()
+{
+ HGROOT=$(hg root 2>/dev/null)
+ if [ ! -z "$HGROOT" ]
then
- return
+ hg branch
fi
+}
+
+get_git_branch ()
+{
+ local my_git_branch checkouted_branch="yes"
if [ -f ".repo/manifests.git/config" ]
then
@@ -283,6 +320,7 @@ set_prompt_colors ()
#prompt_colors[term]="$prompt_colors[generic]" # tty - unused, see term title
prompt_colors[user]="$prompt_colors[generic]" # login - generic
prompt_colors[host]="$prompt_colors[generic]" # hostname - generic
+ prompt_colors[display]="$prompt_colors[generic]" # hostname - generic
#prompt_colors[hist]="$color[none]" # history number - unused
prompt_colors[arob]="$color[bold];$prompt_colors[generic]" # <login>@<hostname> - bold generic
prompt_colors[dies]="$prompt_colors[generic]" # the bottom-end of the prompt - generic