[zsh] Bump oh-my-zsh and fzf

This commit is contained in:
Sebastian Schulze 2020-11-18 10:49:27 +01:00
parent de9c84286f
commit f0e9815af8
Signed by: bascht
GPG Key ID: 5BCB1D3B4D38A35A
50 changed files with 1219 additions and 711 deletions

View File

@ -17,21 +17,19 @@ make
# Build fzf binary and copy it to bin directory # Build fzf binary and copy it to bin directory
make install make install
# Build 32-bit and 64-bit executables and tarballs in target # Build fzf binaries and archives for all platforms using goreleaser
make build
# Publish GitHub release
make release make release
# Make release archives for all supported platforms in target
make release-all
``` ```
### Using `go get` > :warning: Makefile uses git commands to determine the version and the
> revision information for `fzf --version`. So if you're building fzf from an
Alternatively, you can build fzf directly with `go get` command without > environment where its git information is not available, you have to manually
manually cloning the repository. > set `$FZF_VERSION` and `$FZF_REVISION`.
>
```sh > e.g. `FZF_VERSION=0.24.0 FZF_REVISION=tarball make`
go get -u github.com/junegunn/fzf
```
Third-party libraries used Third-party libraries used
-------------------------- --------------------------

View File

@ -1,6 +1,22 @@
CHANGELOG CHANGELOG
========= =========
0.24.3
------
- Added `--padding` option
```sh
fzf --margin 5% --padding 5% --border --preview 'cat {}' \
--color bg:#222222,preview-bg:#333333
```
0.24.2
------
- Bug fixes and improvements
0.24.1
------
- Fixed broken `--color=[bw|no]` option
0.24.0 0.24.0
------ ------
- Real-time rendering of preview window - Real-time rendering of preview window
@ -23,10 +39,30 @@ CHANGELOG
# * Italic style may not be supported by some terminals # * Italic style may not be supported by some terminals
rg --line-number --no-heading --color=always "" | rg --line-number --no-heading --color=always "" |
fzf --ansi --prompt "Rg: " \ fzf --ansi --prompt "Rg: " \
--color fg+:italic,hl:underline:-1,hl+:underline:reverse:-1 \ --color fg+:italic,hl:underline:-1,hl+:italic:underline:reverse:-1 \
--color pointer:reverse,prompt:reverse,input:159 \ --color pointer:reverse,prompt:reverse,input:159 \
--pointer ' ' --pointer ' '
``` ```
- More `--border` options
- `vertical`, `top`, `bottom`, `left`, `right`
- Updated Vim plugin to use these new `--border` options
```vim
" Floating popup window in the center of the screen
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
" Popup with 100% width
let g:fzf_layout = { 'window': { 'width': 1.0, 'height': 0.5, 'border': 'horizontal' } }
" Popup with 100% height
let g:fzf_layout = { 'window': { 'width': 0.5, 'height': 1.0, 'border': 'vertical' } }
" Similar to 'down' layout, but it uses a popup window and doesn't affect the window layout
let g:fzf_layout = { 'window': { 'width': 1.0, 'height': 0.5, 'yoffset': 1.0, 'border': 'top' } }
" Opens on the right;
" 'highlight' option is still supported but it will only take the foreground color of the group
let g:fzf_layout = { 'window': { 'width': 0.5, 'height': 1.0, 'xoffset': 1.0, 'border': 'left', 'highlight': 'Comment' } }
```
- To indicate if `--multi` mode is enabled, fzf will print the number of - To indicate if `--multi` mode is enabled, fzf will print the number of
selected items even when no item is selected selected items even when no item is selected
```sh ```sh
@ -37,6 +73,7 @@ CHANGELOG
seq 100 | fzf --multi 5 seq 100 | fzf --multi 5
# 100/100 (0/5) # 100/100 (0/5)
``` ```
- Since 0.24.0, release binaries will be uploaded to https://github.com/junegunn/fzf/releases
0.23.1 0.23.1
------ ------

View File

@ -5,8 +5,26 @@ MAKEFILE := $(realpath $(lastword $(MAKEFILE_LIST)))
ROOT_DIR := $(shell dirname $(MAKEFILE)) ROOT_DIR := $(shell dirname $(MAKEFILE))
SOURCES := $(wildcard *.go src/*.go src/*/*.go) $(MAKEFILE) SOURCES := $(wildcard *.go src/*.go src/*/*.go) $(MAKEFILE)
REVISION := $(shell git log -n 1 --pretty=format:%h -- $(SOURCES)) ifdef FZF_VERSION
BUILD_FLAGS := -a -ldflags "-X main.revision=$(REVISION) -w '-extldflags=$(LDFLAGS)'" -tags "$(TAGS)" VERSION := $(FZF_VERSION)
else
VERSION := $(shell git describe --abbrev=0 2> /dev/null)
endif
ifeq ($(VERSION),)
$(error Not on git repository; cannot determine $$FZF_VERSION)
endif
VERSION_TRIM := $(shell sed "s/-.*//" <<< $(VERSION))
VERSION_REGEX := $(subst .,\.,$(VERSION_TRIM))
ifdef FZF_REVISION
REVISION := $(FZF_REVISION)
else
REVISION := $(shell git log -n 1 --pretty=format:%h -- $(SOURCES) 2> /dev/null)
endif
ifeq ($(REVISION),)
$(error Not on git repository; cannot determine $$FZF_REVISION)
endif
BUILD_FLAGS := -a -ldflags "-s -w -X main.version=$(VERSION) -X main.revision=$(REVISION)" -tags "$(TAGS)"
BINARY64 := fzf-$(GOOS)_amd64 BINARY64 := fzf-$(GOOS)_amd64
BINARYARM5 := fzf-$(GOOS)_arm5 BINARYARM5 := fzf-$(GOOS)_arm5
@ -14,13 +32,6 @@ BINARYARM6 := fzf-$(GOOS)_arm6
BINARYARM7 := fzf-$(GOOS)_arm7 BINARYARM7 := fzf-$(GOOS)_arm7
BINARYARM8 := fzf-$(GOOS)_arm8 BINARYARM8 := fzf-$(GOOS)_arm8
BINARYPPC64LE := fzf-$(GOOS)_ppc64le BINARYPPC64LE := fzf-$(GOOS)_ppc64le
VERSION := $(shell awk -F= '/version =/ {print $$2}' src/constants.go | tr -d "\" ")
RELEASE64 := fzf-$(VERSION)-$(GOOS)_amd64
RELEASEARM5 := fzf-$(VERSION)-$(GOOS)_arm5
RELEASEARM6 := fzf-$(VERSION)-$(GOOS)_arm6
RELEASEARM7 := fzf-$(VERSION)-$(GOOS)_arm7
RELEASEARM8 := fzf-$(VERSION)-$(GOOS)_arm8
RELEASEPPC64LE := fzf-$(VERSION)-$(GOOS)_ppc64le
# https://en.wikipedia.org/wiki/Uname # https://en.wikipedia.org/wiki/Uname
UNAME_M := $(shell uname -m) UNAME_M := $(shell uname -m)
@ -41,40 +52,11 @@ else ifeq ($(UNAME_M),aarch64)
else ifeq ($(UNAME_M),ppc64le) else ifeq ($(UNAME_M),ppc64le)
BINARY := $(BINARYPPC64LE) BINARY := $(BINARYPPC64LE)
else else
$(error "Build on $(UNAME_M) is not supported, yet.") $(error Build on $(UNAME_M) is not supported, yet.)
endif endif
all: target/$(BINARY) all: target/$(BINARY)
target:
mkdir -p $@
ifeq ($(GOOS),windows)
release: target/$(BINARY64)
cd target && cp -f $(BINARY64) fzf.exe && zip $(RELEASE64).zip fzf.exe
cd target && rm -f fzf.exe
else ifeq ($(GOOS),linux)
release: target/$(BINARY64) target/$(BINARYARM5) target/$(BINARYARM6) target/$(BINARYARM7) target/$(BINARYARM8) target/$(BINARYPPC64LE)
cd target && cp -f $(BINARY64) fzf && tar -czf $(RELEASE64).tgz fzf
cd target && cp -f $(BINARYARM5) fzf && tar -czf $(RELEASEARM5).tgz fzf
cd target && cp -f $(BINARYARM6) fzf && tar -czf $(RELEASEARM6).tgz fzf
cd target && cp -f $(BINARYARM7) fzf && tar -czf $(RELEASEARM7).tgz fzf
cd target && cp -f $(BINARYARM8) fzf && tar -czf $(RELEASEARM8).tgz fzf
cd target && cp -f $(BINARYPPC64LE) fzf && tar -czf $(RELEASEPPC64LE).tgz fzf
cd target && rm -f fzf
else
release: target/$(BINARY64)
cd target && cp -f $(BINARY64) fzf && tar -czf $(RELEASE64).tgz fzf
cd target && rm -f fzf
endif
release-all: clean test
GOOS=darwin make release
GOOS=linux make release
GOOS=freebsd make release
GOOS=openbsd make release
GOOS=windows make release
test: $(SOURCES) test: $(SOURCES)
SHELL=/bin/sh GOOS= $(GO) test -v -tags "$(TAGS)" \ SHELL=/bin/sh GOOS= $(GO) test -v -tags "$(TAGS)" \
github.com/junegunn/fzf/src \ github.com/junegunn/fzf/src \
@ -84,8 +66,46 @@ test: $(SOURCES)
install: bin/fzf install: bin/fzf
build:
goreleaser --rm-dist --snapshot
release:
ifndef GITHUB_TOKEN
$(error GITHUB_TOKEN is not defined)
endif
# Check if we are on master branch
ifneq ($(shell git symbolic-ref --short HEAD),master)
$(error Not on master branch)
endif
# Check if version numbers are properly updated
grep -q ^$(VERSION_REGEX)$$ CHANGELOG.md
grep -qF '"fzf $(VERSION_TRIM)"' man/man1/fzf.1
grep -qF '"fzf $(VERSION_TRIM)"' man/man1/fzf-tmux.1
grep -qF $(VERSION) install
grep -qF $(VERSION) install.ps1
# Make release note out of CHANGELOG.md
sed -n '/^$(VERSION_REGEX)$$/,/^[0-9]/p' CHANGELOG.md | tail -r | \
sed '1,/^ *$$/d' | tail -r | sed 1,2d | tee tmp/release-note
# Push to temp branch first so that install scripts always works on master branch
git checkout -B temp master
git push origin temp --follow-tags --force
# Make a GitHub release
goreleaser --rm-dist --release-notes tmp/release-note
# Push to master
git checkout master
git push origin master
# Delete temp branch
git push origin --delete temp
clean: clean:
$(RM) -r target $(RM) -r dist target
target/$(BINARY64): $(SOURCES) target/$(BINARY64): $(SOURCES)
GOARCH=amd64 $(GO) build $(BUILD_FLAGS) -o $@ GOARCH=amd64 $(GO) build $(BUILD_FLAGS) -o $@
@ -121,4 +141,4 @@ update:
$(GO) get -u $(GO) get -u
$(GO) mod tidy $(GO) mod tidy
.PHONY: all release release-all test install clean docker docker-test update .PHONY: all build release test install clean docker docker-test update

View File

@ -298,9 +298,8 @@ following options are allowed:
- Optional: - Optional:
- `yoffset` [float default 0.5 range [0 ~ 1]] - `yoffset` [float default 0.5 range [0 ~ 1]]
- `xoffset` [float default 0.5 range [0 ~ 1]] - `xoffset` [float default 0.5 range [0 ~ 1]]
- `highlight` [string default `'Comment'`]: Highlight group for border
- `border` [string default `rounded`]: Border style - `border` [string default `rounded`]: Border style
- `rounded` / `sharp` / `horizontal` / `vertical` / `top` / `bottom` / `left` / `right` - `rounded` / `sharp` / `horizontal` / `vertical` / `top` / `bottom` / `left` / `right` / `no[ne]`
`fzf#wrap` `fzf#wrap`
---------- ----------

View File

@ -82,7 +82,7 @@ fzf project consists of the following components:
You can [download fzf executable][bin] alone if you don't need the extra You can [download fzf executable][bin] alone if you don't need the extra
stuff. stuff.
[bin]: https://github.com/junegunn/fzf-bin/releases [bin]: https://github.com/junegunn/fzf/releases
### Using Homebrew or Linuxbrew ### Using Homebrew or Linuxbrew

View File

@ -1,5 +1,6 @@
bin/fzf bin/fzf
bin/fzf.exe bin/fzf.exe
dist
target target
pkg pkg
Gemfile.lock Gemfile.lock
@ -9,3 +10,5 @@ vendor
gopath gopath
*.zwc *.zwc
fzf fzf
tmp
*.patch

11
dot_fzf/dot_gon.hcl Normal file
View File

@ -0,0 +1,11 @@
source = ["./dist/fzf-macos_darwin_amd64/fzf"]
bundle_id = "kr.junegunn.fzf"
apple_id {
username = "junegunn.c@gmail.com"
password = "@env:AC_PASSWORD"
}
sign {
application_identity = "Apple Development: junegunn.c@gmail.com"
}

View File

@ -0,0 +1,69 @@
---
project_name: fzf
before:
hooks:
- go mod download
builds:
- id: fzf-macos
binary: fzf
goos:
- darwin
goarch:
- amd64
ldflags:
- "-s -w -X main.version={{ .Version }} -X main.revision={{ .ShortCommit }}"
hooks:
post: gon .gon.hcl
- goos:
- linux
- windows
- freebsd
- openbsd
goarch:
- amd64
- arm
- arm64
goarm:
- 5
- 6
- 7
ldflags:
- "-s -w -X main.version={{ .Version }} -X main.revision={{ .ShortCommit }}"
ignore:
- goos: freebsd
goarch: arm
- goos: openbsd
goarch: arm
- goos: freebsd
goarch: arm64
- goos: openbsd
goarch: arm64
archives:
- name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
format: tar.gz
format_overrides:
- goos: windows
format: zip
files:
- non-existent*
release:
github:
owner: junegunn
name: fzf
prerelease: auto
name_template: '{{ .Tag }}'
snapshot:
name_template: "{{ .Tag }}-devel"
changelog:
sort: asc
filters:
exclude:
- README
- test

View File

@ -2,11 +2,10 @@
set -u set -u
version=0.23.1 version=0.24.3
auto_completion= auto_completion=
key_bindings= key_bindings=
update_config=2 update_config=2
binary_arch=
shells="bash zsh fish" shells="bash zsh fish"
prefix='~/.fzf' prefix='~/.fzf'
prefix_expand=~/.fzf prefix_expand=~/.fzf
@ -115,7 +114,7 @@ link_fzf_in_path() {
try_curl() { try_curl() {
command -v curl > /dev/null && command -v curl > /dev/null &&
if [[ $1 =~ tgz$ ]]; then if [[ $1 =~ tar.gz$ ]]; then
curl -fL $1 | tar -xzf - curl -fL $1 | tar -xzf -
else else
local temp=${TMPDIR:-/tmp}/fzf.zip local temp=${TMPDIR:-/tmp}/fzf.zip
@ -125,7 +124,7 @@ try_curl() {
try_wget() { try_wget() {
command -v wget > /dev/null && command -v wget > /dev/null &&
if [[ $1 =~ tgz$ ]]; then if [[ $1 =~ tar.gz$ ]]; then
wget -O - $1 | tar -xzf - wget -O - $1 | tar -xzf -
else else
local temp=${TMPDIR:-/tmp}/fzf.zip local temp=${TMPDIR:-/tmp}/fzf.zip
@ -135,13 +134,11 @@ try_wget() {
download() { download() {
echo "Downloading bin/fzf ..." echo "Downloading bin/fzf ..."
if [[ ! "$version" =~ alpha ]]; then if [ -x "$fzf_base"/bin/fzf ]; then
if [ -x "$fzf_base"/bin/fzf ]; then echo " - Already exists"
echo " - Already exists" check_binary && return
check_binary && return
fi
link_fzf_in_path && return
fi fi
link_fzf_in_path && return
mkdir -p "$fzf_base"/bin && cd "$fzf_base"/bin mkdir -p "$fzf_base"/bin && cd "$fzf_base"/bin
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
binary_error="Failed to create bin directory" binary_error="Failed to create bin directory"
@ -149,9 +146,7 @@ download() {
fi fi
local url local url
[[ "$version" =~ alpha ]] && url=https://github.com/junegunn/fzf/releases/download/$version/${1}
url=https://github.com/junegunn/fzf-bin/releases/download/alpha/${1} ||
url=https://github.com/junegunn/fzf-bin/releases/download/$version/${1}
set -o pipefail set -o pipefail
if ! (try_curl $url || try_wget $url); then if ! (try_curl $url || try_wget $url); then
set +o pipefail set +o pipefail
@ -173,20 +168,20 @@ archi=$(uname -sm)
binary_available=1 binary_available=1
binary_error="" binary_error=""
case "$archi" in case "$archi" in
Darwin\ *64) download fzf-$version-darwin_${binary_arch:-amd64}.tgz ;; Darwin\ *64) download fzf-$version-darwin_amd64.tar.gz ;;
Linux\ armv5*) download fzf-$version-linux_${binary_arch:-arm5}.tgz ;; Linux\ armv5*) download fzf-$version-linux_armv5.tar.gz ;;
Linux\ armv6*) download fzf-$version-linux_${binary_arch:-arm6}.tgz ;; Linux\ armv6*) download fzf-$version-linux_armv6.tar.gz ;;
Linux\ armv7*) download fzf-$version-linux_${binary_arch:-arm7}.tgz ;; Linux\ armv7*) download fzf-$version-linux_armv7.tar.gz ;;
Linux\ armv8*) download fzf-$version-linux_${binary_arch:-arm8}.tgz ;; Linux\ armv8*) download fzf-$version-linux_arm64.tar.gz ;;
Linux\ aarch64*) download fzf-$version-linux_${binary_arch:-arm8}.tgz ;; Linux\ aarch64*) download fzf-$version-linux_arm64.tar.gz ;;
Linux\ *64) download fzf-$version-linux_${binary_arch:-amd64}.tgz ;; Linux\ *64) download fzf-$version-linux_amd64.tar.gz ;;
FreeBSD\ *64) download fzf-$version-freebsd_${binary_arch:-amd64}.tgz ;; FreeBSD\ *64) download fzf-$version-freebsd_amd64.tar.gz ;;
OpenBSD\ *64) download fzf-$version-openbsd_${binary_arch:-amd64}.tgz ;; OpenBSD\ *64) download fzf-$version-openbsd_amd64.tar.gz ;;
CYGWIN*\ *64) download fzf-$version-windows_${binary_arch:-amd64}.zip ;; CYGWIN*\ *64) download fzf-$version-windows_amd64.zip ;;
MINGW*\ *64) download fzf-$version-windows_${binary_arch:-amd64}.zip ;; MINGW*\ *64) download fzf-$version-windows_amd64.zip ;;
MSYS*\ *64) download fzf-$version-windows_${binary_arch:-amd64}.zip ;; MSYS*\ *64) download fzf-$version-windows_amd64.zip ;;
Windows*\ *64) download fzf-$version-windows_${binary_arch:-amd64}.zip ;; Windows*\ *64) download fzf-$version-windows_amd64.zip ;;
*) binary_available=0 binary_error=1 ;; *) binary_available=0 binary_error=1 ;;
esac esac
cd "$fzf_base" cd "$fzf_base"
@ -202,7 +197,7 @@ if [ -n "$binary_error" ]; then
export GOPATH="${TMPDIR:-/tmp}/fzf-gopath" export GOPATH="${TMPDIR:-/tmp}/fzf-gopath"
mkdir -p "$GOPATH" mkdir -p "$GOPATH"
fi fi
if go get -u github.com/junegunn/fzf; then if go get -ldflags "-s -w -X main.version=$version -X main.revision=go-get" github.com/junegunn/fzf; then
echo "OK" echo "OK"
cp "$GOPATH/bin/fzf" "$fzf_base/bin/" cp "$GOPATH/bin/fzf" "$fzf_base/bin/"
else else

