Skip to content

Commit 3b1238a

Browse files
author
jedahan
committed
Switch to zsh-style functions
1 parent de360cf commit 3b1238a

21 files changed

+162
-194
lines changed

changelog.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,40 @@
33
The format is based on [Keep a Changelog](http://keepachangelog.com/)
44
and this project adheres to [Semantic Versioning](http://semver.org/).
55

6-
## Unreleased
6+
# Unreleased
7+
8+
## 3.0.0 - 2025-01-06
9+
10+
Years later, we are back. Many bugfixes and small annoyances and incompatibilities gone. A few breaking changes.
11+
12+
Removed geometry_exec_time, will re-add after a future refactor.
13+
14+
GEOMETRY_INFO now uses zsh statusline instead of being an empty command alias.
15+
16+
### Added
17+
- Add geometry_jj function for jujutsu
718
- Add GEOMETRY_TITLE and GEOMETRY_CMDTITLE as display locations
819
- Add geometry_cmd function to display currently-running command in GEOMETRY_CMDTITLE
920

21+
### Removed
22+
- Removed geometry_exec_time
23+
1024
### Fixed
25+
- Fix initial terminal RPROMPT being blank
26+
- Fix showing stale information in RPROMPT
27+
- Fix extra newline when printing GEOMETRY_INFO
1128
- Fix git functions erroring out in non-git directories (thanks @duncanbeevers!)
1229
- Git conflict counting with multiple files (thanks @gluxon!)
1330
- Fix git_status when the git directory contains spaces (thanks @tanyaionova!)
14-
- Do not print newline on enter if GEOMETRY_INFO is empty
31+
- Fix compatibility with znap (thanks @cweagans)
32+
33+
### Changed
34+
- Manually autoload functions we ship, to avoid loading user-created files
35+
- Prefix some functions with `builtin` to avoid user-defined aliases and functions
36+
37+
---
38+
39+
# Released
1540

1641
## 2.2.0 - 2020-01-13
1742

functions/geometry_docker_machine

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
# geometry_docker_machine - show the current docker machine name
22

3-
geometry_docker_machine() {
4-
[[ -n $DOCKER_MACHINE_NAME ]] || return
5-
6-
ansi ${GEOMETRY_DOCKER_MACHINE_COLOR:=blue} "(${GEOMETRY_DOCKER_MACHINE_SYMBOL:="⚓"} ${DOCKER_MACHINE_NAME})"
7-
}
3+
[[ -n $DOCKER_MACHINE_NAME ]] || return
4+
ansi ${GEOMETRY_DOCKER_MACHINE_COLOR:=blue} "(${GEOMETRY_DOCKER_MACHINE_SYMBOL:="⚓"} ${DOCKER_MACHINE_NAME})"

functions/geometry_echo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# geometry_echo - simple echo for a balanced terminal
22

3-
geometry_echo() { echo -n ${GEOMETRY_ECHO:-''}; }
3+
echo -n ${GEOMETRY_ECHO:-''}

functions/geometry_exec_time

Lines changed: 0 additions & 24 deletions
This file was deleted.

functions/geometry_exitcode

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
# geometry_exitcode - show the exit code of the last status
22

3-
geometry_exitcode() {
4-
(( $GEOMETRY[LAST_STATUS] )) && ansi ${GEOMETRY_EXITCODE_COLOR:-red} $GEOMETRY[LAST_STATUS] || echo ''
5-
}
3+
(( $GEOMETRY[LAST_STATUS] )) && ansi ${GEOMETRY_EXITCODE_COLOR:-red} $GEOMETRY[LAST_STATUS] || echo ''

functions/geometry_git

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,21 @@ geometry_git_conflicts() {
8484
ansi ${GEOMETRY_GIT_COLOR_CONFLICTS_UNSOLVED:-red} "${GEOMETRY_GIT_SYMBOL_CONFLICTS_UNSOLVED:-'◈'} $count"
8585
}
8686

87-
geometry_git() {
88-
(( $+commands[git] )) || return
89-
90-
_geometry_git_guard || return
91-
92-
$(git rev-parse --is-bare-repository) \
93-
&& ansi ${GEOMETRY_GIT_COLOR_BARE:=blue} ${GEOMETRY_GIT_SYMBOL_BARE:="⬢"} \
94-
&& return
95-
96-
local git_info && git_info=(
97-
geometry_git_rebase
98-
geometry_git_remote
99-
geometry_git_branch
100-
geometry_git_conflicts
101-
geometry_git_time
102-
geometry_git_stashes
103-
geometry_git_status
104-
)
105-
106-
geometry::wrap $PWD $git_info
107-
}
87+
(( $+commands[git] )) || return
88+
_geometry_git_guard || return
89+
90+
$(git rev-parse --is-bare-repository) \
91+
&& ansi ${GEOMETRY_GIT_COLOR_BARE:=blue} ${GEOMETRY_GIT_SYMBOL_BARE:="⬢"} \
92+
&& return
93+
94+
local git_info && git_info=(
95+
geometry_git_rebase
96+
geometry_git_remote
97+
geometry_git_branch
98+
geometry_git_conflicts
99+
geometry_git_time
100+
geometry_git_stashes
101+
geometry_git_status
102+
)
103+
104+
geometry::wrap $PWD $git_info

functions/geometry_hg

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
# geometry_hg - display current mercurial branch and status
22

3-
geometry_hg() {
4-
(( $+commands[hg] )) || return 1
5-
[[ -d .hg ]] || return 2
3+
(( $+commands[hg] )) || return 1
4+
[[ -d .hg ]] || return 2
65

7-
local branch="$(ansi ${GEOMETRY_HG_COLOR_BRANCH:=242} "$(hg branch 2> /dev/null)")"
6+
local branch="$(ansi ${GEOMETRY_HG_COLOR_BRANCH:=242} "$(hg branch 2> /dev/null)")"
87

9-
[[ -n "$(hg status 2> /dev/null)" ]] \
10-
&& local symbol="$(ansi ${GEOMETRY_HG_COLOR_DIRTY:=red} ${GEOMETRY_HG_SYMBOL_DIRTY:="⬡"})" \
11-
|| local symbol="$(ansi ${GEOMETRY_HG_COLOR_CLEAN:=green} ${GEOMETRY_HG_SYMBOL_CLEAN:="⬢"})"
8+
[[ -n "$(hg status 2> /dev/null)" ]] \
9+
&& local symbol="$(ansi ${GEOMETRY_HG_COLOR_DIRTY:=red} ${GEOMETRY_HG_SYMBOL_DIRTY:="⬡"})" \
10+
|| local symbol="$(ansi ${GEOMETRY_HG_COLOR_CLEAN:=green} ${GEOMETRY_HG_SYMBOL_CLEAN:="⬢"})"
1211

13-
echo -n "${branch}${GEOMETRY_HG_SYMBOL_SEPARATOR:=::}${symbol}"
14-
}
12+
echo -n "${branch}${GEOMETRY_HG_SYMBOL_SEPARATOR:=::}${symbol}"

functions/geometry_hostname

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# geometry_hostname - show user@hostname
22

3-
geometry_hostname() {
4-
local _host=${HOST:-$HOSTNAME}
5-
[[ "$_host" = "${GEOMETRY_HOSTNAME_HIDE_ON:-localhost}" ]] && return
6-
echo -n "${USER}${GEOMETRY_HOSTNAME_SEPARATOR:-@}${_host}"
7-
}
3+
local _host=${HOST:-$HOSTNAME}
4+
[[ "$_host" = "${GEOMETRY_HOSTNAME_HIDE_ON:-localhost}" ]] && return
5+
echo -n "${USER}${GEOMETRY_HOSTNAME_SEPARATOR:-@}${_host}"

functions/geometry_jj

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# geometry_jj - display current jujutsu status
22

3-
geometry_jj () {
4-
(( $+commands[jj] )) || return 1
5-
jj log --quiet --no-pager --no-graph --ignore-working-copy --revisions @ --color never --template \
6-
${GEOMETRY_JJ_TEMPLATE:-'"%F{5}" ++ change_id.shortest() ++ "%F{4}" ++ commit_id.shortest() ++ "%f% "'} \
7-
2> /dev/null
8-
}
3+
(( $+commands[jj] )) || return 1
4+
jj log --quiet --no-pager --no-graph --ignore-working-copy --revisions @ --color never --template \
5+
${GEOMETRY_JJ_TEMPLATE:-'"%F{5}" ++ change_id.shortest() ++ "%F{4}" ++ commit_id.shortest() ++ "%f% "'} \
6+
2> /dev/null

functions/geometry_jobs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# geometry_jobs - show background jobs count `⚙ 1`
22

3-
geometry_jobs() { [[ 0 -ne "$(jobs | wc -l)" ]] && ansi ${GEOMETRY_JOBS_COLOR:=blue} '%(1j.'${GEOMETRY_JOBS_SYMBOL:="⚙"}' %j.)'; }
3+
[[ 0 -ne "$(jobs | wc -l)" ]] && ansi ${GEOMETRY_JOBS_COLOR:=blue} '%(1j.'${GEOMETRY_JOBS_SYMBOL:="⚙"}' %j.)'

0 commit comments

Comments
 (0)