2

Is it possible to achieve the following

➜ ag editNote                    
src/store/actions.js
8:const editNote = ({ commit }, e) => {
26:  editNote,

src/components/Editor.vue
5:      @input="editNote"
22:      'editNote',

/frontend on  master [✘!?] 
➜ vi Ed    

For example I would like to start typing vi Edit and get this replaced with

vi src/components/Editor.vue

  • I don’t think it’s possible on ZSH, but maybe with Bash... – Stan Strum Jan 30 '18 at 2:39
2

The shell, whether bash or zsh, does not have access to the terminal scroll back buffer. While ag was running, output from it goes direct to the terminal and can't be intercepted by the shell.

Depending on what your terminal is, it may be possible to capture the contents of the scroll-back buffer. rxvt-unicode can be induced to dump it to a temporary file with the escape sequence '\e[0i'. For tmux, you can use tmux -q capture-pane \; save-buffer -b 0 $TMPFILE \; delete-buffer -b 0. And screen can do screen -X hardcopy $TMPFILE. However, all these solutions will only work from a local zsh session. As soon as you use ssh or similar, the temporary files won't be on the same system as zsh.

These temporary files can be used for a custom completion widget. I have such a widget but it is a bit too long to paste in here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.