~fmac/corylus

95a3feb1e55f975ef63c159a03e273596ba9c959 — Francesco Camuffo a month ago 0a6019d main
Add seg time-unix
3 files changed, 17 insertions(+), 3 deletions(-)

M README.md
M main.go
A time.go
M README.md => README.md +6 -3
@@ 23,6 23,7 @@ At the moment the available segments are:
- cwd-count
- hostname
- tail
- time-unix
- username

---


@@ 33,15 34,17 @@ Here is an example with some colors.
PS1='$(corylus \
	"[" hostname "] " \
	"\033[34m" username "\033[0m " \
	"\033[35m" cwd "\033[0m" " " \
	"[" cwd-count " files]" \
	"\033[31m $? \033[0m " \
	"\033[35m" cwd "\033[0m " \
	"[" cwd-count " files] " \
	"[" time-unix "]" \
	tail)'
```

Which outputs with this format:

```
[maze] fmac ~/r/c/.git [13 files]
[maze] fmac  0  ~/r/c/.git [13 files] [1620754137]
$
```
## Install

M main.go => main.go +1 -0
@@ 17,6 17,7 @@ func main() {
		"cwd-count": segCwdCount,
		"hostname": segHostname,
		"tail": segTail,
		"time-unix": segTimeUnix,
		"username": segUsername,
	}


A time.go => time.go +10 -0
@@ 0,0 1,10 @@
package main

import (
	"strconv"
	"time"
)

func segTimeUnix() (string, error) {
	return strconv.FormatInt(time.Now().Unix(), 10), nil
}