Skip to content

Commit

Permalink
use ~/.bashrc.d if it's mentioned in ~/bashrc
Browse files Browse the repository at this point in the history
  • Loading branch information
xofer committed Dec 29, 2014
1 parent 3e1b8e6 commit b6f67a9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""Setup script for hop."""

import os.path
from os import makedirs
import sys

from setuptools import setup
Expand Down Expand Up @@ -50,9 +51,18 @@ def run(self):
# First check if the reference to hop.bash is already installed.
with open(bashrc_path, "r") as f:
bashrc_content = f.read()
for k in required_commands.keys():
if k in bashrc_content:
del required_commands[k]
if '.bashrc.d' in bashrc_content:
bashrc_dir = os.path.expanduser('~/.bashrc.d')
if not os.path.isdir(bashrc_dir):
makedirs(bashrc_dir, 0750)
bashrc_path = '{}/hop'.format(bashrc_dir)
bashrc_content = ''
if os.path.isfile(bashrc_path):
with open(bashrc_path, "r") as f2:
bashrc_content = f2.read()
for k in required_commands.keys():
if k in bashrc_content:
del required_commands[k]

if required_commands:
with open(bashrc_path, "a") as f:
Expand Down

0 comments on commit b6f67a9

Please sign in to comment.