# .bashrc 3/14/2025 <swaggboi@gangstalking.agency>

# Interactive shell check (the way Slackware does it)
if shopt -q login_shell; then
    /usr/games/fortune
    echo
fi

## Aliases ##

alias l='ls -blhF'
alias la='ls -balhF'
alias grep='grep -E'
alias ..='cd ..'
alias p='cat'
alias n='cat -n'
alias digg='dig +nocl +short +noshort'
alias emacs='emacs -nw'
alias gpg='gpg -a'
alias cdm='cd $HOME/misc'
alias h='echo $HOME'
#alias open='xdg-open'

if command -v netcat > /dev/null 2>&1; then
    alias nc='netcat -v -z'
elif command -v nc > /dev/null 2>&1; then
    alias nc='nc -v -z'
fi

if command -v doas > /dev/null 2>&1; then
    alias sudo='doas'
fi

## Exports ##

# For Perl/CPAN
if [ -d $HOME/perl5 ]; then
    export PATH="/home/daniel/perl5/bin${PATH:+:${PATH}}"
    export PERL5LIB="/home/daniel/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"
    export PERL_LOCAL_LIB_ROOT="/home/daniel/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"
    export PERL_MB_OPT="--install_base \"/home/daniel/perl5\""
    export PERL_MM_OPT="INSTALL_BASE=/home/daniel/perl5"

    # For perlbrew
    if [ -r $HOME/perl5/perlbrew/etc/bashrc ]; then
        . $HOME/perl5/perlbrew/etc/bashrc
    fi
fi

# For Raku/zef
if [ -d $HOME/.raku/bin ]; then
    export PATH="$HOME/.raku/bin:$PATH"
fi

if command -v rakubrew > /dev/null 2>&1; then
    eval "$(rakubrew init Bash)"
fi

# For Ruby/rbenv
# If not installed globally, see if it's installed locally
if ! command -v rbenv > /dev/null 2>&1; then
    if [ -d $HOME/.rbenv/bin ]; then
        export PATH="$HOME/.rbenv/bin:$PATH"
    fi

    if [ -d $HOME/.rbenv/plugins/ruby-build/bin ]; then
        export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
    fi
fi
# If we have rbenv now, set up the environment
if command -v rbenv > /dev/null 2>&1; then
    eval "$(rbenv init -)"
fi

# Editor
if command -v emacs > /dev/null 2>&1; then
    export EDITOR='emacs -nw'
elif command -v mg > /dev/null 2>&1; then
    export EDITOR='mg'
fi

export PKG_PATH="http://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/10.1/All/"

export PS1='\u@\h:\w\$ '

## Misc ##

# Prevent line wrapping mess
shopt -s checkwinsize