mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-17 14:04:52 +02:00
choose-files kitten: Output a trailing newline when writing to a tty in text format
Fixes #9982
This commit is contained in:
@@ -903,6 +903,10 @@ func main(_ *cli.Command, opts *Options, args []string) (rc int, err error) {
|
||||
m = string(b)
|
||||
}
|
||||
os.Stdout.Write(utils.UnsafeStringToBytes(m))
|
||||
if tty.IsTerminal(os.Stdout.Fd()) && opts.OutputFormat == "text" {
|
||||
// Avoid zsh's silly no trailing newline marker
|
||||
os.Stdout.WriteString("\n")
|
||||
}
|
||||
if opts.WriteOutputTo != "" {
|
||||
os.WriteFile(opts.WriteOutputTo, utils.UnsafeStringToBytes(m), 0600)
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ def handle_result(args: list[str], data: dict[str, Any], target_window_id: int,
|
||||
usage = '[directory to start choosing files in]'
|
||||
|
||||
|
||||
OPTIONS = '''
|
||||
OPTIONS = """
|
||||
--mode
|
||||
type=choices
|
||||
choices=file,files,save-file,dir,save-dir,dirs,save-files
|
||||
@@ -266,11 +266,12 @@ Path to a file to which the output is written in addition to STDOUT.
|
||||
--output-format
|
||||
choices=text,json,shell,shell-relative
|
||||
default=text
|
||||
The format in which to write the output. The :code:`text` format is absolute paths separated by newlines.
|
||||
The :code:`shell` format is quoted absolute paths separated by spaces, quoting is done only if needed. The
|
||||
:code:`shell-relative` format is the same as :code:`shell` except it returns paths relative to the starting
|
||||
directory. Note that when invoked from a mapping, this option is ignored,
|
||||
and either text or shell format is used automatically based on whether the cursor is at a shell prompt or not.
|
||||
The format in which to write the output. The :code:`text` format is absolute paths separated by newlines,
|
||||
with a trailing newline. The :code:`shell` format is quoted absolute paths separated by spaces,
|
||||
quoting is done only if needed. The :code:`shell-relative` format is the same as :code:`shell` except that
|
||||
it returns paths relative to the starting directory. Note that when invoked from a mapping,
|
||||
this option is ignored, and either text or shell format is used automatically based on whether
|
||||
the cursor is at a shell prompt or not.
|
||||
|
||||
|
||||
--write-pid-to
|
||||
@@ -280,7 +281,7 @@ Path to a file to which to write the process ID (PID) of this process to.
|
||||
--clear-cache
|
||||
type=bool-set
|
||||
Clear the caches used by this kitten.
|
||||
'''.format(config_help=CONFIG_HELP.format(conf_name='choose-files', appname=appname)).format
|
||||
""".format(config_help=CONFIG_HELP.format(conf_name='choose-files', appname=appname)).format
|
||||
|
||||
|
||||
help_text = '''\
|
||||
|
||||
Reference in New Issue
Block a user