aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/shell/wsl.sh
blob: 100deafc3cb3274e956a6b2c22a94ca21012fa66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash

WINHOME="$(wslpath "$(powershell.exe -NoProfile -c \$HOME)")"

# XDG Specs
export XDG_DESKTOP_DIR="$WINHOME/Desktop"
export XDG_DOCUMENTS_DIR="$WINHOME/Documents"
export XDG_DOWNLOAD_DIR="$WINHOME/Downloads"
export XDG_MUSIC_DIR="$WINHOME/Music"
export XDG_PICTURES_DIR="$WINHOME/Pictures"
export XDG_TEMPLATES_DIR="$WINHOME/Templates"
export XDG_VIDEOS_DIR="$WINHOME/Videos"

export EDITOR="code --wait"
export DOCKER_HOST=${DOCKER_HOST:-tcp://0.0.0.0:2375}
export DOCKER_MACHINE_NAME=${DOCKER_MACHINE_NAME:-$HOST}

alias cb=clip.exe
alias wsl=wsl.exe
alias ykman='/mnt/c/Program\ Files/Yubico/YubiKey\ Manager/ykman.exe'
alias dmu="docker-machine-wsl"

function docker-machine-wsl() {
  docker-machine-use $@
  export DOCKER_HOST=${DOCKER_HOST:-tcp://0.0.0.0:2375}
  export DOCKER_MACHINE_NAME=${DOCKER_MACHINE_NAME:-$HOST}
}

function wt() {
  powershell.exe -NoProfile -c "wt $@"
}

function winget() {
  cmd="winget.exe $1"
  shift # past cmd

  while [[ $# -gt 0 ]]; do
    key="$1"
    case $key in
    -*) # key value pair
      cmd+=" $key '$2'"
      shift # past argument
      shift # past value
      ;;
    *)             # positional argument
      cmd+=" '$1'" # add it to the list
      shift        # past argument
      ;;
    esac
  done

  powershell.exe -NoProfile -c "$cmd"
}

# https://github.com/validatedev/drop-cache-if-idle
[ -z "$(ps -ef | grep cron | grep -v grep)" ] && sudo /etc/init.d/cron start &>/dev/null