Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the tail of a path (or string) in vim

Tags:

vim

I'm tuning my vimrc and I'd like to show in my airline bar the folder where I started vim (usually my project folder).

As the vim airline help says, I use let g:airline_section_b = '%{getcwd()}' but then I get a complete path while I'd like to get the last folder.

I've tried with :t but doesn't work: let g:airline_section_b = '%{getcwd()}:t. It just shows /home/vivo/myproject:t (while I want just myproject)

like image 534
javier_domenech Avatar asked Feb 06 '23 17:02

javier_domenech


1 Answers

You're looking for fnamemodify() -> fnamemodify(getcwd(), ':t')

like image 112
Luc Hermitte Avatar answered Mar 04 '23 01:03

Luc Hermitte