fish: include term-specific config file, if available
1 file changed, 51 insertions(+), 0 deletions(-)
changed files
A user/settings/fish/per-term/Apple_Terminal.fish
@@ -0,0 +1,51 @@ +set window_and_tab 0 +set tab 1 +set window 2 +set document 6 +set wd 7 + +function update_terminal_path --argument-names ps pt + if set --query SSH_TTY + printf '\e]%d;file://%s@%s%s\a' $ps $USER (prompt_hostname) \ + (string escape --style=url $pt) + else + printf '\e]%d;file://%s\a' $ps (string escape --style=url $pt) + end +end + +function update_terminal_title --argument-names ps pt + printf '\e]%d;%s\a' $ps $pt +end + +function reset_title_document --on-event fish_postexec + # not _path because we don't want a file:// URL + update_terminal_title $document "" +end + +function reset_title_post_ssh --on-event fish_postexec --argument-names cmdline + if string match "ssh *" "$cmdline" + reset_title_document + update_terminal_path $wd "$PWD" + update_terminal_title $window_and_tab "" + end +end + +function clear_title --on-event fish_exit + update_terminal_title $window_and_tab "" +end + +function set_document_title --on-event fish_preexec --argument-names cmdline + set --local args (string split ' ' "$cmdline") + switch "$args[1]" + case e editor vi vim nvim + # move options to $argv_opts + argparse --move-unknown -- $args[2..] + + # check if any arg is a file or directory + for p in (path filter $argv) + # set Terminal path to full path of arg + update_terminal_path $document (path resolve $p) + return + end + end +end