
    7j                     h    d Z ddlZddlZddlZddlmZ ddlmZ  ej                  d      d        Z	y)z'Open a shell in the QMK Home directory
    N)cli)under_qmk_firmwarezGo to QMK Homec                 8   t         j                  j                         s0| j                  j	                  d       t        j
                  d       t               s&| j                  j                  d       | j                  j                  d       | j                  j                         j                  d      sjddl}ddl}|j                  |j                               j                  }|s t         j"                  j%                  dd	      }t!        j&                  ||       yt         j"                  j)                         }|d
   |d<   t+        j,                  t         j"                  j%                  dd      g|       y| j                  j                  d       y)zGo to QMK Home
    zoThis command is for interactive usage only. For non-interactive usage, 'cd $(qmk env QMK_HOME)' is more robust.   z/Spawning a subshell in your QMK_HOME directory.z,Type 'exit' to get back to the parent shell.windowsr   NSHELLz	/bin/bashPS1	MSYS2_PS1z/usr/bin/bash)envz&Already within qmk_firmware directory.)sysstdoutisattylogerrorexitr   infoplatformlower
startswithgetpasspwdgetpwnamgetuserpw_shellosenvirongetexeclcopy
subprocessrun)r   r   r   shellqmk_envs        C/home/hanthebot/chat/keyboard/qmk_firmware/lib/python/qmk/cli/cd.pycdr%      s    ::  H  	I 	FGCD||!!#..y9
 LL!23<<E

w<HHUE"
 jjoo'G#*5>GK NNBJJNN7ODE7S=>    )
__doc__r   r   r    milcr   qmk.pathr   
subcommandr%    r&   r$   <module>r,      s9    
 	   '  !"? ""?r&   