# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

parse_git_branch() {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}

ect() {
  if [ "$#" -ne 0 ]; then
    echo "$1" | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo
  else
    cat /sys/devices/system/cpu/intel_pstate/no_turbo
  fi
}

off4() {
  for x in /sys/devices/system/cpu/cpu[4-7]*/online; do 
    echo 0 | sudo tee "$x"
  done
}

on() {
  for x in /sys/devices/system/cpu/cpu[0-7]*/online; do 
    echo 1 | sudo tee "$x"
  done
}

[ -z ${WSLENV+x} ] || export PATH="${PATH:+"$PATH:"}$HOME/bin"

# base16 config

#BASE16_SHELL="$HOME/.config/base16-shell/"
#[ -n "$PS1" ] && \
#    [ -s "$BASE16_SHELL/profile_helper.sh" ] && \
#        source "$BASE16_SHELL/profile_helper.sh"

# Aliases
# general aliases
alias ls='ls --color=auto'
alias vim='nvim'
alias tf='terraform'

# git aliases
alias ga='git add'
alias gcm='git commit -m'
alias gs='git status'
alias gp='git push'
alias gl='git log'

# config aliases
alias vimc='nvim ~/.config/nvim/init.lua'
alias wmc='nvim ~/.config/sway/config'

# asus tools aliases
alias sup='supergfxctl'

# alias zeditor to zed
alias zed='zeditor'

# Shell prompt

# Reset PS1 prompt everytime
resetPrompt() {
  printf "\e[6 q"
}

# Colors: https://misc.flogisoft.com/bash/tip_colors_and_formatting
PS1='$(resetPrompt)\[\e[1;36m\]\u ($HOSTNAME) \[\e[1;32m\]\w \[\e[0m\]$(parse_git_branch)\n\[\e[35m\]\[\e[1m\]\$ \[\e[0m\]'

# export editor
export EDITOR=nvim

# export pip path
export PATH=$PATH:~/.local/bin

# export composer path
export PATH=$PATH:~/.config/composer/vendor/bin

# android studio stuff
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

# flutter
export FLUTTER_HOME=$HOME/flutter
export PATH=$PATH:$FLUTTER_HOME/bin
export CHROME_EXECUTABLE=brave

# pnpm
export PNPM_HOME="/home/ayush/.local/share/pnpm"
export PATH="$PNPM_HOME:$PATH"

# composer globals
export PATH=$PATH:~/.config/composer

# nvm
source /usr/share/nvm/init-nvm.sh
