parent
3b49e1a2b6
commit
f8daa60b31
2
doc.go
2
doc.go
@ -717,7 +717,7 @@ other command:
|
||||
GIT_PS1_SHOWUNTRACKEDFILES=auto
|
||||
GIT_PS1_SHOWUPSTREAM=auto
|
||||
git=$(__git_ps1 " (%s)") || true
|
||||
fmt="\033[32;1m%u@%h\033[0m:\033[34;1m%w/\033[0m\033[1m%f$git\033[0m"
|
||||
fmt="\033[32;1m%u@%h\033[0m:\033[34;1m%w\033[0m\033[1m%f$git\033[0m"
|
||||
lf -remote "send $id set promptfmt \"$fmt\""
|
||||
}}
|
||||
|
||||
|
@ -749,7 +749,7 @@ define any other command:
|
||||
GIT_PS1_SHOWUNTRACKEDFILES=auto
|
||||
GIT_PS1_SHOWUPSTREAM=auto
|
||||
git=$(__git_ps1 " (%s)") || true
|
||||
fmt="\033[32;1m%u@%h\033[0m:\033[34;1m%w/\033[0m\033[1m%f$git\033[0m"
|
||||
fmt="\033[32;1m%u@%h\033[0m:\033[34;1m%w\033[0m\033[1m%f$git\033[0m"
|
||||
lf -remote "send $id set promptfmt \"$fmt\""
|
||||
}}
|
||||
|
||||
|
3
lf.1
3
lf.1
@ -151,6 +151,7 @@ The following options can be used to customize the behavior of lf:
|
||||
shellopts string (default '')
|
||||
sortby string (default 'natural')
|
||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||
truncatechar string (default '~')
|
||||
.EE
|
||||
.PP
|
||||
The following variables are exported for shell commands:
|
||||
@ -655,7 +656,7 @@ There is a special command 'on-cd' that runs a shell command when it is defined
|
||||
GIT_PS1_SHOWUNTRACKEDFILES=auto
|
||||
GIT_PS1_SHOWUPSTREAM=auto
|
||||
git=$(__git_ps1 " (%s)") || true
|
||||
fmt="\e033[32;1m%u@%h\e033[0m:\e033[34;1m%w/\e033[0m\e033[1m%f$git\e033[0m"
|
||||
fmt="\e033[32;1m%u@%h\e033[0m:\e033[34;1m%w\e033[0m\e033[1m%f$git\e033[0m"
|
||||
lf -remote "send $id set promptfmt \e"$fmt\e""
|
||||
}}
|
||||
.EE
|
||||
|
2
opts.go
2
opts.go
@ -91,7 +91,7 @@ func init() {
|
||||
gOpts.filesep = "\n"
|
||||
gOpts.ifs = ""
|
||||
gOpts.previewer = ""
|
||||
gOpts.promptfmt = "\033[32;1m%u@%h\033[0m:\033[34;1m%w/\033[0m\033[1m%f\033[0m"
|
||||
gOpts.promptfmt = "\033[32;1m%u@%h\033[0m:\033[34;1m%w\033[0m\033[1m%f\033[0m"
|
||||
gOpts.shell = gDefaultShell
|
||||
gOpts.timefmt = time.ANSIC
|
||||
gOpts.truncatechar = "~"
|
||||
|
17
ui.go
17
ui.go
@ -574,12 +574,19 @@ func (ui *ui) drawPromptLine(nav *nav) {
|
||||
fg, bg := termbox.ColorDefault, termbox.ColorDefault
|
||||
|
||||
pwd := nav.currDir().path
|
||||
nohome := strings.TrimPrefix(pwd, gUser.HomeDir)
|
||||
if len(nohome) < len(pwd) {
|
||||
pwd = "~/" + nohome
|
||||
|
||||
if strings.HasPrefix(pwd, gUser.HomeDir) {
|
||||
pwd = filepath.Join("~", strings.TrimPrefix(pwd, gUser.HomeDir))
|
||||
}
|
||||
|
||||
pwd = filepath.Clean(pwd)
|
||||
|
||||
sep := string(filepath.Separator)
|
||||
|
||||
if !strings.HasSuffix(pwd, sep) {
|
||||
pwd += sep
|
||||
}
|
||||
|
||||
var fname string
|
||||
curr, err := nav.currFile()
|
||||
if err == nil {
|
||||
@ -593,9 +600,11 @@ func (ui *ui) drawPromptLine(nav *nav) {
|
||||
prompt = strings.Replace(prompt, "%f", fname, -1)
|
||||
|
||||
if printLength(strings.Replace(prompt, "%w", pwd, -1)) > ui.promptWin.w {
|
||||
sep := string(filepath.Separator)
|
||||
names := strings.Split(pwd, sep)
|
||||
for i := range names {
|
||||
if names[i] == "" {
|
||||
continue
|
||||
}
|
||||
r, _ := utf8.DecodeRuneInString(names[i])
|
||||
names[i] = string(r)
|
||||
if printLength(strings.Replace(prompt, "%w", strings.Join(names, sep), -1)) <= ui.promptWin.w {
|
||||
|
Loading…
Reference in New Issue
Block a user