statusline-format: add %p placeholder for current path
Allow showing the current working directory in the statusline via [statusline] render-format=%p, which is useful if the user changes directories often. Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Tested-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
parent
f414db7858
commit
74fd5d1119
3 changed files with 14 additions and 0 deletions
|
@ -60,6 +60,7 @@ func (ChangeDirectory) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
}
|
}
|
||||||
if err := os.Chdir(target); err == nil {
|
if err := os.Chdir(target); err == nil {
|
||||||
previousDir = cwd
|
previousDir = cwd
|
||||||
|
aerc.UpdateStatus()
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,6 +376,8 @@ These options are configured in the *[statusline]* section of aerc.conf.
|
||||||
: active directory name
|
: active directory name
|
||||||
| %c
|
| %c
|
||||||
: connection state
|
: connection state
|
||||||
|
| %p
|
||||||
|
: current path
|
||||||
| %m
|
| %m
|
||||||
: mute statusline and show only push notifications
|
: mute statusline and show only push notifications
|
||||||
| %S
|
| %S
|
||||||
|
|
|
@ -3,6 +3,7 @@ package statusline
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
|
@ -171,6 +172,16 @@ func parseStatuslineFormat(format string, texter Texter, r renderParams) (string
|
||||||
}
|
}
|
||||||
retval = append(retval, 's')
|
retval = append(retval, 's')
|
||||||
args = append(args, strings.Join(tray, r.sep))
|
args = append(args, strings.Join(tray, r.sep))
|
||||||
|
case 'p':
|
||||||
|
path, err := os.Getwd()
|
||||||
|
if err == nil {
|
||||||
|
home, _ := os.UserHomeDir()
|
||||||
|
if strings.HasPrefix(path, home) {
|
||||||
|
path = strings.Replace(path, home, "~", 1)
|
||||||
|
}
|
||||||
|
retval = append(retval, 's')
|
||||||
|
args = append(args, path)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
// Just ignore it and print as is
|
// Just ignore it and print as is
|
||||||
// so %k in index format becomes %%k to Printf
|
// so %k in index format becomes %%k to Printf
|
||||||
|
|
Loading…
Reference in a new issue