Skip to content

A Vim plugin that updates Apple Terminal's current working document and directory

License

Notifications You must be signed in to change notification settings

cooljeanius/termcwd-vim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

termcwd for Vim

This plugin for command-line Vim makes Apple Terminal's proxy icon reflect Vim's current file (for windows that have one) or working directory (for most other windows).

A screenshot of Vim running inside Apple Terminal.  Vim has this file open for editing, while Apple Terminal's proxy icon menu displays this file's path.

It works by using escape sequences to send Vim's current file and working directory to Terminal. Depending on Terminal's configuration, this may also affect the titles and initial working directories of its windows and tabs [1].

This software is released as open source using the MIT (i.e., Expat) License.

Requirements

Installation

This plugin has nothing to configure, so just download it and make sure Vim can find it at startup. Here are a few options:

  • Clone this repository into a Vim package. Recommended for Vim 8 or later.

    mkdir -p ~/.vim/pack/whatever/start \
        && cd ~/.vim/pack/whatever/start \
        && git clone https://github.com/larryv/termcwd-vim.git
  • Use a third-party plugin manager such as Tim Pope's pathogen. Its documentation should explain how to install plugins. Recommended for Vim 7, which predates native package support.

  • Clone or download this repository to an arbitrary location and manually update Vim's runtimepath option (perhaps in ~/.vimrc). Left as an exercise for the reader. Recommended for my enemies.

That's it. Enjoy the icon.

Notes

[1]Terminal's General preferences determine whether new windows or tabs open with the same working directory as the current window or tab. Each profile's Window and Tab preferences determine whether windows' and tabs' titles display the name or path of the working document or directory.
[2]Do not simply look at Vim's welcome screen, as it does not provide complete version information. For example, in the system Vim on macOS Mojave 10.14.6 it says "version 8.0.1365", but :version says "8.0 […] Included patches: 1-503, 505-680, 682-1283, 1365".
[3](1, 2, 3) Even without these patches, Terminal is updated as soon as the user switches Vim windows or buffers.
[4]Without this patch, Terminal's state becomes stale when Vim is suspended, unless the subsequent process updates it.

About

A Vim plugin that updates Apple Terminal's current working document and directory

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • Vim Script 100.0%