vim - 如何命名/重命名终端缓冲区?
问题描述
有没有办法重命名终端缓冲区?使用 :b 切换缓冲区,终端缓冲区通常显示为!/usr/local/bin/fish
并且!/usr/local/bin/fish (1)
不是很有用。理想情况下,它可以自动重命名,但我也可以docker-compose up
在终端开始工作后手动命名它们(即)。
解决方案
这是我为它制作的功能。免责声明:我不是蒂姆·波普
function! RenameTerminalBufferToCurrentCommand()
" unable to access $HISTFILE from vim, so change this variable to your history file
let l:historyFile = "~/.zsh_history"
let l:mostRecentCommand = system("tail -1 " . l:historyFile . " | cut -f2- -d\\;")
" i prepend "term" for easy buffer searching, but feel free to delete
let l:newFileName = "term " . fnameescape(trim(l:mostRecentCommand))
" the keepalt stops :file from creating an alternative file (alt files are
" annoying when buffer switching)
" :file renames the buffer
silent! execute "keepalt file " . l:newFileName
endfunction
tnoremap <Enter> <Enter><C-\><C-n>:call RenameTerminalBufferToCurrentCommand()<Enter>a
推荐阅读
- javascript - 未捕获(承诺中)ReferenceError:在初始化之前无法访问“USER_REPOS_API_URL”
- vue.js - 为 Vue 应用创建动态 .htaccess
- google-drive-api - 检索访问令牌时出错 FetchError:对 https://oauth2.googleapis.com/token 的请求失败,原因:读取 ECONNRESET
- corda - 更新 LinearState 时如何更新 PersistentState
- sql - 如何在 SAS 的 proc sql 查询中选择列名“startwith”
- excel - VBA - 宏记录器更改单元格颜色未按预期工作
- ios - 如何通过编程或脚本在 iPhone 中使用坐标进行触摸或滑动?
- amazon-web-services - 无法通过 SSH 连接到 EC2 实例并且无法放置 ECS 任务
- sharepoint - Word 文档搜索 - Sharepoint
- scikit-learn - 如何在一个 ColumnTransformerr 中为所有类型的特征、分类特征和数值特征组合管道?