Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a Fabric script that uncomments a particular line of a user's .bashrc file?

How would you write a Fabric script that uncomments the line

#force_color_prompt=yes

from the logged-in user's .bashrc file?

Note: This question is specifically about editing this particular line, not about simply appending force_color_prompt=yes to the end of the file and ignoring this line.

like image 617
coffee-grinder Avatar asked Dec 07 '22 22:12

coffee-grinder


1 Answers

fabric do have api for that. fabric.contrib.files.uncomment

from fabric.contrib.files import uncomment
uncomment("~/.bashrc", "^#force_color_prompt=yes", char='#')
like image 52
ftao Avatar answered Apr 08 '23 10:04

ftao