View File

@ -2,14 +2,14 @@ module github.com/junegunn/fzf
require ( require (
github.com/gdamore/tcell v1.4.0 github.com/gdamore/tcell v1.4.0
github.com/lucasb-eyer/go-colorful v1.0.3 // indirect
github.com/mattn/go-isatty v0.0.12 github.com/mattn/go-isatty v0.0.12
github.com/mattn/go-runewidth v0.0.9 github.com/mattn/go-runewidth v0.0.9
github.com/mattn/go-shellwords v1.0.9 github.com/mattn/go-shellwords v1.0.10
github.com/saracen/walker v0.0.0-20191201085201-324a081bae7e github.com/saracen/walker v0.1.1
golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 // indirect
golang.org/x/text v0.3.2 // indirect golang.org/x/sys v0.0.0-20201026173827-119d4633e4d1
golang.org/x/text v0.3.3 // indirect
) )
go 1.13 go 1.13

View File

@ -1,47 +1,35 @@
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell v1.4.0 h1:vUnHwJRvcPQa3tzi+0QI4U9JINXYJlOz9yiaiPQ2wMU= github.com/gdamore/tcell v1.4.0 h1:vUnHwJRvcPQa3tzi+0QI4U9JINXYJlOz9yiaiPQ2wMU=
github.com/gdamore/tcell v1.4.0/go.mod h1:vxEiSDZdW3L+Uhjii9c3375IlDmR05bzxY404ZVSMo0= github.com/gdamore/tcell v1.4.0/go.mod h1:vxEiSDZdW3L+Uhjii9c3375IlDmR05bzxY404ZVSMo0=
github.com/lucasb-eyer/go-colorful v1.0.2 h1:mCMFu6PgSozg9tDNMMK3g18oJBX7oYGrC09mS6CXfO4=
github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s=
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac= github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.8 h1:3tS41NlGYSmhhe/8fhGRzc+z3AYCw1Fe1WAyLuujKs0=
github.com/mattn/go-runewidth v0.0.8/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-shellwords v1.0.9 h1:eaB5JspOwiKKcHdqcjbfe5lA9cNn/4NRRtddXJCimqk= github.com/mattn/go-shellwords v1.0.10 h1:Y7Xqm8piKOO3v10Thp7Z36h4FYFjt5xB//6XvOrs2Gw=
github.com/mattn/go-shellwords v1.0.9/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y= github.com/mattn/go-shellwords v1.0.10/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
github.com/saracen/walker v0.0.0-20191201085201-324a081bae7e h1:NO86zOn5ScSKW8wRbMaSIcjDZUFpWdCQQnexRqZ9h9A= github.com/saracen/walker v0.1.1 h1:Ou2QIKTWqo0QxhtuHVmtObbmhjMCEUyJ82xp0uV+MGI=
github.com/saracen/walker v0.0.0-20191201085201-324a081bae7e/go.mod h1:G0Z6yVPru183i2MuRJx1DcR4dgIZtLcTdaaE/pC1BJU= github.com/saracen/walker v0.1.1/go.mod h1:0oKYMsKVhSJ+ful4p/XbjvXbMgLEkLITZaxozsl4CGE=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d h1:9FCpayM9Egr1baVnV1SX0H87m+XB0B8S0hAMi99X/3U= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E=
golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756 h1:9nuHUbU8dRnRRfj9KjWUVrJeoexdbeMjttk6Oh1rD10= golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756 h1:9nuHUbU8dRnRRfj9KjWUVrJeoexdbeMjttk6Oh1rD10=
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfruoXZIrh4YBgqVHtDvw0= golang.org/x/sys v0.0.0-20201026173827-119d4633e4d1 h1:/DtoiOYKoQCcIFXQjz07RnWNPRCbqmSXSpgEzhC9ZHM=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201026173827-119d4633e4d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191011211836-4c025a95b26e h1:1o2bDs9pCd2xFhdwqJTrCIswAeEsn4h/PCNelWpfcsI=
golang.org/x/tools v0.0.0-20191011211836-4c025a95b26e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View File

