#
# Dotfile specifics for Trailblazer (non-WSL)
#

# Path
# Note: lower in the list = higher priority
PATH_ADDS = [
    r"C:\\Program Files\\Git\\bin",
	r"C:\\Users\\deprekated\\.local\\bin",	
]

# Aliases
aliases['ls'] = 'eza -gb'
aliases['tree'] = 'eza --tree'

# Replace some of Xonsh's aliases with our own.
aliases['mkdir'] = 'mkdir.exe'
aliases['sudo'] = r'C:\Users\deprekated\scoop\shims\sudo.cmd'

# Use a proper GNU find.
aliases['find'] = r'C:\Users\deprekated\scoop\shims\find.exe'

# Make it easy to go into our t5 build environment.
aliases['t5wsl'] = 'wsl -d t5sw --cd ~/Projects/t5'

# lsusb equivalent
def _lsusb(args):
	PowerShell "Get-PnpDevice -InstanceId 'USB*' -Status OK | Format-Table -property InstanceID,FriendlyName,Class" | grep -v Hub | sed -e "s|USB.VID_||" -e "s|&PID_|:|" -e "s|[&\\][^ ]* *|    |" -e "/FriendlyName/d" -e "/----/d"
aliases['lsusb'] = _lsusb

# Aliases for our power-controlled USB3 hub.
aliases['ykushcmd'] = "~/.local/bin/ykushcmd.bat"
aliases['yk'] = "~/.local/bin/ykushcmd.bat ykush3"

# Convenience hacks:
def cycle_t5_power():
    import time

    yk -d 1
    time.sleep(0.5)
    yk -u 1

aliases['t5cycle'] = cycle_t5_power

# Git LFS is broken when sshConfig is set, but it accepts configuration
# from the environment, first. Take advantage to make everything work.
$GIT_SSH_COMMAND=r"C:\\\Windows\\\System32\\\OpenSSH\\\ssh.exe"

# Use mob to pass our branches around
$MOB_REMOTE_NAME="mob-remote"

# Windows behaves better when TERM isn't defined. What?
del $TERM

# Don't bother with Windows paths. They're icky.
$FORCE_POSIX_PATHS=True

# Don't bother with bash completion, on Windows.
if 'bash' in __xonsh__.completers:
	del __xonsh__.completers['bash']

# Set up Amaranth to use our local tools.
$AMARANTH_ENV_TRELLIS = r'C:\Users\deprekated\scoop\apps\oss-cad-suite-nightly\current\environment.bat'

# Add an open command, as Osiria wanted.
def xopen_impl(args):
  argstr = " ".join(args)
  PowerShell -Command @("(New-Object -com 'Shell.Application').ShellExecute(\"" + argstr + "\")")
aliases['xopen'] = xopen_impl

# Don't break neovim when called from Git.
__xonsh__.commands_cache.threadable_predictors['git'] = lambda *a, **kw: False

# Use our standard gpg4win SSH.
$SSH_AUTH_SOCK=r"\\.\pipe\ssh-pageant"
