########################################################################
# 
# PERSONAL sh stuff
# 
########################################################################

bt() {
    echo "powering on"
    bluetoothctl power on
    device=$1
    echo "connecting to $device";
    bluetoothctl devices | awk -v device="$device" '$0 ~ device {print $2}' | xargs -I{} bluetoothctl connect {}
}

grab() {
    out=$1
    echo "pasting clipboard to $out"
    xclip -sel clipboard -t image/png -o > $out
}

# tm - create new tmux session, or switch to existing one. Works from within tmux too. (@bag-man)
# `tm` will allow you to select your tmux session via fzf.
# `tm irc` will attach to the irc session (if it exists), else it will create it.

tm() {
  [[ -n "$TMUX" ]] && change="switch-client" || change="attach-session"
  if [ $1 ]; then
    tmux $change -t "$1" 2>/dev/null || (tmux new-session -d -s $1 && tmux $change -t "$1"); return
  fi
  session=$(tmux list-sessions -F "#{session_name}" 2>/dev/null | fzf --exit-0) && tmux $change -t "$session" || echo "No sessions found."
}

# save a youtube video as audio file
yt() {
    youtube-dl $1 -x --audio-format mp3
}


########################################################################
# 
# PATH additions
# 
########################################################################
alias vi=nvim
export VISUAL=nvim
export EDITOR="$VISUAL"

source "$HOME/.cargo/env"
export PATH="$PATH:$HOME/.local/bin"
export PATH="$PATH:/usr/local/lib/nodejs/bin"
export PATH="$PATH:/opt/nvim/bin"

alias d="sudo docker"