@ -1,10 +1,4 @@
$version="0.23.1" $version="0.24.3"
if ([Environment]::Is64BitProcess) {
$binary_arch="amd64"
} else {
$binary_arch="386"
}
$fzf_base=Split-Path -Parent $MyInvocation.MyCommand.Definition $fzf_base=Split-Path -Parent $MyInvocation.MyCommand.Definition
@ -32,12 +26,10 @@ function check_binary () {
function download { function download {
param($file) param($file)
Write-Host "Downloading bin/fzf ..." Write-Host "Downloading bin/fzf ..."
if ("$version" -ne "alpha") { if (Test-Path "$fzf_base\bin\fzf.exe") {
if (Test-Path "$fzf_base\bin\fzf.exe") { Write-Host " - Already exists"
Write-Host " - Already exists" if (check_binary) {
if (check_binary) { return
return
}
} }
} }
if (-not (Test-Path "$fzf_base\bin")) { if (-not (Test-Path "$fzf_base\bin")) {
@ -48,11 +40,7 @@ function download {
return return
} }
cd "$fzf_base\bin" cd "$fzf_base\bin"
if ("$version" -eq "alpha") { $url="https://github.com/junegunn/fzf/releases/download/$version/$file"
$url="https://github.com/junegunn/fzf-bin/releases/download/alpha/$file"
} else {
$url="https://github.com/junegunn/fzf-bin/releases/download/$version/$file"
}
$temp=$env:TMP + "\fzf.zip" $temp=$env:TMP + "\fzf.zip"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
(New-Object Net.WebClient).DownloadFile($url, $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$temp")) (New-Object Net.WebClient).DownloadFile($url, $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$temp"))
@ -68,6 +56,6 @@ function download {
check_binary >$null check_binary >$null
} }
download "fzf-$version-windows_$binary_arch.zip" download "fzf-$version-windows_amd64.zip"
Write-Host 'For more information, see: https://github.com/junegunn/fzf' Write-Host 'For more information, see: https://github.com/junegunn/fzf'

View File

@ -5,9 +5,10 @@ import (
"github.com/junegunn/fzf/src/protector" "github.com/junegunn/fzf/src/protector"
) )
var revision string var version string = "0.24"
var revision string = "devel"
func main() { func main() {
protector.Protect() protector.Protect()
fzf.Run(fzf.ParseOptions(), revision) fzf.Run(fzf.ParseOptions(), version, revision)
} }

View File

@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
.. ..
.TH fzf-tmux 1 "Oct 2020" "fzf 0.23.1" "fzf-tmux - open fzf in tmux split pane" .TH fzf-tmux 1 "Nov 2020" "fzf 0.24.3" "fzf-tmux - open fzf in tmux split pane"
.SH NAME .SH NAME
fzf-tmux - open fzf in tmux split pane fzf-tmux - open fzf in tmux split pane

View File

@ -21,7 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
.. ..
.TH fzf 1 "Oct 2020" "fzf 0.23.1" "fzf - a command-line fuzzy finder" .TH fzf 1 "Nov 2020" "fzf 0.24.3" "fzf - a command-line fuzzy finder"
.SH NAME .SH NAME
fzf - a command-line fuzzy finder fzf - a command-line fuzzy finder
@ -192,6 +192,16 @@ Draw border around the finder
.br .br
.BR horizontal " Horizontal lines above and below the finder" .BR horizontal " Horizontal lines above and below the finder"
.br .br
.BR vertical " Vertical lines on each side of the finder"
.br
.BR top
.br
.BR bottom
.br
.BR left
.br
.BR right
.br
.TP .TP
.B "--no-unicode" .B "--no-unicode"
@ -223,6 +233,29 @@ e.g.
\fBfzf --margin 10% \fBfzf --margin 10%
fzf --margin 1,5%\fR fzf --margin 1,5%\fR
.RE .RE
.TP
.BI "--padding=" PADDING
Comma-separated expression for padding inside the border. Padding is
distinguishable from margin only when \fB--border\fR option is used.
.br
.br
e.g.
\fBfzf --margin 5% --padding 5% --border --preview 'cat {}' \\
--color bg:#222222,preview-bg:#333333\fR
.br
.RS
.BR TRBL " Same padding for top, right, bottom, and left"
.br
.BR TB,RL " Vertical, horizontal padding"
.br
.BR T,RL,B " Top, horizontal, bottom padding"
.br
.BR T,R,B,L " Top, right, bottom, left padding"
.br
.RE
.TP .TP
.BI "--info=" "STYLE" .BI "--info=" "STYLE"
Determines the display style of finder info. Determines the display style of finder info.

View File

@ -128,7 +128,7 @@ endfunction
function! s:default_layout() function! s:default_layout()
return s:popup_support() return s:popup_support()
\ ? { 'window' : { 'width': 0.9, 'height': 0.6, 'highlight': 'Normal' } } \ ? { 'window' : { 'width': 0.9, 'height': 0.6 } }
\ : { 'down': '~40%' } \ : { 'down': '~40%' }
endfunction endfunction
@ -154,7 +154,20 @@ function! fzf#install()
endif endif
endfunction endfunction
function! fzf#exec() function! s:version_requirement(val, min)
let val = split(a:val, '\.')
let min = split(a:min, '\.')
for idx in range(0, len(min) - 1)
let v = get(val, idx, 0)
if v < min[idx] | return 0
elseif v > min[idx] | return 1
endif
endfor
return 1
endfunction
let s:checked = {}
function! fzf#exec(...)
if !exists('s:exec') if !exists('s:exec')
if executable(s:fzf_go) if executable(s:fzf_go)
let s:exec = s:fzf_go let s:exec = s:fzf_go
@ -169,6 +182,26 @@ function! fzf#exec()
throw 'fzf executable not found' throw 'fzf executable not found'
endif endif
endif endif
if a:0 && !has_key(s:checked, a:1)
let command = s:exec . ' --version'
let output = systemlist(command)
if v:shell_error || empty(output)
throw printf('Failed to run "%s": %s', command, output)
endif
let fzf_version = matchstr(output[-1], '[0-9.]\+')
if s:version_requirement(fzf_version, a:1)
let s:checked[a:1] = 1
return s:exec
elseif a:0 < 2 && input(printf('You need fzf %s or above. Found: %s. Download binary? (y/n) ', a:1, fzf_version)) =~? '^y'
redraw
call fzf#install()
return fzf#exec(a:1, 1)
else
throw printf('You need to upgrade fzf (required: %s or above)', a:1)
endif
endif
return s:exec return s:exec
endfunction endfunction
@ -250,7 +283,8 @@ function! s:common_sink(action, lines) abort
let cwd = exists('w:fzf_pushd') ? w:fzf_pushd.dir : expand('%:p:h') let cwd = exists('w:fzf_pushd') ? w:fzf_pushd.dir : expand('%:p:h')
for item in a:lines for item in a:lines
if item[0] != '~' && item !~ (s:is_win ? '^[A-Z]:\' : '^/') if item[0] != '~' && item !~ (s:is_win ? '^[A-Z]:\' : '^/')
let item = join([cwd, item], (s:is_win ? '\' : '/')) let sep = s:is_win ? '\' : '/'
let item = join([cwd, item], cwd[len(cwd)-1] == sep ? '' : sep)
endif endif
if empty if empty
execute 'e' s:escape(item) execute 'e' s:escape(item)
@ -404,7 +438,7 @@ try
let prefix = '( '.source.' )|' let prefix = '( '.source.' )|'
elseif type == 3 elseif type == 3
let temps.input = s:fzf_tempname() let temps.input = s:fzf_tempname()
call writefile(map(source, '<SID>enc_to_cp(v:val)'), temps.input) call writefile(source, temps.input)
let prefix = (s:is_win ? 'type ' : 'cat ').fzf#shellescape(temps.input).'|' let prefix = (s:is_win ? 'type ' : 'cat ').fzf#shellescape(temps.input).'|'
else else
throw 'Invalid source type' throw 'Invalid source type'
@ -432,6 +466,7 @@ try
elseif use_term elseif use_term
let optstr .= ' --no-height' let optstr .= ' --no-height'
endif endif
let optstr .= s:border_opt(get(dict, 'window', 0))
let command = prefix.(use_tmux ? s:fzf_tmux(dict) : fzf_exec).' '.optstr.' > '.temps.result let command = prefix.(use_tmux ? s:fzf_tmux(dict) : fzf_exec).' '.optstr.' > '.temps.result
if use_term if use_term
@ -610,7 +645,8 @@ function! s:execute(dict, command, use_height, temps) abort
endif endif
let exit_status = v:shell_error let exit_status = v:shell_error
redraw! redraw!
return s:exit_handler(exit_status, command) ? s:collect(a:temps) : [] let lines = s:collect(a:temps)
return s:exit_handler(exit_status, command) ? lines : []
endfunction endfunction
function! s:execute_tmux(dict, command, temps) abort function! s:execute_tmux(dict, command, temps) abort
@ -624,7 +660,8 @@ function! s:execute_tmux(dict, command, temps) abort
call system(command) call system(command)
let exit_status = v:shell_error let exit_status = v:shell_error
redraw! redraw!
return s:exit_handler(exit_status, command) ? s:collect(a:temps) : [] let lines = s:collect(a:temps)
return s:exit_handler(exit_status, command) ? lines : []
endfunction endfunction
function! s:calc_size(max, val, dict) function! s:calc_size(max, val, dict)
@ -656,6 +693,32 @@ function! s:getpos()
return {'tab': tabpagenr(), 'win': winnr(), 'winid': win_getid(), 'cnt': winnr('$'), 'tcnt': tabpagenr('$')} return {'tab': tabpagenr(), 'win': winnr(), 'winid': win_getid(), 'cnt': winnr('$'), 'tcnt': tabpagenr('$')}
endfunction endfunction
function! s:border_opt(window)
if type(a:window) != type({})
return ''
endif
" Border style
let style = tolower(get(a:window, 'border', 'rounded'))
if !has_key(a:window, 'border') && !get(a:window, 'rounded', 1)
let style = 'sharp'
endif
if style == 'none' || style == 'no'
return ''
endif
" For --border styles, we need fzf 0.24.0 or above
call fzf#exec('0.24.0')
let opt = ' --border=' . style
if has_key(a:window, 'highlight')
let color = s:get_color('fg', a:window.highlight)
if len(color)
let opt .= ' --color=border:' . color
endif
endif
return opt
endfunction
function! s:split(dict) function! s:split(dict)
let directions = { let directions = {
\ 'up': ['topleft', 'resize', &lines], \ 'up': ['topleft', 'resize', &lines],
@ -745,12 +808,12 @@ function! s:execute_term(dict, command, temps) abort
execute self.winrest execute self.winrest
endif endif
let lines = s:collect(self.temps)
if !s:exit_handler(a:code, self.command, 1) if !s:exit_handler(a:code, self.command, 1)
return return
endif endif
call s:pushd(self.dict) call s:pushd(self.dict)
let lines = s:collect(self.temps)
call s:callback(self.dict, lines) call s:callback(self.dict, lines)
call self.switch_back(s:getpos() == self.ppos) call self.switch_back(s:getpos() == self.ppos)
endfunction endfunction
@ -775,6 +838,7 @@ function! s:execute_term(dict, command, temps) abort
let term_opts.curwin = 1 let term_opts.curwin = 1
endif endif
let fzf.buf = term_start([&shell, &shellcmdflag, command], term_opts) let fzf.buf = term_start([&shell, &shellcmdflag, command], term_opts)
call setbufvar(fzf.buf, '&termwinkey', '<c-z>')
if is_popup && exists('#TerminalWinOpen') if is_popup && exists('#TerminalWinOpen')
doautocmd <nomodeline> TerminalWinOpen doautocmd <nomodeline> TerminalWinOpen
endif endif
@ -782,6 +846,7 @@ function! s:execute_term(dict, command, temps) abort
call term_wait(fzf.buf, 20) call term_wait(fzf.buf, 20)
endif endif
endif endif
tnoremap <buffer> <c-z> <nop>
finally finally
call s:dopopd() call s:dopopd()
endtry endtry
@ -848,33 +913,22 @@ if has('nvim')
endfunction endfunction
else else
function! s:create_popup(hl, opts) abort function! s:create_popup(hl, opts) abort
let is_frame = has_key(a:opts, 'border')
let s:popup_create = {buf -> popup_create(buf, #{ let s:popup_create = {buf -> popup_create(buf, #{
\ line: a:opts.row, \ line: a:opts.row,
\ col: a:opts.col, \ col: a:opts.col,
\ minwidth: a:opts.width, \ minwidth: a:opts.width,
\ maxwidth: a:opts.width,
\ minheight: a:opts.height, \ minheight: a:opts.height,
\ zindex: 50 - is_frame, \ maxheight: a:opts.height,
\ zindex: 1000,
\ })} \ })}
if is_frame autocmd TerminalOpen * ++once call s:popup_create(str2nr(expand('<abuf>')))
let id = s:popup_create('')
call setwinvar(id, '&wincolor', a:hl)
call setbufline(winbufnr(id), 1, a:opts.border)
execute 'autocmd BufWipeout * ++once call popup_close('..id..')'
return winbufnr(id)
else
autocmd TerminalOpen * ++once call s:popup_create(str2nr(expand('<abuf>')))
endif
endfunction endfunction
endif endif
function! s:popup(opts) abort function! s:popup(opts) abort
" Support ambiwidth == 'double'
let ambidouble = &ambiwidth == 'double' ? 2 : 1
" Size and position " Size and position
let width = min([max([8, a:opts.width > 1 ? a:opts.width : float2nr(&columns * a:opts.width)]), &columns]) let width = min([max([8, a:opts.width > 1 ? a:opts.width : float2nr(&columns * a:opts.width)]), &columns])
let width += width % ambidouble
let height = min([max([4, a:opts.height > 1 ? a:opts.height : float2nr(&lines * a:opts.height)]), &lines - has('nvim')]) let height = min([max([4, a:opts.height > 1 ? a:opts.height : float2nr(&lines * a:opts.height)]), &lines - has('nvim')])
let row = float2nr(get(a:opts, 'yoffset', 0.5) * (&lines - height)) let row = float2nr(get(a:opts, 'yoffset', 0.5) * (&lines - height))
let col = float2nr(get(a:opts, 'xoffset', 0.5) * (&columns - width)) let col = float2nr(get(a:opts, 'xoffset', 0.5) * (&columns - width))
@ -885,45 +939,9 @@ function! s:popup(opts) abort
let row += !has('nvim') let row += !has('nvim')
let col += !has('nvim') let col += !has('nvim')
" Border style
let style = tolower(get(a:opts, 'border', 'rounded'))
if !has_key(a:opts, 'border') && !get(a:opts, 'rounded', 1)
let style = 'sharp'
endif
if style =~ 'vertical\|left\|right'
let mid = style == 'vertical' ? '│' .. repeat(' ', width - 2 * ambidouble) .. '│' :
\ style == 'left' ? '│' .. repeat(' ', width - 1 * ambidouble)
\ : repeat(' ', width - 1 * ambidouble) .. '│'
let border = repeat([mid], height)
let shift = { 'row': 0, 'col': style == 'right' ? 0 : 2, 'width': style == 'vertical' ? -4 : -2, 'height': 0 }
elseif style =~ 'horizontal\|top\|bottom'
let hor = repeat('─', width / ambidouble)
let mid = repeat(' ', width)
let border = style == 'horizontal' ? [hor] + repeat([mid], height - 2) + [hor] :
\ style == 'top' ? [hor] + repeat([mid], height - 1)
\ : repeat([mid], height - 1) + [hor]
let shift = { 'row': style == 'bottom' ? 0 : 1, 'col': 0, 'width': 0, 'height': style == 'horizontal' ? -2 : -1 }
else
let edges = style == 'sharp' ? ['┌', '┐', '└', '┘'] : ['╭', '╮', '╰', '╯']
let bar = repeat('─', width / ambidouble - 2)
let top = edges[0] .. bar .. edges[1]
let mid = '│' .. repeat(' ', width - 2 * ambidouble) .. '│'
let bot = edges[2] .. bar .. edges[3]
let border = [top] + repeat([mid], height - 2) + [bot]
let shift = { 'row': 1, 'col': 2, 'width': -4, 'height': -2 }
endif
let highlight = get(a:opts, 'highlight', 'Comment')
let frame = s:create_popup(highlight, {
\ 'row': row, 'col': col, 'width': width, 'height': height, 'border': border
\ })
call s:create_popup('Normal', { call s:create_popup('Normal', {
\ 'row': row + shift.row, 'col': col + shift.col, 'width': width + shift.width, 'height': height + shift.height \ 'row': row, 'col': col, 'width': width, 'height': height
\ }) \ })
if has('nvim')
execute 'autocmd BufWipeout <buffer> bwipeout '..frame
endif
endfunction endfunction
let s:default_action = { let s:default_action = {

View File

@ -46,9 +46,20 @@ __fzf_comprun() {
fi fi
} }
__fzf_orig_completion_filter() { __fzf_orig_completion() {
sed 's/^\(.*-F\) *\([^ ]*\).* \([^ ]*\)$/export _fzf_orig_completion_\3="\1 %s \3 #\2"; [[ "\1" = *" -o nospace "* ]] \&\& [[ ! "$__fzf_nospace_commands" = *" \3 "* ]] \&\& __fzf_nospace_commands="$__fzf_nospace_commands \3 ";/' | local l comp f cmd
awk -F= '{OFS = FS} {gsub(/[^A-Za-z0-9_= ;]/, "_", $1);}1' while read -r l; do
if [[ "$l" =~ ^(.*\ -F)\ *([^ ]*).*\ ([^ ]*)$ ]]; then
comp="${BASH_REMATCH[1]}"
f="${BASH_REMATCH[2]}"
cmd="${BASH_REMATCH[3]}"
[[ "$f" = _fzf_* ]] && continue
printf -v "_fzf_orig_completion_${cmd//[^A-Za-z0-9_]/_}" "%s" "${comp} %s ${cmd} #${f}"
if [[ "$l" = *" -o nospace "* ]] && [[ ! "$__fzf_nospace_commands" = *" $cmd "* ]]; then
__fzf_nospace_commands="$__fzf_nospace_commands $cmd "
fi
fi
done
} }
_fzf_opts_completion() { _fzf_opts_completion() {
@ -137,7 +148,7 @@ _fzf_handle_dynamic_completion() {
ret=$? ret=$?
# _completion_loader may not have updated completion for the command # _completion_loader may not have updated completion for the command
if [ "$(complete -p "$orig_cmd" 2> /dev/null)" != "$orig_complete" ]; then if [ "$(complete -p "$orig_cmd" 2> /dev/null)" != "$orig_complete" ]; then
eval "$(complete | command grep " -F.* $orig_cmd$" | __fzf_orig_completion_filter)" __fzf_orig_completion < <(complete -p "$orig_cmd" 2> /dev/null)
if [[ "$__fzf_nospace_commands" = *" $orig_cmd "* ]]; then if [[ "$__fzf_nospace_commands" = *" $orig_cmd "* ]]; then
eval "${orig_complete/ -F / -o nospace -F }" eval "${orig_complete/ -F / -o nospace -F }"
else else
@ -306,9 +317,7 @@ a_cmds="
svn tar unzip zip" svn tar unzip zip"
# Preserve existing completion # Preserve existing completion
eval "$(complete | __fzf_orig_completion < <(complete -p $d_cmds $a_cmds 2> /dev/null)
sed -E '/-F/!d; / _fzf/d; '"/ ($(echo $d_cmds $a_cmds | sed 's/ /|/g; s/+/\\+/g'))$/"'!d' |
__fzf_orig_completion_filter)"
if type _completion_loader > /dev/null 2>&1; then if type _completion_loader > /dev/null 2>&1; then
_fzf_completion_loader=1 _fzf_completion_loader=1
@ -353,7 +362,7 @@ _fzf_setup_completion() {
return 1 return 1
fi fi
shift shift
eval "$(complete -p "$@" 2> /dev/null | grep -v "$fn" | __fzf_orig_completion_filter)" __fzf_orig_completion < <(complete -p "$@" 2> /dev/null)
for cmd in "$@"; do for cmd in "$@"; do
case "$kind" in case "$kind" in
dir) __fzf_defc "$cmd" "$fn" "-o nospace -o dirnames" ;; dir) __fzf_defc "$cmd" "$fn" "-o nospace -o dirnames" ;;

View File

@ -9,9 +9,6 @@ import (
) )
const ( const (
// Current version
version = "0.23.1"
// Core // Core
coordinatorDelayMax time.Duration = 100 * time.Millisecond coordinatorDelayMax time.Duration = 100 * time.Millisecond
coordinatorDelayStep time.Duration = 10 * time.Millisecond coordinatorDelayStep time.Duration = 10 * time.Millisecond

View File

@ -43,7 +43,7 @@ Matcher -> EvtHeader -> Terminal (update header)
*/ */
// Run starts fzf // Run starts fzf
func Run(opts *Options, revision string) { func Run(opts *Options, version string, revision string) {
sort := opts.Sort > 0 sort := opts.Sort > 0
sortCriteria = opts.Criteria sortCriteria = opts.Criteria

View File

@ -58,8 +58,10 @@ const usage = `usage: fzf [options]
(default: 10) (default: 10)
--layout=LAYOUT Choose layout: [default|reverse|reverse-list] --layout=LAYOUT Choose layout: [default|reverse|reverse-list]
--border[=STYLE] Draw border around the finder --border[=STYLE] Draw border around the finder
[rounded|sharp|horizontal] (default: rounded) [rounded|sharp|horizontal|vertical|
--margin=MARGIN Screen margin (TRBL / TB,RL / T,RL,B / T,R,B,L) top|bottom|left|right] (default: rounded)
--margin=MARGIN Screen margin (TRBL | TB,RL | T,RL,B | T,R,B,L)
--padding=PADDING Padding inside border (TRBL | TB,RL | T,RL,B | T,R,B,L)
--info=STYLE Finder info style [default|inline|hidden] --info=STYLE Finder info style [default|inline|hidden]
--prompt=STR Input prompt (default: '> ') --prompt=STR Input prompt (default: '> ')
--pointer=STR Pointer to the current line (default: '>') --pointer=STR Pointer to the current line (default: '>')
@ -220,6 +222,7 @@ type Options struct {
Header []string Header []string
HeaderLines int HeaderLines int
Margin [4]sizeSpec Margin [4]sizeSpec
Padding [4]sizeSpec
BorderShape tui.BorderShape BorderShape tui.BorderShape
Unicode bool Unicode bool
Tabstop int Tabstop int
@ -280,6 +283,7 @@ func defaultOptions() *Options {
Header: make([]string, 0), Header: make([]string, 0),
HeaderLines: 0, HeaderLines: 0,
Margin: defaultMargin(), Margin: defaultMargin(),
Padding: defaultMargin(),
Unicode: true, Unicode: true,
Tabstop: 8, Tabstop: 8,
ClearOnExit: true, ClearOnExit: true,
@ -421,11 +425,21 @@ func parseBorder(str string, optional bool) tui.BorderShape {
return tui.BorderSharp return tui.BorderSharp
case "horizontal": case "horizontal":
return tui.BorderHorizontal return tui.BorderHorizontal
case "vertical":
return tui.BorderVertical
case "top":
return tui.BorderTop
case "bottom":
return tui.BorderBottom
case "left":
return tui.BorderLeft
case "right":
return tui.BorderRight
default: default:
if optional && str == "" { if optional && str == "" {
return tui.BorderRounded return tui.BorderRounded
} }
errorExit("invalid border style (expected: rounded|sharp|horizontal)") errorExit("invalid border style (expected: rounded|sharp|horizontal|vertical|top|bottom|left|right)")
} }
return tui.BorderNone return tui.BorderNone
} }
@ -606,7 +620,7 @@ func parseTheme(defaultTheme *tui.ColorTheme, str string) *tui.ColorTheme {
case "16": case "16":
theme = dupeTheme(tui.Default16) theme = dupeTheme(tui.Default16)
case "bw", "no": case "bw", "no":
theme = nil theme = tui.NoColorTheme()
default: default:
fail := func() { fail := func() {
errorExit("invalid color specification: " + str) errorExit("invalid color specification: " + str)
@ -1065,10 +1079,10 @@ func parsePreviewWindow(opts *previewOpts, input string) {
} }
} }
func parseMargin(margin string) [4]sizeSpec { func parseMargin(opt string, margin string) [4]sizeSpec {
margins := strings.Split(margin, ",") margins := strings.Split(margin, ",")
checked := func(str string) sizeSpec { checked := func(str string) sizeSpec {
return parseSize(str, 49, "margin") return parseSize(str, 49, opt)
} }
switch len(margins) { switch len(margins) {
case 1: case 1:
@ -1088,7 +1102,7 @@ func parseMargin(margin string) [4]sizeSpec {
checked(margins[0]), checked(margins[1]), checked(margins[0]), checked(margins[1]),
checked(margins[2]), checked(margins[3])} checked(margins[2]), checked(margins[3])}
default: default:
errorExit("invalid margin: " + margin) errorExit("invalid " + opt + ": " + margin)
} }
return defaultMargin() return defaultMargin()
} }
@ -1313,6 +1327,8 @@ func parseOptions(opts *Options, allArgs []string) {
opts.Height = sizeSpec{} opts.Height = sizeSpec{}
case "--no-margin": case "--no-margin":
opts.Margin = defaultMargin() opts.Margin = defaultMargin()
case "--no-padding":
opts.Padding = defaultMargin()
case "--no-border": case "--no-border":
opts.BorderShape = tui.BorderNone opts.BorderShape = tui.BorderNone
case "--border": case "--border":
@ -1324,7 +1340,12 @@ func parseOptions(opts *Options, allArgs []string) {
opts.Unicode = true opts.Unicode = true
case "--margin": case "--margin":
opts.Margin = parseMargin( opts.Margin = parseMargin(
"margin",
nextString(allArgs, &i, "margin required (TRBL / TB,RL / T,RL,B / T,R,B,L)")) nextString(allArgs, &i, "margin required (TRBL / TB,RL / T,RL,B / T,R,B,L)"))
case "--padding":
opts.Padding = parseMargin(
"padding",
nextString(allArgs, &i, "padding required (TRBL / TB,RL / T,RL,B / T,R,B,L)"))
case "--tabstop": case "--tabstop":
opts.Tabstop = nextInt(allArgs, &i, "tab stop required") opts.Tabstop = nextInt(allArgs, &i, "tab stop required")
case "--clear": case "--clear":
@ -1393,7 +1414,9 @@ func parseOptions(opts *Options, allArgs []string) {
} else if match, value := optString(arg, "--preview-window="); match { } else if match, value := optString(arg, "--preview-window="); match {
parsePreviewWindow(&opts.Preview, value) parsePreviewWindow(&opts.Preview, value)
} else if match, value := optString(arg, "--margin="); match { } else if match, value := optString(arg, "--margin="); match {
opts.Margin = parseMargin(value) opts.Margin = parseMargin("margin", value)
} else if match, value := optString(arg, "--padding="); match {
opts.Padding = parseMargin("padding", value)
} else if match, value := optString(arg, "--tabstop="); match { } else if match, value := optString(arg, "--tabstop="); match {
opts.Tabstop = atoi(value) opts.Tabstop = atoi(value)
} else if match, value := optString(arg, "--hscroll-off="); match { } else if match, value := optString(arg, "--hscroll-off="); match {

View File

@ -119,6 +119,7 @@ type Terminal struct {
ansi bool ansi bool
tabstop int tabstop int
margin [4]sizeSpec margin [4]sizeSpec
padding [4]sizeSpec
strong tui.Attr strong tui.Attr
unicode bool unicode bool
borderShape tui.BorderShape borderShape tui.BorderShape
@ -472,6 +473,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
printQuery: opts.PrintQuery, printQuery: opts.PrintQuery,
history: opts.History, history: opts.History,
margin: opts.Margin, margin: opts.Margin,
padding: opts.Padding,
unicode: opts.Unicode, unicode: opts.Unicode,
borderShape: opts.BorderShape, borderShape: opts.BorderShape,
cleanExit: opts.ClearOnExit, cleanExit: opts.ClearOnExit,
@ -526,7 +528,6 @@ func (t *Terminal) parsePrompt(prompt string) (func(), int) {
blankState := ansiOffset{[2]int32{int32(loc[0]), int32(loc[1])}, ansiState{-1, -1, tui.AttrClear}} blankState := ansiOffset{[2]int32{int32(loc[0]), int32(loc[1])}, ansiState{-1, -1, tui.AttrClear}}
if item.colors != nil { if item.colors != nil {
lastColor := (*item.colors)[len(*item.colors)-1] lastColor := (*item.colors)[len(*item.colors)-1]
fmt.Println(lastColor.offset[1], int32(loc[1]))
if lastColor.offset[1] < int32(loc[1]) { if lastColor.offset[1] < int32(loc[1]) {
blankState.offset[0] = lastColor.offset[1] blankState.offset[0] = lastColor.offset[1]
colors := append(*item.colors, blankState) colors := append(*item.colors, blankState)
@ -653,7 +654,7 @@ func (t *Terminal) displayWidth(runes []rune) int {
} }
const ( const (
minWidth = 16 minWidth = 4
minHeight = 4 minHeight = 4
maxDisplayWidthCalc = 1024 maxDisplayWidthCalc = 1024
@ -670,34 +671,64 @@ func calculateSize(base int, size sizeSpec, occupied int, minSize int, pad int)
func (t *Terminal) resizeWindows() { func (t *Terminal) resizeWindows() {
screenWidth := t.tui.MaxX() screenWidth := t.tui.MaxX()
screenHeight := t.tui.MaxY() screenHeight := t.tui.MaxY()
marginInt := [4]int{}
t.prevLines = make([]itemLine, screenHeight) t.prevLines = make([]itemLine, screenHeight)
for idx, sizeSpec := range t.margin {
if sizeSpec.percent { marginInt := [4]int{} // TRBL
paddingInt := [4]int{} // TRBL
sizeSpecToInt := func(index int, spec sizeSpec) int {
if spec.percent {
var max float64 var max float64
if idx%2 == 0 { if index%2 == 0 {
max = float64(screenHeight) max = float64(screenHeight)
} else { } else {
max = float64(screenWidth) max = float64(screenWidth)
} }
marginInt[idx] = int(max * sizeSpec.size * 0.01) return int(max * spec.size * 0.01)
} else {
marginInt[idx] = int(sizeSpec.size)
} }
return int(spec.size)
}
for idx, sizeSpec := range t.padding {
paddingInt[idx] = sizeSpecToInt(idx, sizeSpec)
}
extraMargin := [4]int{} // TRBL
for idx, sizeSpec := range t.margin {
switch t.borderShape { switch t.borderShape {
case tui.BorderHorizontal: case tui.BorderHorizontal:
marginInt[idx] += 1 - idx%2 extraMargin[idx] += 1 - idx%2
case tui.BorderVertical:
extraMargin[idx] += 2 * (idx % 2)
case tui.BorderTop:
if idx == 0 {
extraMargin[idx]++
}
case tui.BorderRight:
if idx == 1 {
extraMargin[idx] += 2
}
case tui.BorderBottom:
if idx == 2 {
extraMargin[idx]++
}
case tui.BorderLeft:
if idx == 3 {
extraMargin[idx] += 2
}
case tui.BorderRounded, tui.BorderSharp: case tui.BorderRounded, tui.BorderSharp:
marginInt[idx] += 1 + idx%2 extraMargin[idx] += 1 + idx%2
} }
marginInt[idx] = sizeSpecToInt(idx, sizeSpec) + extraMargin[idx]
} }
adjust := func(idx1 int, idx2 int, max int, min int) { adjust := func(idx1 int, idx2 int, max int, min int) {
if max >= min { if max >= min {
margin := marginInt[idx1] + marginInt[idx2] margin := marginInt[idx1] + marginInt[idx2] + paddingInt[idx1] + paddingInt[idx2]
if max-margin < min { if max-margin < min {
desired := max - min desired := max - min
marginInt[idx1] = desired * marginInt[idx1] / margin paddingInt[idx1] = desired * paddingInt[idx1] / margin
marginInt[idx2] = desired * marginInt[idx2] / margin paddingInt[idx2] = desired * paddingInt[idx2] / margin
marginInt[idx1] = util.Max(extraMargin[idx1], desired*marginInt[idx1]/margin)
marginInt[idx2] = util.Max(extraMargin[idx2], desired*marginInt[idx2]/margin)
} }
} }
} }
@ -735,19 +766,41 @@ func (t *Terminal) resizeWindows() {
switch t.borderShape { switch t.borderShape {
case tui.BorderHorizontal: case tui.BorderHorizontal:
t.border = t.tui.NewWindow( t.border = t.tui.NewWindow(
marginInt[0]-1, marginInt[0]-1, marginInt[3], width, height+2,
marginInt[3],
width,
height+2,
false, tui.MakeBorderStyle(tui.BorderHorizontal, t.unicode)) false, tui.MakeBorderStyle(tui.BorderHorizontal, t.unicode))
case tui.BorderVertical:
t.border = t.tui.NewWindow(
marginInt[0], marginInt[3]-2, width+4, height,
false, tui.MakeBorderStyle(tui.BorderVertical, t.unicode))
case tui.BorderTop:
t.border = t.tui.NewWindow(
marginInt[0]-1, marginInt[3], width, height+1,
false, tui.MakeBorderStyle(tui.BorderTop, t.unicode))
case tui.BorderBottom:
t.border = t.tui.NewWindow(
marginInt[0], marginInt[3], width, height+1,
false, tui.MakeBorderStyle(tui.BorderBottom, t.unicode))
case tui.BorderLeft:
t.border = t.tui.NewWindow(
marginInt[0], marginInt[3]-2, width+2, height,
false, tui.MakeBorderStyle(tui.BorderLeft, t.unicode))
case tui.BorderRight:
t.border = t.tui.NewWindow(
marginInt[0], marginInt[3], width+2, height,
false, tui.MakeBorderStyle(tui.BorderRight, t.unicode))
case tui.BorderRounded, tui.BorderSharp: case tui.BorderRounded, tui.BorderSharp:
t.border = t.tui.NewWindow( t.border = t.tui.NewWindow(
marginInt[0]-1, marginInt[0]-1, marginInt[3]-2, width+4, height+2,
marginInt[3]-2,
width+4,
height+2,
false, tui.MakeBorderStyle(t.borderShape, t.unicode)) false, tui.MakeBorderStyle(t.borderShape, t.unicode))
} }
// Add padding
for idx, val := range paddingInt {
marginInt[idx] += val
}
width = screenWidth - marginInt[1] - marginInt[3]
height = screenHeight - marginInt[0] - marginInt[2]
noBorder := tui.MakeBorderStyle(tui.BorderNone, t.unicode) noBorder := tui.MakeBorderStyle(tui.BorderNone, t.unicode)
if previewVisible { if previewVisible {
createPreviewWindow := func(y int, x int, w int, h int) { createPreviewWindow := func(y int, x int, w int, h int) {
@ -769,17 +822,19 @@ func (t *Terminal) resizeWindows() {
t.pwindow = t.tui.NewWindow(y, x, pwidth, pheight, true, noBorder) t.pwindow = t.tui.NewWindow(y, x, pwidth, pheight, true, noBorder)
} }
verticalPad := 2 verticalPad := 2
minPreviewHeight := 3
if t.preview.border == tui.BorderNone { if t.preview.border == tui.BorderNone {
verticalPad = 0 verticalPad = 0
minPreviewHeight = 1
} }
switch t.preview.position { switch t.preview.position {
case posUp: case posUp:
pheight := calculateSize(height, t.preview.size, minHeight, 3, verticalPad) pheight := calculateSize(height, t.preview.size, minHeight, minPreviewHeight, verticalPad)
t.window = t.tui.NewWindow( t.window = t.tui.NewWindow(
marginInt[0]+pheight, marginInt[3], width, height-pheight, false, noBorder) marginInt[0]+pheight, marginInt[3], width, height-pheight, false, noBorder)
createPreviewWindow(marginInt[0], marginInt[3], width, pheight) createPreviewWindow(marginInt[0], marginInt[3], width, pheight)
case posDown: case posDown:
pheight := calculateSize(height, t.preview.size, minHeight, 3, verticalPad) pheight := calculateSize(height, t.preview.size, minHeight, minPreviewHeight, verticalPad)
t.window = t.tui.NewWindow( t.window = t.tui.NewWindow(
marginInt[0], marginInt[3], width, height-pheight, false, noBorder) marginInt[0], marginInt[3], width, height-pheight, false, noBorder)
createPreviewWindow(marginInt[0]+height-pheight, marginInt[3], width, pheight) createPreviewWindow(marginInt[0]+height-pheight, marginInt[3], width, pheight)
@ -1222,6 +1277,7 @@ func (t *Terminal) renderPreviewText(unchanged bool) {
} }
var ansi *ansiState var ansi *ansiState
for _, line := range t.previewer.lines { for _, line := range t.previewer.lines {
line = strings.TrimSuffix(line, "\n")
if lineNo >= height || t.pwindow.Y() == height-1 && t.pwindow.X() > 0 { if lineNo >= height || t.pwindow.Y() == height-1 && t.pwindow.X() > 0 {
t.previewed.filled = true t.previewed.filled = true
break break
@ -1252,6 +1308,7 @@ func (t *Terminal) renderPreviewText(unchanged bool) {
if unchanged && lineNo == 0 { if unchanged && lineNo == 0 {
break break
} }
t.pwindow.Fill("\n")
} }
lineNo++ lineNo++
} }
@ -1823,13 +1880,9 @@ func (t *Terminal) Loop() {
reader := bufio.NewReader(out) reader := bufio.NewReader(out)
eofChan := make(chan bool) eofChan := make(chan bool)
finishChan := make(chan bool, 1) finishChan := make(chan bool, 1)
reapChan := make(chan bool)
err := cmd.Start() err := cmd.Start()
reaps := 0 if err == nil {
if err != nil { reapChan := make(chan bool)
t.reqBox.Set(reqPreviewDisplay, previewResult{version, []string{err.Error()}, 0, ""})
} else {
reaps = 2
lineChan := make(chan eachLine) lineChan := make(chan eachLine)
// Goroutine 1 reads process output // Goroutine 1 reads process output
go func() { go func() {
@ -1842,6 +1895,7 @@ func (t *Terminal) Loop() {
} }
eofChan <- true eofChan <- true
}() }()
// Goroutine 2 periodically requests rendering // Goroutine 2 periodically requests rendering
go func(version int64) { go func(version int64) {
lines := []string{} lines := []string{}
@ -1883,42 +1937,47 @@ func (t *Terminal) Loop() {
ticker.Stop() ticker.Stop()
reapChan <- true reapChan <- true
}(version) }(version)
}
// Goroutine 3 is responsible for cancelling running preview command // Goroutine 3 is responsible for cancelling running preview command
go func(version int64) { go func(version int64) {
timer := time.NewTimer(previewDelayed) timer := time.NewTimer(previewDelayed)
Loop: Loop:
for { for {
select { select {
case <-timer.C: case <-timer.C:
t.reqBox.Set(reqPreviewDelayed, version) t.reqBox.Set(reqPreviewDelayed, version)
case code := <-t.killChan: case code := <-t.killChan:
if code != exitCancel { if code != exitCancel {
util.KillCommand(cmd)
os.Exit(code)
} else {
timer := time.NewTimer(previewCancelWait)
select {
case <-timer.C:
util.KillCommand(cmd) util.KillCommand(cmd)
case <-finishChan: os.Exit(code)
} else {
timer := time.NewTimer(previewCancelWait)
select {
case <-timer.C:
util.KillCommand(cmd)
case <-finishChan:
}
timer.Stop()
} }
timer.Stop() break Loop
case <-finishChan:
break Loop
} }
break Loop
case <-finishChan:
break Loop
} }
} timer.Stop()
timer.Stop() reapChan <- true
reapChan <- true }(version)
}(version)
<-eofChan <-eofChan // Goroutine 1 finished
cmd.Wait() // NOTE: We should not call Wait before EOF cmd.Wait() // NOTE: We should not call Wait before EOF
finishChan <- true finishChan <- true // Tell Goroutine 3 to stop
for i := 0; i < reaps; i++ { <-reapChan // Goroutine 2 and 3 finished
<-reapChan <-reapChan
} else {
// Failed to start the command. Report the error immediately.
t.reqBox.Set(reqPreviewDisplay, previewResult{version, []string{err.Error()}, 0, ""})
} }
cleanTemporaryFiles() cleanTemporaryFiles()
} else { } else {
t.reqBox.Set(reqPreviewDisplay, previewResult{version, nil, 0, ""}) t.reqBox.Set(reqPreviewDisplay, previewResult{version, nil, 0, ""})

View File

@ -653,15 +653,46 @@ func (w *LightWindow) drawBorder() {
case BorderRounded, BorderSharp: case BorderRounded, BorderSharp:
w.drawBorderAround() w.drawBorderAround()
case BorderHorizontal: case BorderHorizontal:
w.drawBorderHorizontal() w.drawBorderHorizontal(true, true)
case BorderVertical:
w.drawBorderVertical(true, true)
case BorderTop:
w.drawBorderHorizontal(true, false)
case BorderBottom:
w.drawBorderHorizontal(false, true)
case BorderLeft:
w.drawBorderVertical(true, false)
case BorderRight:
w.drawBorderVertical(false, true)
} }
} }
func (w *LightWindow) drawBorderHorizontal() { func (w *LightWindow) drawBorderHorizontal(top, bottom bool) {
w.Move(0, 0) if top {
w.CPrint(ColBorder, repeat(w.border.horizontal, w.width)) w.Move(0, 0)
w.Move(w.height-1, 0) w.CPrint(ColBorder, repeat(w.border.horizontal, w.width))
w.CPrint(ColBorder, repeat(w.border.horizontal, w.width)) }
if bottom {
w.Move(w.height-1, 0)
w.CPrint(ColBorder, repeat(w.border.horizontal, w.width))
}
}
func (w *LightWindow) drawBorderVertical(left, right bool) {
width := w.width - 2
if !left || !right {
width++
}
for y := 0; y < w.height; y++ {
w.Move(y, 0)
if left {
w.CPrint(ColBorder, string(w.border.vertical))
}
w.CPrint(ColBorder, repeat(' ', width))
if right {
w.CPrint(ColBorder, string(w.border.vertical))
}
}
} }
func (w *LightWindow) drawBorderAround() { func (w *LightWindow) drawBorderAround() {

View File

@ -583,7 +583,8 @@ func (w *TcellWindow) CFill(fg Color, bg Color, a Attr, str string) FillReturn {
} }
func (w *TcellWindow) drawBorder() { func (w *TcellWindow) drawBorder() {
if w.borderStyle.shape == BorderNone { shape := w.borderStyle.shape
if shape == BorderNone {
return return
} }
@ -603,17 +604,32 @@ func (w *TcellWindow) drawBorder() {
style = w.normal.style() style = w.normal.style()
} }
for x := left; x < right; x++ { switch shape {
_screen.SetContent(x, top, w.borderStyle.horizontal, nil, style) case BorderRounded, BorderSharp, BorderHorizontal, BorderTop:
_screen.SetContent(x, bot-1, w.borderStyle.horizontal, nil, style) for x := left; x < right; x++ {
_screen.SetContent(x, top, w.borderStyle.horizontal, nil, style)
}
} }
switch shape {
if w.borderStyle.shape != BorderHorizontal { case BorderRounded, BorderSharp, BorderHorizontal, BorderBottom:
for x := left; x < right; x++ {
_screen.SetContent(x, bot-1, w.borderStyle.horizontal, nil, style)
}
}
switch shape {
case BorderRounded, BorderSharp, BorderVertical, BorderLeft:
for y := top; y < bot; y++ { for y := top; y < bot; y++ {
_screen.SetContent(left, y, w.borderStyle.vertical, nil, style) _screen.SetContent(left, y, w.borderStyle.vertical, nil, style)
}
}
switch shape {
case BorderRounded, BorderSharp, BorderVertical, BorderRight:
for y := top; y < bot; y++ {
_screen.SetContent(right-1, y, w.borderStyle.vertical, nil, style) _screen.SetContent(right-1, y, w.borderStyle.vertical, nil, style)
} }
}
switch shape {
case BorderRounded, BorderSharp:
_screen.SetContent(left, top, w.borderStyle.topLeft, nil, style) _screen.SetContent(left, top, w.borderStyle.topLeft, nil, style)
_screen.SetContent(right-1, top, w.borderStyle.topRight, nil, style) _screen.SetContent(right-1, top, w.borderStyle.topRight, nil, style)
_screen.SetContent(left, bot-1, w.borderStyle.bottomLeft, nil, style) _screen.SetContent(left, bot-1, w.borderStyle.bottomLeft, nil, style)

View File

@ -259,6 +259,11 @@ const (
BorderRounded BorderRounded
BorderSharp BorderSharp
BorderHorizontal BorderHorizontal
BorderVertical
BorderTop
BorderBottom
BorderLeft
BorderRight
) )
type BorderStyle struct { type BorderStyle struct {
@ -549,6 +554,9 @@ func initTheme(theme *ColorTheme, baseTheme *ColorTheme, forceBlack bool) {
func initPalette(theme *ColorTheme) { func initPalette(theme *ColorTheme) {
pair := func(fg, bg ColorAttr) ColorPair { pair := func(fg, bg ColorAttr) ColorPair {
if fg.Color == colDefault && (fg.Attr&Reverse) > 0 {
bg.Color = colDefault
}
return ColorPair{fg.Color, bg.Color, fg.Attr} return ColorPair{fg.Color, bg.Color, fg.Attr}
} }
blank := theme.Fg blank := theme.Fg

View File

@ -4,7 +4,5 @@ root = true
end_of_line = lf end_of_line = lf
insert_final_newline = true insert_final_newline = true
charset = utf-8 charset = utf-8
indent_size = 2
[*.sh] indent_style = space
indent_size = 4
indent_style = tab

View File

@ -1,4 +1,5 @@
# Plugin owners # Plugin owners
plugins/gitfast/ @felipec plugins/aws/ @maksyms
plugins/sdk/ @rgoldberg plugins/git-lfs/ @vietduc01100001
plugins/git-lfs/ @vietduc01100001 plugins/gitfast/ @felipec
plugins/sdk/ @rgoldberg

View File

@ -1,7 +1,7 @@
--- ---
name: Feature request name: Feature request
about: Suggest a feature for Oh My Zsh about: Suggest a feature for Oh My Zsh
labels: 'feature' labels: 'Feature'
--- ---

View File

@ -1,7 +1,7 @@
--- ---
name: Support name: Support
about: Request support for any problem you're having with Oh My Zsh about: Request support for any problem you're having with Oh My Zsh
labels: 'support' labels: 'Support'
--- ---

View File

@ -134,6 +134,7 @@ zmodload zsh/langinfo
# -P causes spaces to be encoded as '%20' instead of '+' # -P causes spaces to be encoded as '%20' instead of '+'
function omz_urlencode() { function omz_urlencode() {
emulate -L zsh emulate -L zsh
local -a opts
zparseopts -D -E -a opts r m P zparseopts -D -E -a opts r m P
local in_str=$1 local in_str=$1

View File

@ -6,7 +6,8 @@ function omz_history {
if [[ -n "$clear" ]]; then if [[ -n "$clear" ]]; then
# if -c provided, clobber the history file # if -c provided, clobber the history file
echo -n >| "$HISTFILE" echo -n >| "$HISTFILE"
echo >&2 History file deleted. Reload the session to see its effects. fc -p "$HISTFILE"
echo >&2 History file deleted.
elif [[ -n "$list" ]]; then elif [[ -n "$list" ]]; then
# if -l provided, run as if calling `fc' directly # if -l provided, run as if calling `fc' directly
builtin fc "$@" builtin fc "$@"
@ -36,3 +37,4 @@ setopt hist_expire_dups_first # delete duplicates first when HISTFILE size excee
setopt hist_ignore_dups # ignore duplicated commands history list setopt hist_ignore_dups # ignore duplicated commands history list
setopt hist_ignore_space # ignore commands that start with space setopt hist_ignore_space # ignore commands that start with space
setopt hist_verify # show command with history expansion to user before running it setopt hist_verify # show command with history expansion to user before running it
setopt share_history # share command history data

View File

@ -3,7 +3,7 @@
This plugin provides completion support for [awscli](https://docs.aws.amazon.com/cli/latest/reference/index.html) This plugin provides completion support for [awscli](https://docs.aws.amazon.com/cli/latest/reference/index.html)
and a few utilities to manage AWS profiles and display them in the prompt. and a few utilities to manage AWS profiles and display them in the prompt.
To use it, make sure [jq](https://stedolan.github.io/jq/download/) is installed, and add `aws` to the plugins array in your zshrc file. To use it, add `aws` to the plugins array in your zshrc file.
```zsh ```zsh
plugins=(... aws) plugins=(... aws)
@ -15,6 +15,13 @@ plugins=(... aws)
It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI. It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI.
Run `asp` without arguments to clear the profile. Run `asp` without arguments to clear the profile.
* `acp [<profile>]`: in addition to `asp` functionality, it actually changes the profile by
assuming the role specified in the `<profile>` configuration. It supports MFA and sets
`$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if obtained. It
requires the roles to be configured as per the
[official guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html).
Run `acp` without arguments to clear the profile.
* `agp`: gets the current value of `$AWS_PROFILE`. * `agp`: gets the current value of `$AWS_PROFILE`.
* `aws_change_access_key`: changes the AWS access key of a profile. * `aws_change_access_key`: changes the AWS access key of a profile.
@ -33,6 +40,36 @@ plugins=(... aws)
The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
the current `$AWS_PROFILE`. It uses two variables to control how that is shown: the current `$AWS_PROFILE`. It uses two variables to control how that is shown:
- ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`. * ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
- ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`. * ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
## Configuration
[Configuration and credential file settings](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) by AWS
### Scenario: IAM roles with a source profile and MFA authentication
Source profile credentials in `~/.aws/credentials`:
```
[source-profile-name]
aws_access_key_id = ...
aws_secret_access_key = ...
```
Role configuration in `~/.aws/config`:
```
[profile source-profile-name]
mfa_serial = arn:aws:iam::111111111111:mfa/myuser
region = us-east-1
output = json
[profile profile-with-role]
role_arn = arn:aws:iam::9999999999999:role/myrole
mfa_serial = arn:aws:iam::111111111111:mfa/myuser
source_profile = source-profile-name
region = us-east-1
output = json
```

View File

@ -5,7 +5,7 @@ function agp() {
# AWS profile selection # AWS profile selection
function asp() { function asp() {
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE
echo AWS profile cleared. echo AWS profile cleared.
return return
fi fi
@ -18,60 +18,101 @@ function asp() {
return 1 return 1
fi fi
local exists="$(aws configure get aws_access_key_id --profile $1)" export AWS_DEFAULT_PROFILE=$1
local role_arn="$(aws configure get role_arn --profile $1)" export AWS_PROFILE=$1
local aws_access_key_id="" export AWS_EB_PROFILE=$1
local aws_secret_access_key="" }
local aws_session_token=""
if [[ -n $exists || -n $role_arn ]]; then # AWS profile switch
if [[ -n $role_arn ]]; then function acp() {
local mfa_serial="$(aws configure get mfa_serial --profile $1)" if [[ -z "$1" ]]; then
local mfa_token="" unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE
local mfa_opt="" unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
if [[ -n $mfa_serial ]]; then echo AWS profile cleared.
echo "Please enter your MFA token for $mfa_serial:" return
read mfa_token fi
echo "Please enter the session duration in seconds (900-43200; default: 3600, which is the default maximum for a role):"
read sess_duration local -a available_profiles
if [[ -z $sess_duration ]]; then available_profiles=($(aws_profiles))
sess_duration = 3600 if [[ -z "${available_profiles[(r)$1]}" ]]; then
fi echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2
mfa_opt="--serial-number $mfa_serial --token-code $mfa_token --duration-seconds $sess_duration" echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2
return 1
fi
local profile="$1"
# Get fallback credentials for if the aws command fails or no command is run
local aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)"
local aws_secret_access_key="$(aws configure get aws_secret_access_key --profile $profile)"
local aws_session_token="$(aws configure get aws_session_token --profile $profile)"
# First, if the profile has MFA configured, lets get the token and session duration
local mfa_serial="$(aws configure get mfa_serial --profile $profile)"
if [[ -n "$mfa_serial" ]]; then
local -a mfa_opt
local mfa_token sess_duration
echo -n "Please enter your MFA token for $mfa_serial: "
read -r mfa_token
echo -n "Please enter the session duration in seconds (900-43200; default: 3600, which is the default maximum for a role): "
read -r sess_duration
mfa_opt=(--serial-number "$mfa_serial" --token-code "$mfa_token" --duration-seconds "${sess_duration:-3600}")
# Now see whether we need to just MFA for the current role, or assume a different one
local role_arn="$(aws configure get role_arn --profile $profile)"
if [[ -n "$role_arn" ]]; then
# Means we need to assume a specified role
aws_command=(aws sts assume-role --role-arn "$role_arn" "${mfa_opt[@]}")
# Check whether external_id is configured to use while assuming the role
local external_id="$(aws configure get external_id --profile "$profile")"
if [[ -n "$external_id" ]]; then
aws_command+=(--external-id "$external_id")
fi fi
local ext_id="$(aws configure get external_id --profile $1)" # Get source profile to use to assume role
local extid_opt="" local source_profile="$(aws configure get source_profile --profile "$profile")"
if [[ -n $ext_id ]]; then aws_command+=(--profile="${source_profile:-profile}" --role-session-name "${source_profile:-profile}")
extid_opt="--external-id $ext_id"
fi
local profile=$1 echo "Assuming role $role_arn using profile ${source_profile:-profile}"
local source_profile="$(aws configure get source_profile --profile $1)"
if [[ -n $source_profile ]]; then
profile=$source_profile
fi
echo "Assuming role $role_arn using profile $profile"
local assume_cmd=(aws sts assume-role "--profile=$profile" "--role-arn $role_arn" "--role-session-name "$profile"" "$mfa_opt" "$extid_opt")
local JSON="$(eval ${assume_cmd[@]})"
aws_access_key_id="$(echo $JSON | jq -r '.Credentials.AccessKeyId')"
aws_secret_access_key="$(echo $JSON | jq -r '.Credentials.SecretAccessKey')"
aws_session_token="$(echo $JSON | jq -r '.Credentials.SessionToken')"
else else
aws_access_key_id="$(aws configure get aws_access_key_id --profile $1)" # Means we only need to do MFA
aws_secret_access_key="$(aws configure get aws_secret_access_key --profile $1)" aws_command=(aws sts get-session-token --profile="$profile" "${mfa_opt[@]}")
aws_session_token="" echo "Obtaining session token for profile $profile"
fi fi
export AWS_DEFAULT_PROFILE=$1 # Format output of aws command for easier processing
export AWS_PROFILE=$1 aws_command+=(--query '[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]' --output text)
export AWS_EB_PROFILE=$1
export AWS_ACCESS_KEY_ID=$aws_access_key_id
export AWS_SECRET_ACCESS_KEY=$aws_secret_access_key
[[ -z "$aws_session_token" ]] && unset AWS_SESSION_TOKEN || export AWS_SESSION_TOKEN=$aws_session_token
echo "Switched to AWS Profile: $1"; # Run the aws command to obtain credentials
local -a credentials
credentials=(${(ps:\t:)"$(${aws_command[@]})"})
if [[ -n "$credentials" ]]; then
aws_access_key_id="${credentials[1]}"
aws_secret_access_key="${credentials[2]}"
aws_session_token="${credentials[3]}"
fi
fi
# Switch to AWS profile
if [[ -n "${aws_access_key_id}" && -n "$aws_secret_access_key" ]]; then
export AWS_DEFAULT_PROFILE="$profile"
export AWS_PROFILE="$profile"
export AWS_EB_PROFILE="$profile"
export AWS_ACCESS_KEY_ID="$aws_access_key_id"
export AWS_SECRET_ACCESS_KEY="$aws_secret_access_key"
if [[ -n "$aws_session_token" ]]; then
export AWS_SESSION_TOKEN="$aws_session_token"
else
unset AWS_SESSION_TOKEN
fi
echo "Switched to AWS Profile: $profile"
fi fi
} }
@ -99,7 +140,7 @@ function aws_profiles() {
function _aws_profiles() { function _aws_profiles() {
reply=($(aws_profiles)) reply=($(aws_profiles))
} }
compctl -K _aws_profiles asp aws_change_access_key compctl -K _aws_profiles asp acp aws_change_access_key
# AWS prompt # AWS prompt
function aws_prompt_info() { function aws_prompt_info() {
@ -107,7 +148,7 @@ function aws_prompt_info() {
echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_SUFFIX:=>}" echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_SUFFIX:=>}"
} }
if [ "$SHOW_AWS_PROMPT" != false ]; then if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then
RPROMPT='$(aws_prompt_info)'"$RPROMPT" RPROMPT='$(aws_prompt_info)'"$RPROMPT"
fi fi

View File

@ -18,10 +18,7 @@ if [[ "$OSTYPE" = darwin* ]]; then
} }
function battery_pct() { function battery_pct() {
local battery_status="$(ioreg -rc AppleSmartBattery)" pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
local -i capacity=$(sed -n -e '/MaxCapacity/s/^.*"MaxCapacity"\ =\ //p' <<< $battery_status)
local -i current=$(sed -n -e '/CurrentCapacity/s/^.*"CurrentCapacity"\ =\ //p' <<< $battery_status)
echo $(( current * 100 / capacity ))
} }
function battery_pct_remaining() { function battery_pct_remaining() {

View File

@ -16,3 +16,17 @@ You can also try to color other pages by prefixing the respective command with `
```zsh ```zsh
colored git help clone colored git help clone
``` ```
## Customization
The plugin declares global associative array `less_termcap`, which maps termcap capabilities to escape
sequences for the `less` pager. This mapping can be further customized by the user after the plugin is
loaded. Check out sources for more.
For example: `less_termcap[md]` maps to `LESS_TERMCAP_md` which is the escape sequence that tells `less`
how to print something in bold. It's currently shown in bold red, but if you want to change it, you
can redefine `less_termcap[md]` in your zshrc file, after OMZ is sourced:
```zsh
less_termcap[md]="${fg_bold[blue]}" # this tells less to print bold text in bold blue
```

View File

@ -1,39 +1,48 @@
if [[ "$OSTYPE" = solaris* ]] # Requires colors autoload.
then # See termcap(5).
if [[ ! -x "$HOME/bin/nroff" ]]
then # Set up once, and then reuse. This way it supports user overrides after the
mkdir -p "$HOME/bin" # plugin is loaded.
cat > "$HOME/bin/nroff" <<EOF typeset -AHg less_termcap
#!/bin/sh
if [ -n "\$_NROFF_U" -a "\$1,\$2,\$3" = "-u0,-Tlp,-man" ]; then # bold & blinking mode
shift less_termcap[mb]="${fg_bold[red]}"
exec /usr/bin/nroff -u\$_NROFF_U "\$@" less_termcap[md]="${fg_bold[red]}"
fi less_termcap[me]="${reset_color}"
#-- Some other invocation of nroff # standout mode
exec /usr/bin/nroff "\$@" less_termcap[so]="${fg_bold[yellow]}${bg[blue]}"
EOF less_termcap[se]="${reset_color}"
chmod +x "$HOME/bin/nroff" # underlining
fi less_termcap[us]="${fg_bold[green]}"
fi less_termcap[ue]="${reset_color}"
# Absolute path to this file's directory.
typeset __colored_man_pages_dir="${0:A:h}"
function colored() { function colored() {
command env \ local -a environment
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \ # Convert associative array to plain array of NAME=VALUE items.
LESS_TERMCAP_me=$(printf "\e[0m") \ local k v
LESS_TERMCAP_se=$(printf "\e[0m") \ for k v in "${(@kv)less_termcap}"; do
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ environment+=( "LESS_TERMCAP_${k}=${v}" )
LESS_TERMCAP_ue=$(printf "\e[0m") \ done
LESS_TERMCAP_us=$(printf "\e[1;32m") \
PAGER="${commands[less]:-$PAGER}" \ # Prefer `less` whenever available, since we specifically configured
_NROFF_U=1 \ # environment for it.
PATH="$HOME/bin:$PATH" \ environment+=( PAGER="${commands[less]:-$PAGER}" )
"$@"
# See ./nroff script.
if [[ "$OSTYPE" = solaris* ]]; then
environment+=( PATH="${__colored_man_pages_dir}:$PATH" )
fi
command env $environment "$@"
} }
# Colorize man and dman/debman (from debian-goodies) # Colorize man and dman/debman (from debian-goodies)
function man \ function man \
dman \ dman \
debman { debman {
colored $0 "$@" colored $0 "$@"
} }

View File

@ -0,0 +1,12 @@
#!/bin/sh
# The whole point of this wrapper is to replace emboldening factor -u0 with
# -u1 under certain circumstances on Solaris.
if [ "$1,$2,$3" = "-u0,-Tlp,-man" ]; then
shift
exec /usr/bin/nroff -u1 "$@"
else
# Some other invocation of nroff
exec /usr/bin/nroff "$@"
fi

View File

@ -6,7 +6,8 @@ alias cless="colorize_less"
ZSH_COLORIZE_PLUGIN_PATH=$0:A ZSH_COLORIZE_PLUGIN_PATH=$0:A
colorize_check_requirements() { colorize_check_requirements() {
local available_tools=("chroma" "pygmentize") local -a available_tools
available_tools=("chroma" "pygmentize")
if [ -z "$ZSH_COLORIZE_TOOL" ]; then if [ -z "$ZSH_COLORIZE_TOOL" ]; then
if (( $+commands[pygmentize] )); then if (( $+commands[pygmentize] )); then

View File

@ -154,10 +154,10 @@ unset -f setup_using_opensuse_package setup_using_debian_package setup_using_bas
if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
if (( $+commands[rg] )); then if (( $+commands[rg] )); then
export FZF_DEFAULT_COMMAND='rg --files --hidden' export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git/*"'
elif (( $+commands[fd] )); then elif (( $+commands[fd] )); then
export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git' export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git'
elif (( $+commands[ag] )); then elif (( $+commands[ag] )); then
export FZF_DEFAULT_COMMAND='ag -l --hidden -g ""' export FZF_DEFAULT_COMMAND='ag -l --hidden -g "" --ignore .git'
fi fi
fi fi

View File

@ -31,11 +31,14 @@ function work_in_progress() {
# Check if main exists and use instead of master # Check if main exists and use instead of master
function git_main_branch() { function git_main_branch() {
if [[ -n "$(git branch --list main)" ]]; then local branch
echo main for branch in main trunk; do
else if command git show-ref -q --verify refs/heads/$branch; then
echo master echo $branch
fi return
fi
done
echo master
} }
# #

View File

@ -27,19 +27,26 @@ zstyle -T ':completion:*:*:git:*' tag-order && \
zstyle -s ":completion:*:*:git:*" script script zstyle -s ":completion:*:*:git:*" script script
if [ -z "$script" ]; then if [ -z "$script" ]; then
local -a locations local -a locations
local e local e bash_completion
bash_completion=$(pkg-config --variable=completionsdir bash-completion 2>/dev/null) ||
bash_completion='/usr/share/bash-completion/completions/'
locations=( locations=(
"$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash "$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
"$HOME/.local/share/bash-completion/completions/git" "$HOME/.local/share/bash-completion/completions/git"
"$(pkg-config --variable=completionsdir bash-completion)"/git "$bash_completion/git"
'/usr/share/bash-completion/completions/git'
'/etc/bash_completion.d/git' # old debian '/etc/bash_completion.d/git' # old debian
) )
for e in $locations; do for e in $locations; do
test -f $e && script="$e" && break test -f $e && script="$e" && break
done done
fi fi
local old_complete="$functions[complete]"
functions[complete]=:
GIT_SOURCING_ZSH_COMPLETION=y . "$script" GIT_SOURCING_ZSH_COMPLETION=y . "$script"
functions[complete]="$old_complete"
__gitcomp () __gitcomp ()
{ {
@ -105,21 +112,6 @@ __gitcomp_nl ()
compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0 compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0
} }
__gitcomp_nl_append ()
{
emulate -L zsh
compset -P '*[=:]'
compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0
}
__gitcomp_file_direct ()
{
emulate -L zsh
compadd -f -- ${(f)1} && _ret=0
}
__gitcomp_file () __gitcomp_file ()
{ {
emulate -L zsh emulate -L zsh
@ -127,6 +119,21 @@ __gitcomp_file ()
compadd -f -p "${2-}" -- ${(f)1} && _ret=0 compadd -f -p "${2-}" -- ${(f)1} && _ret=0
} }
__gitcomp_direct_append ()
{
__gitcomp_direct "$@"
}
__gitcomp_nl_append ()
{
__gitcomp_nl "$@"
}
__gitcomp_file_direct ()
{
__gitcomp_file "$1" ""
}
_git_zsh () _git_zsh ()
{ {
__gitcomp "v1.0" __gitcomp "v1.0"

View File

@ -3585,7 +3585,6 @@ __git_func_wrap ()
# This is NOT a public function; use at your own risk. # This is NOT a public function; use at your own risk.
__git_complete () __git_complete ()
{ {
test -n "$ZSH_VERSION" && return
local wrapper="__git_wrap${2}" local wrapper="__git_wrap${2}"
eval "$wrapper () { __git_func_wrap $2 ; }" eval "$wrapper () { __git_func_wrap $2 ; }"
complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \ complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
@ -3607,8 +3606,7 @@ if ! git --list-cmds=main >/dev/null 2>&1; then
{ {
case "$1" in case "$1" in
--list-cmds=*) --list-cmds=*)
IFS=, read -r -a cmds <<< "${1##--list-cmds=}" while read -r -d ',' x; do
for x in ${cmds[@]}; do
case "$x" in case "$x" in
nohelpers) nohelpers)
;; ;;
@ -3620,7 +3618,7 @@ if ! git --list-cmds=main >/dev/null 2>&1; then
echo ${__git_cmds[$x]} echo ${__git_cmds[$x]}
;; ;;
esac esac
done done <<< "${1##--list-cmds=},"
return return
;; ;;
esac esac

View File

@ -9,40 +9,48 @@
# ------- # -------
# #
# * Dongweiming <ciici123@gmail.com> # * Dongweiming <ciici123@gmail.com>
# * Subhaditya Nath <github.com/subnut>
# * Marc Cornellà <github.com/mcornella>
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
__sudo-replace-buffer() {
local old=$1 new=$2 space=${2:+ }
if [[ ${#LBUFFER} -le ${#old} ]]; then
RBUFFER="${space}${BUFFER#$old }"
LBUFFER="${new}"
else
LBUFFER="${new}${space}${LBUFFER#$old }"
fi
}
sudo-command-line() { sudo-command-line() {
[[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)" [[ -z $BUFFER ]] && LBUFFER="$(fc -ln -1)"
# Save beginning space # Save beginning space
local WHITESPACE="" local WHITESPACE=""
if [[ ${LBUFFER:0:1} == " " ]] ; then if [[ ${LBUFFER:0:1} = " " ]]; then
WHITESPACE=" " WHITESPACE=" "
LBUFFER="${LBUFFER:1}" LBUFFER="${LBUFFER:1}"
fi fi
if [[ -n $EDITOR && $BUFFER == $EDITOR\ * ]]; then # Get the first part of the typed command and check if it's an alias to $EDITOR
if [[ ${#LBUFFER} -le ${#EDITOR} ]]; then # If so, locally change $EDITOR to the alias so that it matches below
RBUFFER=" ${BUFFER#$EDITOR }" if [[ -n "$EDITOR" ]]; then
LBUFFER="sudoedit" local cmd="${${(Az)BUFFER}[1]}"
else if [[ "${aliases[$cmd]} " = (\$EDITOR|$EDITOR)\ * ]]; then
LBUFFER="sudoedit ${LBUFFER#$EDITOR }" local EDITOR="$cmd"
fi
elif [[ $BUFFER == sudoedit\ * ]]; then
if [[ ${#LBUFFER} -le 8 ]]; then
RBUFFER=" ${BUFFER#sudoedit }"
LBUFFER="$EDITOR"
else
LBUFFER="$EDITOR ${LBUFFER#sudoedit }"
fi
elif [[ $BUFFER == sudo\ * ]]; then
if [[ ${#LBUFFER} -le 4 ]]; then
RBUFFER="${BUFFER#sudo }"
LBUFFER=""
else
LBUFFER="${LBUFFER#sudo }"
fi fi
fi
if [[ -n $EDITOR && $BUFFER = $EDITOR\ * ]]; then
__sudo-replace-buffer "$EDITOR" "sudoedit"
elif [[ -n $EDITOR && $BUFFER = \$EDITOR\ * ]]; then
__sudo-replace-buffer "\$EDITOR" "sudoedit"
elif [[ $BUFFER = sudoedit\ * ]]; then
__sudo-replace-buffer "sudoedit" "$EDITOR"
elif [[ $BUFFER = sudo\ * ]]; then
__sudo-replace-buffer "sudo" ""
else else
LBUFFER="sudo $LBUFFER" LBUFFER="sudo $LBUFFER"
fi fi
@ -50,7 +58,9 @@ sudo-command-line() {
# Preserve beginning space # Preserve beginning space
LBUFFER="${WHITESPACE}${LBUFFER}" LBUFFER="${WHITESPACE}${LBUFFER}"
} }
zle -N sudo-command-line zle -N sudo-command-line
# Defined shortcut keys: [Esc] [Esc] # Defined shortcut keys: [Esc] [Esc]
bindkey -M emacs '\e\e' sudo-command-line bindkey -M emacs '\e\e' sudo-command-line
bindkey -M vicmd '\e\e' sudo-command-line bindkey -M vicmd '\e\e' sudo-command-line

View File

@ -2,6 +2,10 @@
[The Fuck](https://github.com/nvbn/thefuck) plugin — magnificent app which corrects your previous console command. [The Fuck](https://github.com/nvbn/thefuck) plugin — magnificent app which corrects your previous console command.
To use it, add thefuck to the plugins array of your zshrc file:
plugins=(... thefuck)
## Usage ## Usage
Press `ESC` twice to correct previous console command. Press `ESC` twice to correct previous console command.

View File

@ -37,6 +37,9 @@
# #
set -e set -e
# Track if $ZSH was provided
custom_zsh=${ZSH:+yes}
# Default settings # Default settings
ZSH=${ZSH:-~/.oh-my-zsh} ZSH=${ZSH:-~/.oh-my-zsh}
REPO=${REPO:-ohmyzsh/ohmyzsh} REPO=${REPO:-ohmyzsh/ohmyzsh}
@ -53,12 +56,16 @@ command_exists() {
command -v "$@" >/dev/null 2>&1 command -v "$@" >/dev/null 2>&1
} }
error() { fmt_error() {
echo ${RED}"Error: $@"${RESET} >&2 echo ${RED}"Error: $@"${RESET} >&2
} }
underline() { fmt_underline() {
echo "$(printf '\033[4m')$@$(printf '\033[24m')" echo "$(printf '\033[4m')$@$(printf '\033[24m')"
}
fmt_code() {
echo "\`$(printf '\033[38;5;247m')$@${RESET}\`"
} }
setup_color() { setup_color() {
@ -81,71 +88,71 @@ setup_color() {
} }
setup_ohmyzsh() { setup_ohmyzsh() {
# Prevent the cloned repository from having insecure permissions. Failing to do # Prevent the cloned repository from having insecure permissions. Failing to do
# so causes compinit() calls to fail with "command not found: compdef" errors # so causes compinit() calls to fail with "command not found: compdef" errors
# for users with insecure umasks (e.g., "002", allowing group writability). Note # for users with insecure umasks (e.g., "002", allowing group writability). Note
# that this will be ignored under Cygwin by default, as Windows ACLs take # that this will be ignored under Cygwin by default, as Windows ACLs take
# precedence over umasks except for filesystems mounted with option "noacl". # precedence over umasks except for filesystems mounted with option "noacl".
umask g-w,o-w umask g-w,o-w
echo "${BLUE}Cloning Oh My Zsh...${RESET}" echo "${BLUE}Cloning Oh My Zsh...${RESET}"
command_exists git || { command_exists git || {
error "git is not installed" fmt_error "git is not installed"
exit 1 exit 1
} }
if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then
error "Windows/MSYS Git is not supported on Cygwin" fmt_error "Windows/MSYS Git is not supported on Cygwin"
error "Make sure the Cygwin git package is installed and is first on the \$PATH" fmt_error "Make sure the Cygwin git package is installed and is first on the \$PATH"
exit 1 exit 1
fi fi
git clone -c core.eol=lf -c core.autocrlf=false \ git clone -c core.eol=lf -c core.autocrlf=false \
-c fsck.zeroPaddedFilemode=ignore \ -c fsck.zeroPaddedFilemode=ignore \
-c fetch.fsck.zeroPaddedFilemode=ignore \ -c fetch.fsck.zeroPaddedFilemode=ignore \
-c receive.fsck.zeroPaddedFilemode=ignore \ -c receive.fsck.zeroPaddedFilemode=ignore \
--depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || { --depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || {
error "git clone of oh-my-zsh repo failed" fmt_error "git clone of oh-my-zsh repo failed"
exit 1 exit 1
} }
echo echo
} }
setup_zshrc() { setup_zshrc() {
# Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones # Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones
# with datestamp of installation that moved them aside, so we never actually # with datestamp of installation that moved them aside, so we never actually
# destroy a user's original zshrc # destroy a user's original zshrc
echo "${BLUE}Looking for an existing zsh config...${RESET}" echo "${BLUE}Looking for an existing zsh config...${RESET}"
# Must use this exact name so uninstall.sh can find it # Must use this exact name so uninstall.sh can find it
OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
# Skip this if the user doesn't want to replace an existing .zshrc # Skip this if the user doesn't want to replace an existing .zshrc
if [ $KEEP_ZSHRC = yes ]; then if [ $KEEP_ZSHRC = yes ]; then
echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}" echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}"
return return
fi fi
if [ -e "$OLD_ZSHRC" ]; then if [ -e "$OLD_ZSHRC" ]; then
OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)" OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)"
if [ -e "$OLD_OLD_ZSHRC" ]; then if [ -e "$OLD_OLD_ZSHRC" ]; then
error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}" fmt_error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}"
error "re-run the installer again in a couple of seconds" fmt_error "re-run the installer again in a couple of seconds"
exit 1 exit 1
fi fi
mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}" mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}"
echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \ echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \
"${GREEN}Backing up to ${OLD_OLD_ZSHRC}${RESET}" "${GREEN}Backing up to ${OLD_OLD_ZSHRC}${RESET}"
fi fi
echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}" echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}"
mv ~/.zshrc "$OLD_ZSHRC" mv ~/.zshrc "$OLD_ZSHRC"
fi fi
echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}" echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}"
sed "/^export ZSH=/ c\\ sed "/^export ZSH=/ c\\
export ZSH=\"$ZSH\" export ZSH=\"$ZSH\"
" "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp " "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp
mv -f ~/.zshrc-omztemp ~/.zshrc mv -f ~/.zshrc-omztemp ~/.zshrc
@ -154,146 +161,160 @@ export ZSH=\"$ZSH\"
} }
setup_shell() { setup_shell() {
# Skip setup if the user wants or stdin is closed (not running interactively). # Skip setup if the user wants or stdin is closed (not running interactively).
if [ $CHSH = no ]; then if [ $CHSH = no ]; then
return return
fi fi
# If this user's login shell is already "zsh", do not attempt to switch. # If this user's login shell is already "zsh", do not attempt to switch.
if [ "$(basename "$SHELL")" = "zsh" ]; then if [ "$(basename -- "$SHELL")" = "zsh" ]; then
return return
fi fi
# If this platform doesn't provide a "chsh" command, bail out. # If this platform doesn't provide a "chsh" command, bail out.
if ! command_exists chsh; then if ! command_exists chsh; then
cat <<-EOF cat <<EOF
I can't change your shell automatically because this system does not have chsh. I can't change your shell automatically because this system does not have chsh.
${BLUE}Please manually change your default shell to zsh${RESET} ${BLUE}Please manually change your default shell to zsh${RESET}
EOF EOF
return return
fi fi
echo "${BLUE}Time to change your default shell to zsh:${RESET}" echo "${BLUE}Time to change your default shell to zsh:${RESET}"
# Prompt for user choice on changing the default login shell # Prompt for user choice on changing the default login shell
printf "${YELLOW}Do you want to change your default shell to zsh? [Y/n]${RESET} " printf "${YELLOW}Do you want to change your default shell to zsh? [Y/n]${RESET} "
read opt read opt
case $opt in case $opt in
y*|Y*|"") echo "Changing the shell..." ;; y*|Y*|"") echo "Changing the shell..." ;;
n*|N*) echo "Shell change skipped."; return ;; n*|N*) echo "Shell change skipped."; return ;;
*) echo "Invalid choice. Shell change skipped."; return ;; *) echo "Invalid choice. Shell change skipped."; return ;;
esac esac
# Check if we're running on Termux # Check if we're running on Termux
case "$PREFIX" in case "$PREFIX" in
*com.termux*) termux=true; zsh=zsh ;; *com.termux*) termux=true; zsh=zsh ;;
*) termux=false ;; *) termux=false ;;
esac esac
if [ "$termux" != true ]; then if [ "$termux" != true ]; then
# Test for the right location of the "shells" file # Test for the right location of the "shells" file
if [ -f /etc/shells ]; then if [ -f /etc/shells ]; then
shells_file=/etc/shells shells_file=/etc/shells
elif [ -f /usr/share/defaults/etc/shells ]; then # Solus OS elif [ -f /usr/share/defaults/etc/shells ]; then # Solus OS
shells_file=/usr/share/defaults/etc/shells shells_file=/usr/share/defaults/etc/shells
else else
error "could not find /etc/shells file. Change your default shell manually." fmt_error "could not find /etc/shells file. Change your default shell manually."
return return
fi fi
# Get the path to the right zsh binary # Get the path to the right zsh binary
# 1. Use the most preceding one based on $PATH, then check that it's in the shells file # 1. Use the most preceding one based on $PATH, then check that it's in the shells file
# 2. If that fails, get a zsh path from the shells file, then check it actually exists # 2. If that fails, get a zsh path from the shells file, then check it actually exists
if ! zsh=$(which zsh) || ! grep -qx "$zsh" "$shells_file"; then if ! zsh=$(which zsh) || ! grep -qx "$zsh" "$shells_file"; then
if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -1) || [ ! -f "$zsh" ]; then if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -1) || [ ! -f "$zsh" ]; then
error "no zsh binary found or not present in '$shells_file'" fmt_error "no zsh binary found or not present in '$shells_file'"
error "change your default shell manually." fmt_error "change your default shell manually."
return return
fi fi
fi fi
fi fi
# We're going to change the default shell, so back up the current one # We're going to change the default shell, so back up the current one
if [ -n "$SHELL" ]; then if [ -n "$SHELL" ]; then
echo $SHELL > ~/.shell.pre-oh-my-zsh echo $SHELL > ~/.shell.pre-oh-my-zsh
else else
grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh
fi fi
# Actually change the default shell to zsh # Actually change the default shell to zsh
if ! chsh -s "$zsh"; then if ! chsh -s "$zsh"; then
error "chsh command unsuccessful. Change your default shell manually." fmt_error "chsh command unsuccessful. Change your default shell manually."
else else
export SHELL="$zsh" export SHELL="$zsh"
echo "${GREEN}Shell successfully changed to '$zsh'.${RESET}" echo "${GREEN}Shell successfully changed to '$zsh'.${RESET}"
fi fi
echo echo
} }
main() { main() {
# Run as unattended if stdin is closed # Run as unattended if stdin is not a tty
if [ ! -t 0 ]; then if [ ! -t 0 ]; then
RUNZSH=no RUNZSH=no
CHSH=no CHSH=no
fi fi
# Parse arguments # Parse arguments
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case $1 in case $1 in
--unattended) RUNZSH=no; CHSH=no ;; --unattended) RUNZSH=no; CHSH=no ;;
--skip-chsh) CHSH=no ;; --skip-chsh) CHSH=no ;;
--keep-zshrc) KEEP_ZSHRC=yes ;; --keep-zshrc) KEEP_ZSHRC=yes ;;
esac esac
shift shift
done done
setup_color setup_color
if ! command_exists zsh; then if ! command_exists zsh; then
echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first." echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first."
exit 1 exit 1
fi fi
if [ -d "$ZSH" ]; then if [ -d "$ZSH" ]; then
cat <<-EOF echo "${YELLOW}The \$ZSH folder already exists ($ZSH).${RESET}"
${YELLOW}You already have Oh My Zsh installed.${RESET} if [ "$custom_zsh" = yes ]; then
You'll need to remove '$ZSH' if you want to reinstall. cat <<EOF
EOF
exit 1
fi
setup_ohmyzsh You ran the installer with the \$ZSH setting or the \$ZSH variable is
setup_zshrc exported. You have 3 options:
setup_shell
printf "$GREEN" 1. Unset the ZSH variable when calling the installer:
cat <<-'EOF' $(fmt_code "ZSH= sh install.sh")
__ __ 2. Install Oh My Zsh to a directory that doesn't exist yet:
____ / /_ ____ ___ __ __ ____ _____/ /_ $(fmt_code "ZSH=path/to/new/ohmyzsh/folder sh install.sh")
/ __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ 3. (Caution) If the folder doesn't contain important information,
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / you can just remove it with $(fmt_code "rm -r $ZSH")
\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/
/____/ ....is now installed! EOF
else
echo "You'll need to remove it if you want to reinstall."
fi
exit 1
fi
setup_ohmyzsh
setup_zshrc
setup_shell
printf "$GREEN"
cat <<'EOF'
__ __
____ / /_ ____ ___ __ __ ____ _____/ /_
/ __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/
/____/ ....is now installed!
EOF EOF
cat <<-EOF cat <<EOF
Before you scream Oh My Zsh! please look over the ~/.zshrc file to select plugins, themes, and options. Before you scream Oh My Zsh! please look over the ~/.zshrc file to select plugins, themes, and options.
• Follow us on Twitter: $(underline https://twitter.com/ohmyzsh) • Follow us on Twitter: $(fmt_underline https://twitter.com/ohmyzsh)
• Join our Discord server: $(underline https://discord.gg/ohmyzsh) • Join our Discord server: $(fmt_underline https://discord.gg/ohmyzsh)
• Get stickers, shirts, coffee mugs and other swag: $(underline https://shop.planetargon.com/collections/oh-my-zsh) • Get stickers, shirts, coffee mugs and other swag: $(fmt_underline https://shop.planetargon.com/collections/oh-my-zsh)
EOF EOF
printf "$RESET" printf "$RESET"
if [ $RUNZSH = no ]; then if [ $RUNZSH = no ]; then
echo "${YELLOW}Run zsh to try it out.${RESET}" echo "${YELLOW}Run zsh to try it out.${RESET}"
exit exit
fi fi
exec zsh -l exec zsh -l
} }
main "$@" main "$@"

View File

@ -348,7 +348,7 @@ Powerlevel10k.
```zsh ```zsh
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>! ~/.zshrc echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
``` ```
Users in mainland China can use the official mirror on gitee.com for faster download.<br> Users in mainland China can use the official mirror on gitee.com for faster download.<br>
@ -356,7 +356,7 @@ Users in mainland China can use the official mirror on gitee.com for faster down
```zsh ```zsh
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ~/powerlevel10k git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ~/powerlevel10k
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>! ~/.zshrc echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
``` ```
This is the simplest kind of installation and it works even if you are using a plugin manager. Just This is the simplest kind of installation and it works even if you are using a plugin manager. Just
@ -421,14 +421,14 @@ supported by Powerlevel10k.
```zsh ```zsh
brew install romkatv/powerlevel10k/powerlevel10k brew install romkatv/powerlevel10k/powerlevel10k
echo 'source /usr/local/opt/powerlevel10k/powerlevel10k.zsh-theme' >>! ~/.zshrc echo 'source /usr/local/opt/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
``` ```
### Arch Linux ### Arch Linux
```zsh ```zsh
yay -S --noconfirm zsh-theme-powerlevel10k-git yay -S --noconfirm zsh-theme-powerlevel10k-git
echo 'source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme' >>! ~/.zshrc echo 'source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
``` ```
[zsh-theme-powerlevel10k-git](https://aur.archlinux.org/packages/zsh-theme-powerlevel10k-git/) [zsh-theme-powerlevel10k-git](https://aur.archlinux.org/packages/zsh-theme-powerlevel10k-git/)
@ -564,7 +564,7 @@ applications on your system. Configure your terminal to use this font:
- **Guake**: Right Click on an open terminal and open *Preferences*. Under *Appearance* - **Guake**: Right Click on an open terminal and open *Preferences*. Under *Appearance*
tab, uncheck *Use the system fixed width font* (if not already) and select `MesloLGS NF Regular`. tab, uncheck *Use the system fixed width font* (if not already) and select `MesloLGS NF Regular`.
Exit the Preferences dialog by clicking *Close*. Exit the Preferences dialog by clicking *Close*.
- **Alacritty**: Create or open `~/.config/alacritty/alacritty.yml` and and the following section - **Alacritty**: Create or open `~/.config/alacritty/alacritty.yml` and add the following section
to it: to it:
```yaml ```yaml
font: font:
@ -694,10 +694,14 @@ The command to update Powerlevel10k depends on how it was installed.
``` ```
3. Copy `~/powerlevel10k` from the machine connected to the Internet to the one without Internet 3. Copy `~/powerlevel10k` from the machine connected to the Internet to the one without Internet
access. access.
4. Append the following lines to the bottom of `~/.zshrc` on the machine without Internet access: 4. Add `source ~/powerlevel10k/powerlevel10k.zsh-theme` to `~/.zshrc` on the machine without
Internet access:
```zsh ```zsh
source ~/powerlevel10k/powerlevel10k.zsh-theme echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
unset ZSH_THEME ```
5. If `~/.zshrc` on the machine without Internet access sets `ZSH_THEME`, remove that line.
```zsh
sed -i.bak '/^ZSH_THEME=/d' ~/.zshrc
``` ```
To update, remove `~/powerlevel10k` on both machines and repeat steps 1-3. To update, remove `~/powerlevel10k` on both machines and repeat steps 1-3.
@ -725,15 +729,17 @@ Powerlevel10k defines prompt and nothing else. It sets [prompt-related options](
https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/prompt-highlight.png) https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/prompt-highlight.png)
Everything within the highlighted areas on the screenshot is produced by Powerlevel10k. Everything within the highlighted areas on the screenshot is produced by Powerlevel10k.
Powerlevel10k has no control over the terminal content or color outside these areas. Powerlevel10k has no control over the terminal content or colors outside these areas.
Powerlevel10k does not affect: Powerlevel10k does not affect:
- Terminal window title. - Terminal window/tab title.
- Colors used by `ls`. - Colors used by `ls`.
- Content and style of command completions. - The behavior of `git` command.
- The content and style of <kbd>Tab</kbd> completions.
- Command line colors (syntax highlighting, autosuggestions, etc.). - Command line colors (syntax highlighting, autosuggestions, etc.).
- Key bindings. - Key bindings.
- Aliases.
- Prompt parameters other than `PS1` and `RPS1`. - Prompt parameters other than `PS1` and `RPS1`.
- Zsh options other than those [related to prompt]( - Zsh options other than those [related to prompt](
http://zsh.sourceforge.net/Doc/Release/Options.html#Prompting). http://zsh.sourceforge.net/Doc/Release/Options.html#Prompting).
@ -1513,7 +1519,7 @@ theme (so that you end up with no theme) and then installing Powerlevel10k manua
```zsh ```zsh
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>! ~/.zshrc echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
``` ```
This method of installation won't make anything slower or otherwise sub-par. This method of installation won't make anything slower or otherwise sub-par.

View File

@ -62,7 +62,7 @@ applications on your system. Configure your terminal to use this font:
- **Guake**: Right Click on an open terminal and open *Preferences*. Under *Appearance* - **Guake**: Right Click on an open terminal and open *Preferences*. Under *Appearance*
tab, uncheck *Use the system fixed width font* (if not already) and select `MesloLGS NF Regular`. tab, uncheck *Use the system fixed width font* (if not already) and select `MesloLGS NF Regular`.
Exit the Preferences dialog by clicking *Close*. Exit the Preferences dialog by clicking *Close*.
- **Alacritty**: Create or open `~/.config/alacritty/alacritty.yml` and and the following section - **Alacritty**: Create or open `~/.config/alacritty/alacritty.yml` and add the following section
to it: to it:
```yaml ```yaml
font: font:

View File

@ -11,6 +11,12 @@ fi
export LC_ALL=C export LC_ALL=C
if [ -z "${ZSH_VERSION-}" ] && command -v zsh >/dev/null 2>&1; then
case "${BASH_VERSION-}" in
[0-3].*) exec zsh "$0" "$@";;
esac
fi
usage="$(command cat <<\END usage="$(command cat <<\END
Usage: build [-m ARCH] [-c CPU] [-d CMD] [-i IMAGE] [-s] [-w] Usage: build [-m ARCH] [-c CPU] [-d CMD] [-i IMAGE] [-s] [-w]
@ -29,7 +35,7 @@ Options:
succeed; on some operating systems this option is not succeed; on some operating systems this option is not
supported; on others it can have partial effect supported; on others it can have partial effect
-w automatically download tarballs for dependencies if they -w automatically download tarballs for dependencies if they
don't already exist in ./deps; dependencies are described do not already exist in ./deps; dependencies are described
in ./build.info in ./build.info
END END
)" )"
@ -159,10 +165,11 @@ case "$gitstatus_kernel" in
;; ;;
darwin) darwin)
command mkdir -- "$workdir"/lib command mkdir -- "$workdir"/lib
command ln -s -- /usr/local/opt/libiconv/lib/libiconv.a "$workdir"/lib brew_prefix="$(command brew --prefix)"
command ln -s -- "$brew_prefix"/opt/libiconv/lib/libiconv.a "$workdir"/lib
libgit2_cmake_flags="$libgit2_cmake_flags -DUSE_ICONV=ON" libgit2_cmake_flags="$libgit2_cmake_flags -DUSE_ICONV=ON"
libgit2_cflags="$libgit2_cflags -I/usr/local/opt/libiconv/include" libgit2_cflags="$libgit2_cflags -I"$brew_prefix"/opt/libiconv/include"
gitstatus_cxxflags="$gitstatus_cxxflags -I/usr/local/opt/libiconv/include" gitstatus_cxxflags="$gitstatus_cxxflags -I"$brew_prefix"/opt/libiconv/include"
gitstatus_ldlibs="$gitstatus_ldlibs -liconv" gitstatus_ldlibs="$gitstatus_ldlibs -liconv"
gitstatus_ldflags="$gitstatus_ldflags -L${workdir}/lib" gitstatus_ldflags="$gitstatus_ldflags -L${workdir}/lib"
libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=OFF" libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=OFF"

View File

@ -181,9 +181,10 @@ local build='
function build-unix() { function build-unix() {
local intro flags=(-sw) local intro flags=(-sw)
case $2 in case $2 in
linux-ppc64le);; linux-ppc64le) ;;
linux-*) flags+=(-d docker);; linux-*) flags+=(-d docker);;
darwin-*) intro='PATH="/usr/local/bin:$PATH"';; darwin-arm64) intro='PATH="/opt/homebrew/bin:$PATH"';;
darwin-*) intro='PATH="/usr/local/bin:$PATH"';;
esac esac
ssh $1 -- /bin/sh -uex <<<" ssh $1 -- /bin/sh -uex <<<"
$intro $intro

View File

@ -25,6 +25,7 @@ uname_s_glob="msys_nt-10.0"; uname_m_glob="x86_64"; file="gitstatusd-${uname_
# Fallbacks to official gitstatusd binaries. # Fallbacks to official gitstatusd binaries.
uname_s_glob="cygwin_nt-*"; uname_m_glob="i686"; file="gitstatusd-cygwin_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="c96baef70b81b5a1d46adcc9e93721eaf4bdc295562bdd2baf210a6b416b9911"; uname_s_glob="cygwin_nt-*"; uname_m_glob="i686"; file="gitstatusd-cygwin_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="c96baef70b81b5a1d46adcc9e93721eaf4bdc295562bdd2baf210a6b416b9911";
uname_s_glob="cygwin_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-cygwin_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="18b5be49f6eb9ff1cf25e76d6f2333c7402e686e05ce5b88ca107c80504210d8"; uname_s_glob="cygwin_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-cygwin_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="18b5be49f6eb9ff1cf25e76d6f2333c7402e686e05ce5b88ca107c80504210d8";
uname_s_glob="darwin"; uname_m_glob="arm64"; file="gitstatusd-${uname_s}-x86_64"; version="v1.3.1"; sha256="26d582fe9a0b2090c28e84e5e32a6d42d6988cedff51e41ec5f789512c53b0fc";
uname_s_glob="mingw32_nt-*"; uname_m_glob="i686"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="618d2425c6a22fa3762fe6fe252f9ddb4ed9138df1377e48b2f119cd4875f400"; uname_s_glob="mingw32_nt-*"; uname_m_glob="i686"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="618d2425c6a22fa3762fe6fe252f9ddb4ed9138df1377e48b2f119cd4875f400";
uname_s_glob="mingw32_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="bdfae7a7c0fd83d0214a7eabde3b7d8709336bd08697a74d48bea4a04c352676"; uname_s_glob="mingw32_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="bdfae7a7c0fd83d0214a7eabde3b7d8709336bd08697a74d48bea4a04c352676";
uname_s_glob="mingw64_nt-*"; uname_m_glob="i686"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="618d2425c6a22fa3762fe6fe252f9ddb4ed9138df1377e48b2f119cd4875f400"; uname_s_glob="mingw64_nt-*"; uname_m_glob="i686"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="618d2425c6a22fa3762fe6fe252f9ddb4ed9138df1377e48b2f119cd4875f400";

View File

@ -3934,7 +3934,8 @@ function _p9k_vcs_resume() {
} }
function _p9k_vcs_gitstatus() { function _p9k_vcs_gitstatus() {
if [[ $_p9k__refresh_reason == precmd ]]; then if [[ $_p9k__refresh_reason == precmd ]] && (( !_p9k__vcs_called )); then
typeset -gi _p9k__vcs_called=1
if (( $+_p9k__gitstatus_next_dir )); then if (( $+_p9k__gitstatus_next_dir )); then
_p9k__gitstatus_next_dir=$_p9k__cwd_a _p9k__gitstatus_next_dir=$_p9k__cwd_a
else else
@ -5597,6 +5598,8 @@ _p9k_prompt_net_iface_sync() {
} }
function _p9k_set_prompt() { function _p9k_set_prompt() {
local -i _p9k__vcs_called
PROMPT= PROMPT=
RPROMPT= RPROMPT=
[[ $1 == instant_ ]] || PROMPT+='${$((_p9k_on_expand()))+}' [[ $1 == instant_ ]] || PROMPT+='${$((_p9k_on_expand()))+}'
@ -5755,7 +5758,7 @@ _p9k_set_instant_prompt() {
[[ -n $RPROMPT ]] || unset RPROMPT [[ -n $RPROMPT ]] || unset RPROMPT
} }
typeset -gri __p9k_instant_prompt_version=30 typeset -gri __p9k_instant_prompt_version=38
_p9k_dump_instant_prompt() { _p9k_dump_instant_prompt() {
local user=${(%):-%n} local user=${(%):-%n}
@ -5771,7 +5774,7 @@ _p9k_dump_instant_prompt() {
local -i fd local -i fd
sysopen -a -m 600 -o creat,trunc -u fd -- $tmp || return sysopen -a -m 600 -o creat,trunc -u fd -- $tmp || return
{ {
[[ $TERM_PROGRAM == Hyper ]] && local hyper='==' || local hyper='!=' [[ $TERM == (screen*|tmux*) ]] && local screen='-n' || local screen='-z'
local -a display_v=("${_p9k__display_v[@]}") local -a display_v=("${_p9k__display_v[@]}")
local -i i local -i i
for ((i = 6; i <= $#display_v; i+=2)); do display_v[i]=show; done for ((i = 6; i <= $#display_v; i+=2)); do display_v[i]=show; done
@ -5782,14 +5785,16 @@ _p9k_dump_instant_prompt() {
if [[ -r $gitstatus_dir/install.info ]]; then if [[ -r $gitstatus_dir/install.info ]]; then
IFS= read -r gitstatus_header <$gitstatus_dir/install.info || return IFS= read -r gitstatus_header <$gitstatus_dir/install.info || return
fi fi
>&$fd print -r -- '[[ -t 0 && -t 1 && -t 2 && -o interactive && -o zle && -o no_xtrace ]] &&
! (( ${+__p9k_instant_prompt_disabled} || ZSH_SUBSHELL || ${+ZSH_SCRIPT} || ${+ZSH_EXECUTION_STRING} )) || return 0'
>&$fd print -r -- "() { >&$fd print -r -- "() {
$__p9k_intro_no_locale $__p9k_intro_no_locale
(( ! \$+__p9k_instant_prompt_disabled )) || return typeset -gi __p9k_instant_prompt_disabled=1
typeset -gi __p9k_instant_prompt_disabled=1 __p9k_instant_prompt_sourced=$__p9k_instant_prompt_version
[[ \$ZSH_VERSION == ${(q)ZSH_VERSION} && \$ZSH_PATCHLEVEL == ${(q)ZSH_PATCHLEVEL} && [[ \$ZSH_VERSION == ${(q)ZSH_VERSION} && \$ZSH_PATCHLEVEL == ${(q)ZSH_PATCHLEVEL} &&
\$TERM_PROGRAM $hyper 'Hyper' && \$+VTE_VERSION == $+VTE_VERSION && $screen \${(M)TERM:#(screen*|tmux*)} &&
\${#\${(M)VTE_VERSION:#(<1-4602>|4801)}} == ${#${(M)VTE_VERSION:#(<1-4602>|4801)}} &&
\$POWERLEVEL9K_DISABLE_INSTANT_PROMPT != 'true' && \$POWERLEVEL9K_DISABLE_INSTANT_PROMPT != 'true' &&
\$POWERLEVEL9K_INSTANT_PROMPT != 'off' ]] || { __p9k_instant_prompt_sourced=0; return 1; } \$POWERLEVEL9K_INSTANT_PROMPT != 'off' ]] || return
typeset -g __p9k_instant_prompt_param_sig=${(q+)_p9k__param_sig} typeset -g __p9k_instant_prompt_param_sig=${(q+)_p9k__param_sig}
local gitstatus_dir=${(q)gitstatus_dir} local gitstatus_dir=${(q)gitstatus_dir}
local gitstatus_header=${(q)gitstatus_header} local gitstatus_header=${(q)gitstatus_header}
@ -5800,16 +5805,12 @@ _p9k_dump_instant_prompt() {
local -i height=$_POWERLEVEL9K_INSTANT_PROMPT_COMMAND_LINES local -i height=$_POWERLEVEL9K_INSTANT_PROMPT_COMMAND_LINES
local prompt_dir=${(q)prompt_dir}" local prompt_dir=${(q)prompt_dir}"
>&$fd print -r -- ' >&$fd print -r -- '
(( _z4h_can_save_restore_screen == 1 )) && height=0
local real_gitstatus_header local real_gitstatus_header
if [[ -r $gitstatus_dir/install.info ]]; then if [[ -r $gitstatus_dir/install.info ]]; then
IFS= read -r real_gitstatus_header <$gitstatus_dir/install.info || real_gitstatus_header=borked IFS= read -r real_gitstatus_header <$gitstatus_dir/install.info || real_gitstatus_header=borked
fi fi
if [[ $real_gitstatus_header != $gitstatus_header ]]; then [[ $real_gitstatus_header == $gitstatus_header ]] || return
__p9k_instant_prompt_sourced=0
return 1
fi
[[ $ZSH_SUBSHELL == 0 && -z $ZSH_SCRIPT && -z $ZSH_EXECUTION_STRING &&
-t 0 && -t 1 && -t 2 && -o interactive && -o zle && -o no_xtrace ]] || return
zmodload zsh/langinfo zsh/terminfo zsh/system || return zmodload zsh/langinfo zsh/terminfo zsh/system || return
if [[ $langinfo[CODESET] != (utf|UTF)(-|)8 ]]; then if [[ $langinfo[CODESET] != (utf|UTF)(-|)8 ]]; then
local loc_cmd=$commands[locale] local loc_cmd=$commands[locale]
@ -5829,11 +5830,18 @@ _p9k_dump_instant_prompt() {
local prompt_file=$prompt_dir/prompt-${#pwd} local prompt_file=$prompt_dir/prompt-${#pwd}
local key=$pwd:$ssh:${(%):-%#} local key=$pwd:$ssh:${(%):-%#}
local content local content
if [[ ! -e $prompt_file ]]; then
typeset -gi __p9k_instant_prompt_sourced='$__p9k_instant_prompt_version'
return 1
fi
{ content="$(<$prompt_file)" } 2>/dev/null || return { content="$(<$prompt_file)" } 2>/dev/null || return
local tail=${content##*$rs$key$us} local tail=${content##*$rs$key$us}
[[ ${#tail} != ${#content} ]] || return if (( ${#tail} == ${#content} )); then
typeset -gi __p9k_instant_prompt_sourced='$__p9k_instant_prompt_version'
return 1
fi
local P9K_PROMPT=instant local P9K_PROMPT=instant
if [[ $P9K_TTY != old ]]; then' if [[ -z $P9K_TTY || $P9K_TTY == old && -n ${_P9K_TTY:#$TTY} ]]; then'
if (( _POWERLEVEL9K_NEW_TTY_MAX_AGE_SECONDS < 0 )); then if (( _POWERLEVEL9K_NEW_TTY_MAX_AGE_SECONDS < 0 )); then
>&$fd print -r -- ' typeset -gx P9K_TTY=new' >&$fd print -r -- ' typeset -gx P9K_TTY=new'
else else
@ -5848,6 +5856,7 @@ _p9k_dump_instant_prompt() {
fi' fi'
fi fi
>&$fd print -r -- ' fi >&$fd print -r -- ' fi
typeset -gx _P9K_TTY=$TTY
local -i _p9k__empty_line_i=3 _p9k__ruler_i=3 local -i _p9k__empty_line_i=3 _p9k__ruler_i=3
local -A _p9k_display_k=('${(j: :)${(@q)${(kv)_p9k_display_k}}}') local -A _p9k_display_k=('${(j: :)${(@q)${(kv)_p9k_display_k}}}')
local -a _p9k__display_v=('${(j: :)${(@q)display_v}}') local -a _p9k__display_v=('${(j: :)${(@q)display_v}}')
@ -5957,37 +5966,36 @@ _p9k_dump_instant_prompt() {
fi fi
>&$fd print -r -- ' >&$fd print -r -- '
trap "unset -m _p9k__\*; unfunction p10k" EXIT trap "unset -m _p9k__\*; unfunction p10k" EXIT
local -a _p9k_t=("${(@ps:$us:)${tail%%$rs*}}")' local -a _p9k_t=("${(@ps:$us:)${tail%%$rs*}}")
if [[ $+VTE_VERSION == 1 || $TERM_PROGRAM == Hyper ]]; then if [[ $+VTE_VERSION == 1 || $TERM_PROGRAM == Hyper ]] && (( $+commands[stty] )); then
if [[ $TERM_PROGRAM == Hyper ]]; then if [[ $TERM_PROGRAM == Hyper ]]; then
local bad_lines=40 bad_columns=100 local bad_lines=40 bad_columns=100
else else
local bad_lines=24 bad_columns=80 local bad_lines=24 bad_columns=80
fi fi
>&$fd print -r -- ' if (( LINES == bad_lines && COLUMNS == bad_columns )); then
if (( LINES == '$bad_lines' && COLUMNS == '$bad_columns' )); then zmodload -F zsh/stat b:zstat || return
zmodload -F zsh/stat b:zstat || return zmodload zsh/datetime || return
zmodload zsh/datetime || return local -a tty_ctime
local -a tty_ctime if ! zstat -A tty_ctime +ctime -- $TTY 2>/dev/null || (( tty_ctime[1] + 2 > EPOCHREALTIME )); then
if ! zstat -A tty_ctime +ctime -- $TTY 2>/dev/null || (( tty_ctime[1] + 2 > EPOCHREALTIME )); then local -F deadline=$((EPOCHREALTIME+0.025))
local -F deadline=$((EPOCHREALTIME+0.025)) local tty_size
local tty_size while true; do
while true; do if (( EPOCHREALTIME > deadline )) || ! tty_size="$(command stty size 2>/dev/null)" || [[ $tty_size != <->" "<-> ]]; then
if (( EPOCHREALTIME > deadline )) || ! tty_size="$(/bin/stty size 2>/dev/null)" || [[ $tty_size != <->" "<-> ]]; then (( $+_p9k__ruler_i )) || local -i _p9k__ruler_i=1
(( $+_p9k__ruler_i )) || local -i _p9k__ruler_i=1 local _p9k__g= _p9k__'$#_p9k_line_segments_right'r= _p9k__'$#_p9k_line_segments_right'r_frame=
local _p9k__g= _p9k__'$#_p9k_line_segments_right'r= _p9k__'$#_p9k_line_segments_right'r_frame= break
break fi
fi if [[ $tty_size != "$bad_lines $bad_columns" ]]; then
if [[ $tty_size != "'$bad_lines' '$bad_columns'" ]]; then local lines_columns=(${=tty_size})
local lines_columns=(${=tty_size}) local LINES=$lines_columns[1]
local LINES=$lines_columns[1] local COLUMNS=$lines_columns[2]
local COLUMNS=$lines_columns[2] break
break fi
fi done
done fi
fi fi
fi' fi'
fi
(( __p9k_ksh_arrays )) && >&$fd print -r -- ' setopt ksh_arrays' (( __p9k_ksh_arrays )) && >&$fd print -r -- ' setopt ksh_arrays'
(( __p9k_sh_glob )) && >&$fd print -r -- ' setopt sh_glob' (( __p9k_sh_glob )) && >&$fd print -r -- ' setopt sh_glob'
>&$fd print -r -- ' typeset -ga __p9k_used_instant_prompt=("${(@e)_p9k_t[-3,-1]}")' >&$fd print -r -- ' typeset -ga __p9k_used_instant_prompt=("${(@e)_p9k_t[-3,-1]}")'
@ -6012,15 +6020,13 @@ _p9k_dump_instant_prompt() {
fi fi
_p9k__ret=$x _p9k__ret=$x
} }
local out' local out
[[ $+VTE_VERSION == 1 || $TERM_PROGRAM == Hyper ]] && >&$fd print -r -- ' if (( ! $+_p9k__g )); then' if [[ $+VTE_VERSION == 0 && $TERM_PROGRAM != Hyper ]] || (( ! $+_p9k__g )); then
>&$fd print -r -- ' local mark=${(e)PROMPT_EOL_MARK}
local mark=${(e)PROMPT_EOL_MARK} [[ $mark == "%B%S%#%s%b" ]] && _p9k__ret=1 || _p9k_prompt_length $mark
[[ $mark == "%B%S%#%s%b" ]] && _p9k__ret=1 || _p9k_prompt_length $mark local -i fill=$((COLUMNS > _p9k__ret ? COLUMNS - _p9k__ret : 0))
local -i fill=$((COLUMNS > _p9k__ret ? COLUMNS - _p9k__ret : 0)) out+="${(%):-%b%k%f%s%u$mark${(pl.$fill.. .)}$cr%b%k%f%s%u%E}"
out+="${(%):-%b%k%f%s%u$mark${(pl.$fill.. .)}$cr%b%k%f%s%u%E}"' fi
[[ $+VTE_VERSION == 1 || $TERM_PROGRAM == Hyper ]] && >&$fd print -r -- ' fi'
>&$fd print -r -- '
out+="${(pl.$height..$lf.)}$esc${height}A$terminfo[sc]" out+="${(pl.$height..$lf.)}$esc${height}A$terminfo[sc]"
out+=${(%):-"$__p9k_used_instant_prompt[1]$__p9k_used_instant_prompt[2]"} out+=${(%):-"$__p9k_used_instant_prompt[1]$__p9k_used_instant_prompt[2]"}
if [[ -n $__p9k_used_instant_prompt[3] ]]; then if [[ -n $__p9k_used_instant_prompt[3] ]]; then
@ -6040,6 +6046,10 @@ _p9k_dump_instant_prompt() {
exec {__p9k_fd_0}<&0 {__p9k_fd_1}>&1 {__p9k_fd_2}>&2 0<&$fd_null 1>$__p9k_instant_prompt_output exec {__p9k_fd_0}<&0 {__p9k_fd_1}>&1 {__p9k_fd_2}>&2 0<&$fd_null 1>$__p9k_instant_prompt_output
exec 2>&1 {fd_null}>&- exec 2>&1 {fd_null}>&-
typeset -gi __p9k_instant_prompt_active=1 typeset -gi __p9k_instant_prompt_active=1
if (( _z4h_can_save_restore_screen == 1 )); then
typeset -g _z4h_saved_screen
-z4h-save-screen
fi
typeset -g __p9k_instant_prompt_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh typeset -g __p9k_instant_prompt_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh
if builtin source $__p9k_instant_prompt_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then if builtin source $__p9k_instant_prompt_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then
_p9k_preinit _p9k_preinit
@ -6051,6 +6061,10 @@ _p9k_dump_instant_prompt() {
exec 0<&$__p9k_fd_0 1>&$__p9k_fd_1 2>&$__p9k_fd_2 {__p9k_fd_0}>&- {__p9k_fd_1}>&- {__p9k_fd_2}>&- exec 0<&$__p9k_fd_0 1>&$__p9k_fd_1 2>&$__p9k_fd_2 {__p9k_fd_0}>&- {__p9k_fd_1}>&- {__p9k_fd_2}>&-
unset __p9k_fd_0 __p9k_fd_1 __p9k_fd_2 unset __p9k_fd_0 __p9k_fd_1 __p9k_fd_2
typeset -gi __p9k_instant_prompt_erased=1 typeset -gi __p9k_instant_prompt_erased=1
if (( _z4h_can_save_restore_screen == 1 && __p9k_instant_prompt_sourced >= 35 )); then
-z4h-restore-screen
unset _z4h_saved_screen
fi
print -rn -- $terminfo[rc]${(%):-%b%k%f%s%u}$terminfo[ed] print -rn -- $terminfo[rc]${(%):-%b%k%f%s%u}$terminfo[ed]
if [[ -s $__p9k_instant_prompt_output ]]; then if [[ -s $__p9k_instant_prompt_output ]]; then
command cat $__p9k_instant_prompt_output 2>/dev/null command cat $__p9k_instant_prompt_output 2>/dev/null
@ -6081,7 +6095,8 @@ _p9k_dump_instant_prompt() {
zshexit_functions=(_p9k_instant_prompt_cleanup $zshexit_functions) zshexit_functions=(_p9k_instant_prompt_cleanup $zshexit_functions)
precmd_functions=(_p9k_instant_prompt_precmd_first $precmd_functions) precmd_functions=(_p9k_instant_prompt_precmd_first $precmd_functions)
DISABLE_UPDATE_PROMPT=true DISABLE_UPDATE_PROMPT=true
} && unsetopt prompt_cr prompt_sp || true' } && unsetopt prompt_cr prompt_sp && typeset -gi __p9k_instant_prompt_sourced='$__p9k_instant_prompt_version' ||
typeset -gi __p9k_instant_prompt_sourced=${__p9k_instant_prompt_sourced:-0}'
} always { } always {
exec {fd}>&- exec {fd}>&-
} }
@ -6245,6 +6260,10 @@ function _p9k_clear_instant_prompt() {
local -i fill=$((COLUMNS > _p9k__ret ? COLUMNS - _p9k__ret : 0)) local -i fill=$((COLUMNS > _p9k__ret ? COLUMNS - _p9k__ret : 0))
local cr=$'\r' local cr=$'\r'
local sp="${(%):-%b%k%f%s%u$mark${(pl.$fill.. .)}$cr%b%k%f%s%u%E}" local sp="${(%):-%b%k%f%s%u$mark${(pl.$fill.. .)}$cr%b%k%f%s%u%E}"
if (( _z4h_can_save_restore_screen == 1 && __p9k_instant_prompt_sourced >= 35 )); then
-z4h-restore-screen
unset _z4h_saved_screen
fi
print -rn -- $terminfo[rc]${(%):-%b%k%f%s%u}$terminfo[ed] print -rn -- $terminfo[rc]${(%):-%b%k%f%s%u}$terminfo[ed]
local unexpected=${${${(S)content//$'\e[?'<->'c'}//$'\e['<->' q'}//$'\e'[^$'\a\e']#($'\a'|$'\e\\')} local unexpected=${${${(S)content//$'\e[?'<->'c'}//$'\e['<->' q'}//$'\e'[^$'\a\e']#($'\a'|$'\e\\')}
if [[ -n $unexpected ]]; then if [[ -n $unexpected ]]; then
@ -6305,6 +6324,10 @@ function _p9k_clear_instant_prompt() {
} 2>/dev/null } 2>/dev/null
else else
zf_rm -f -- $__p9k_instant_prompt_output 2>/dev/null zf_rm -f -- $__p9k_instant_prompt_output 2>/dev/null
if (( _z4h_can_save_restore_screen == 1 && __p9k_instant_prompt_sourced >= 35 )); then
-z4h-restore-screen
unset _z4h_saved_screen
fi
print -rn -- $terminfo[rc]${(%):-%b%k%f%s%u}$terminfo[ed] print -rn -- $terminfo[rc]${(%):-%b%k%f%s%u}$terminfo[ed]
fi fi
prompt_opts=(percent subst sp cr) prompt_opts=(percent subst sp cr)
@ -6412,7 +6435,7 @@ function _p9k_on_expand() {
zle -F $_p9k__state_dump_fd _p9k_do_dump zle -F $_p9k__state_dump_fd _p9k_do_dump
fi fi
if (( ! $+P9K_TTY )); then if [[ -z $P9K_TTY || $P9K_TTY == old && -n ${_P9K_TTY:#$TTY} ]]; then
typeset -gx P9K_TTY=old typeset -gx P9K_TTY=old
if (( _POWERLEVEL9K_NEW_TTY_MAX_AGE_SECONDS < 0 )); then if (( _POWERLEVEL9K_NEW_TTY_MAX_AGE_SECONDS < 0 )); then
P9K_TTY=new P9K_TTY=new
@ -6425,6 +6448,8 @@ function _p9k_on_expand() {
fi fi
fi fi
typeset -gx _P9K_TTY=$TTY
__p9k_reset_state=1 __p9k_reset_state=1
if (( _POWERLEVEL9K_PROMPT_ADD_NEWLINE )); then if (( _POWERLEVEL9K_PROMPT_ADD_NEWLINE )); then
@ -6611,6 +6636,7 @@ _p9k_precmd_impl() {
local -F start_time=EPOCHREALTIME local -F start_time=EPOCHREALTIME
unset _p9k__vcs unset _p9k__vcs
unset _p9k__vcs_timeout unset _p9k__vcs_timeout
local -i _p9k__vcs_called
_p9k_vcs_gitstatus _p9k_vcs_gitstatus
local -i fast_vcs=1 local -i fast_vcs=1
fi fi
@ -6682,6 +6708,8 @@ _p9k_precmd() {
# See https://www.zsh.org/mla/workers/2020/msg00612.html for the reason behind __p9k_trapint. # See https://www.zsh.org/mla/workers/2020/msg00612.html for the reason behind __p9k_trapint.
typeset -g __p9k_trapint='_p9k_trapint; return 130' typeset -g __p9k_trapint='_p9k_trapint; return 130'
trap "$__p9k_trapint" INT trap "$__p9k_trapint" INT
: ${(%):-%b%k%s%u}
} }
function _p9k_reset_prompt() { function _p9k_reset_prompt() {
@ -7346,33 +7374,37 @@ function _p9k_on_widget_zle-line-init() {
function _p9k_on_widget_zle-line-finish() { function _p9k_on_widget_zle-line-finish() {
(( $+_p9k__line_finished )) && return (( $+_p9k__line_finished )) && return
local P9K_PROMPT=transient
_p9k__line_finished= _p9k__line_finished=
(( _p9k_reset_on_line_finish )) && __p9k_reset_state=2 (( _p9k_reset_on_line_finish )) && __p9k_reset_state=2
(( $+functions[p10k-on-post-prompt] )) && p10k-on-post-prompt (( $+functions[p10k-on-post-prompt] )) && p10k-on-post-prompt
local -i optimized
if [[ -n $_p9k_transient_prompt ]]; then if [[ -n $_p9k_transient_prompt ]]; then
if [[ $_POWERLEVEL9K_TRANSIENT_PROMPT == always || $_p9k__cwd == $_p9k__last_prompt_pwd ]]; then if [[ $_POWERLEVEL9K_TRANSIENT_PROMPT == always || $_p9k__cwd == $_p9k__last_prompt_pwd ]]; then
RPROMPT= optimized=1
PROMPT=$_p9k_transient_prompt
__p9k_reset_state=2 __p9k_reset_state=2
else else
_p9k__last_prompt_pwd=$_p9k__cwd _p9k__last_prompt_pwd=$_p9k__cwd
fi fi
fi fi
if [[ $1 == int ]]; then
_p9k__must_restore_prompt=1
if (( !_p9k__restore_prompt_fd )); then
sysopen -o cloexec -ru _p9k__restore_prompt_fd /dev/null
zle -F $_p9k__restore_prompt_fd _p9k_restore_prompt
fi
fi
if (( __p9k_reset_state == 2 )); then if (( __p9k_reset_state == 2 )); then
if [[ $1 == int ]]; then if (( optimized )); then
_p9k__must_restore_prompt=1 RPROMPT= PROMPT=$_p9k_transient_prompt _p9k_reset_prompt
if (( !_p9k__restore_prompt_fd )); then else
sysopen -o cloexec -ru _p9k__restore_prompt_fd /dev/null _p9k_reset_prompt
zle -F $_p9k__restore_prompt_fd _p9k_restore_prompt
fi
fi fi
if (( $+termcap[up] )); then
(( _p9k__can_hide_cursor )) && local hide=$terminfo[civis] || local hide=
echo -nE - $hide$'\n'$termcap[up]
fi
_p9k_reset_prompt
fi fi
_p9k__line_finished='%{%}' _p9k__line_finished='%{%}'
@ -7427,7 +7459,7 @@ function _p9k_widget_hook() {
eval "$__p9k_intro" eval "$__p9k_intro"
(( _p9k__restore_prompt_fd )) && _p9k_restore_prompt $_p9k__restore_prompt_fd (( _p9k__restore_prompt_fd )) && _p9k_restore_prompt $_p9k__restore_prompt_fd
if [[ $1 == clear-screen ]]; then if [[ $1 == (clear-screen|z4h-clear-screen-*-top) ]]; then
P9K_TTY=new P9K_TTY=new
_p9k__expanded=0 _p9k__expanded=0
_p9k_reset_prompt _p9k_reset_prompt
@ -7499,6 +7531,8 @@ function _p9k_wrap_widgets() {
visual-line-mode visual-line-mode
deactivate-region deactivate-region
clear-screen clear-screen
z4h-clear-screen-soft-top
z4h-clear-screen-hard-top
send-break send-break
$_POWERLEVEL9K_HOOK_WIDGETS $_POWERLEVEL9K_HOOK_WIDGETS
) )
@ -7899,13 +7933,13 @@ _p9k_must_init() {
[[ $sig == $_p9k__param_sig ]] && return 1 [[ $sig == $_p9k__param_sig ]] && return 1
_p9k_deinit _p9k_deinit
fi fi
_p9k__param_pat=$'v108\1'${(q)ZSH_VERSION}$'\1'${(q)ZSH_PATCHLEVEL}$'\1' _p9k__param_pat=$'v109\1'${(q)ZSH_VERSION}$'\1'${(q)ZSH_PATCHLEVEL}$'\1'
_p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1' _p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1'
_p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1' _p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1'
_p9k__param_pat+=$'$GITSTATUS_CACHE_DIR\1$GITSTATUS_AUTO_INSTALL\1${ZLE_RPROMPT_INDENT:-1}\1' _p9k__param_pat+=$'$GITSTATUS_CACHE_DIR\1$GITSTATUS_AUTO_INSTALL\1${ZLE_RPROMPT_INDENT:-1}\1'
_p9k__param_pat+=$'$__p9k_sh_glob\1$__p9k_ksh_arrays\1$ITERM_SHELL_INTEGRATION_INSTALLED\1' _p9k__param_pat+=$'$__p9k_sh_glob\1$__p9k_ksh_arrays\1$ITERM_SHELL_INTEGRATION_INSTALLED\1'
_p9k__param_pat+=$'${PROMPT_EOL_MARK-%B%S%#%s%b}\1$commands[locale]\1$langinfo[CODESET]\1' _p9k__param_pat+=$'${PROMPT_EOL_MARK-%B%S%#%s%b}\1$+commands[locale]\1$langinfo[CODESET]\1'
_p9k__param_pat+=$'$VTE_VERSION\1$TERM_PROGRAM\1$DEFAULT_USER\1$P9K_SSH\1$commands[uname]\1' _p9k__param_pat+=$'${(M)VTE_VERSION:#(<1-4602>|4801)}\1$DEFAULT_USER\1$P9K_SSH\1$+commands[uname]\1'
_p9k__param_pat+=$'$__p9k_root_dir\1$functions[p10k-on-init]\1$functions[p10k-on-pre-prompt]\1' _p9k__param_pat+=$'$__p9k_root_dir\1$functions[p10k-on-init]\1$functions[p10k-on-pre-prompt]\1'
_p9k__param_pat+=$'$functions[p10k-on-post-widget]\1$functions[p10k-on-post-prompt]\1' _p9k__param_pat+=$'$functions[p10k-on-post-widget]\1$functions[p10k-on-post-prompt]\1'
_p9k__param_pat+=$'$+commands[git]\1$terminfo[colors]' _p9k__param_pat+=$'$+commands[git]\1$terminfo[colors]'
@ -8325,6 +8359,11 @@ _p9k_init() {
_p9k_dumped_instant_prompt_sigs=() _p9k_dumped_instant_prompt_sigs=()
fi fi
if (( $+__p9k_instant_prompt_sourced && __p9k_instant_prompt_sourced != __p9k_instant_prompt_version )); then
_p9k_delete_instant_prompt
_p9k_dumped_instant_prompt_sigs=()
fi
if (( $+__p9k_instant_prompt_erased )); then if (( $+__p9k_instant_prompt_erased )); then
unset __p9k_instant_prompt_erased unset __p9k_instant_prompt_erased
{ {
@ -8388,7 +8427,7 @@ _p9k_deinit() {
fi fi
(( $+_p9k__iterm2_precmd )) && functions[iterm2_precmd]=$_p9k__iterm2_precmd (( $+_p9k__iterm2_precmd )) && functions[iterm2_precmd]=$_p9k__iterm2_precmd
(( $+_p9k__iterm2_decorate_prompt )) && functions[iterm2_decorate_prompt]=$_p9k__iterm2_decorate_prompt (( $+_p9k__iterm2_decorate_prompt )) && functions[iterm2_decorate_prompt]=$_p9k__iterm2_decorate_prompt
unset -m '(_POWERLEVEL9K_|P9K_|_p9k_)*~(P9K_SSH|P9K_TTY)' unset -m '(_POWERLEVEL9K_|P9K_|_p9k_)*~(P9K_SSH|P9K_TTY|_P9K_TTY)'
[[ -n $__p9k_locale ]] || unset __p9k_locale [[ -n $__p9k_locale ]] || unset __p9k_locale
} }
@ -8800,10 +8839,5 @@ if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file && -n $__p9k_instant_p
zf_rm -f -- $__p9k_instant_prompt_dump_file{,.zwc} 2>/dev/null zf_rm -f -- $__p9k_instant_prompt_dump_file{,.zwc} 2>/dev/null
fi fi
if [[ $+__p9k_instant_prompt_sourced == 1 && $__p9k_instant_prompt_sourced != $__p9k_instant_prompt_version ]]; then
_p9k_delete_instant_prompt
zf_rm -f -- $__p9k_dump_file{,.zwc} 2>/dev/null
fi
_p9k_init_ssh _p9k_init_ssh
prompt_powerlevel9k_setup prompt_powerlevel9k_setup