Skip to content

bash

.bashrc

#  _               _
# | |__   __ _ ___| |__  _ __ ___
# | '_ \ / _` / __| '_ \| '__/ __|
# | |_) | (_| \__ \ | | | | | (__
# |_.__/ \__,_|___/_| |_|_|  \___|

# [[ $- == *i* ]] && source /usr/share/blesh/ble.sh --noattach

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

#export PATH="$(getconf PATH):/usr/local/bin:$HOME/bin"
export PATH="/usr/bin:/usr/local/bin:$HOME/bin"
[ -r /usr/share/bash-completion/bash_completion   ] && . /usr/share/bash-completion/bash_completion
source "/usr/share/doc/pkgfile/command-not-found.bash"
#source "/etc/profile.d/autojump.bash"
shopt -s autocd
shopt -s globstar
shopt -s extglob
# shopt -s failglob
shopt -s cmdhist
shopt -s lithist
shopt -s histappend
export HISTCONTROL=ignoredups:erasedups
export HISTTIMEFORMAT='%F %T '

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
export HISTSIZE=50000000
export HISTFILESIZE=100000


# BASH PS1
## colors
red=$(tput setaf 1)
brightred=$(tput setaf 9)
green=$(tput setaf 2)
brightgreen=$(tput setaf 10)
yellow=$(tput setaf 3)
brightyellow=$(tput setaf 11)
blue=$(tput setaf 4)
brightblue=$(tput setaf 12)
magenta=$(tput setaf 5)
brightmagenta=$(tput setaf 13)
cyan=$(tput setaf 6)
brightcyan=$(tput setaf 14)
black=$(tput setaf 0)
bright_black=$(tput setaf 8)
white=$(tput setaf 7)
brightwhite=$(tput setaf 15)
bold=$(tput bold)
normal=$(tput sgr0)
dim=$(tput dim)
reset=$(tput sgr0)

git-status-checker () {
    RESULT="$(git rev-parse --show-toplevel 2>/dev/null)"
    if ! [[ -z "$RESULT" ]];
    then
      BRANCH="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)"
      if [[ "$RESULT" == "$HOME" ]];
      then
    RESULT="~"
      else
    RESULT="$(basename $RESULT)"
      fi
      if [[ -z `git status --porcelain` ]];
      then
        echo -e " $green($RESULT : $BRANCH)$reset"
      else
        echo -e " $red($RESULT : $BRANCH)$reset"
      fi
    fi
}

SSH_TTY=${SSH_TTY:-`tty 2>/dev/null||readlink /proc/$$/fd/0 2>/dev/null`}

# PROMPT_COMMAND="history -a ; history -n ;$PROMPT_COMMAND"
export PS1="\[$white\]\d\[$yellow\] \W\[$reset\]\[$bold\]\$(git-status-checker)\[$reset\] [\[$blue\]\[$bold\]\u@\h\[$reset\]:${SSH_TTY/\/dev\/}:\j]\n\[$reset\]\[$brightblack\]\t\[$blue\] \$ \[$reset\]"

alias vim='nvim'

#alias tmux='env TERM=xterm-256color tmux'

# Launch TMUX

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options

alias ls='ls --color=auto'

#export FZF_DEFAULT_OPS="--extended"
[ -f ~/.fzf.bash ] && source ~/.fzf.bash

# FZF Stuff
EDITOR=nvim
export EDITOR

export FZF_DEFAULT_COMMAND='find -type f'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_DEFAULT_OPTS='-e --multi --bind ctrl-a:select-all,ctrl-d:deselect-all,ctrl-t:toggle,Home:preview-page-up,End:preview-page-down --preview-window=wrap'

# alias fzf_pyside_helper="fzf --preview 'py_helper.sh {}' --preview-window=right,70%"
alias fzf_pyside_helper="fzf --preview 'py_helper.sh {}'"


genpasswd () {
    echo -n @ && cat /dev/urandom | env LC_CTYPE=C tr -dc '[:alnum:]' | head -c 15 && echo
}

convert-transcript () {
  egrep -v '<|>' "$1" | egrep -v '^$' | tail --lines +5 | egrep [a-zA-Z0-9] | sed -n 'p;n' | xclip -i && echo 'Copied to clipboard!'
}

alias youtube-dl-proxy='youtube-dl --proxy socks5://localhost:1080'
alias youtube-dl-proxy2='youtube-dl --proxy socks5://localhost:2080'
alias curl-proxy='curl -x socks5h://localhost:5050'
alias tarot='find /home/vector/Pictures/Tarot -iname "*.jpg" | sort -R | xargs -r -d "\n" sxiv'

# Load fzf colors
if [ -f ~/.fzf.conf ]; then
  . ~/.fzf.conf
fi

# # Base16 shell
# if [ -f ~/.base16_theme ]; then
#   script_name=$(basename "$(realpath ~/.base16_theme)" .sh)
#   export BASE16_THEME=${script_name#*-}
#   . ~/.base16_theme
# fi
# 
# if [ -e "$HOME/base16/profile_helper.sh" ];
# then
#     eval "$($HOME/base16/profile_helper.sh)"
# fi

alias xclipco='xclip -o -selection clipboard'
alias npvim='nvim -c "set ft=python"'

# if command -v tmux >/dev/null 2>&1 && [ "${DISPLAY}" ] && [ -z "$TMUX" ]; then
#     # if not inside a tmux session, and if no session is started, start a new session
#     tmux;
# fi

alias nvdocsearch='grep -riIHn "" ~/.nvim/**/doc | fzfpreview'
alias pydocsearch='grep -riI "" ~/arch-pyside/src/build/sources/pyside6/doc/**/*.html | fzf'
alias pydocsearch-html='grep -riI "" ~/arch-pyside/src/build/sources/pyside6/doc/**/*.html | fzf'

alias lsp='printf "%s\n"'

alias fzfp="fzf --delimiter : --preview 'bat --style=full --color=always -H {2} {1}' --preview-window '~3,+{2}+3/2'"
alias home="ssh root@192.168.220.1 'wpa_cli -i wlan0 select_network 0'"
alias ginkgo="ssh root@192.168.220.1 'wpa_cli -i wlan0 select_network 5'"
alias list_networks="ssh root@192.168.220.1 'wpa_cli -i wlan0 list_networks'"
alias pypro='python <(cat <<\EOF'

pkgbuild-template () {
    cat <<-'EOF'
        # Maintainer: Rebel@Vectorspace <resonyze@gmail.com>
        pkgname=restview
        pkgver=v2.2.r5.gbf3480d
        pkgrel=1
        pkgdesc="A viewer for ReStructuredText documents that renders them on the fly."
        arch=('x86_64')
        url="https://github.com/mgedmin/restview"
        license=('GPL3')
        depends=('python-docutils' 'python-pygments' 'python-readme-renderer' 'python-setuptools')
        makedepends=('git')
        #replaces=('libxfce4menu')
        #conflicts=('exo')
        source=("${pkgname}"::"git+https://github.com/mgedmin/restview.git")
        # source=("${pkgname}.deb"::"https://repository-origin.spotify.com/pool/non-free/s/spotify-client/spotify-client_1.1.84.716.gc5f8b819_amd64.deb")
        # source=("${pkgname}.deb")
        # noextract=("${pkgname}.deb")
        sha256sums=('SKIP')

        source=("${pkgname}"::"git+https://github.com/thermitegod/spacefm.git"
        "git+https://github.com/thermitegod/ztd.git"
        "git+https://github.com/thermitegod/alphanumeric.git")
        sha256sums=('SKIP'
            'SKIP'
            'SKIP')

        prepare () {
            cd "${pkgname}"
            # This command reads from .gitmodules in the current directory
            git submodule init
            # third_party/ztd refers to one the entries in .gitmodules file
            # third_party/ztd.url refers to its url property
            git config submodule.third_party/ztd.url "$srcdir/ztd"
            git config submodule.third_party/alphanumeric.url "$srcdir/alphanumeric"
            git submodule update
            mkdir -p build
        }


        build() {
          cd "${srcdir}/${pkgname}"
          python setup.py build
        }

        pkgver() {
          cd "$pkgname"
          git describe --long | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
          git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
          printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
        }

        package() {
          cd "${srcdir}/${pkgname}"
          # python setup.py install --skip-build --root="${pkgdir}"/
          # nvim -es --cmd ":helptags doc" --cmd ":q"
          # python setup.py install --optimize=1 --root="$pkgdir/" --prefix=/usr --skip-build
          # tar -xf "data.tar.gz" -C "$pkgdir"
          # install -Dm755 ../HiFile.AppImage "${pkgdir}/usr/bin/hifile"
          # install -Dm644 ../PKGBUILD "${pkgdir}/opt/HiFile/PKGBUILD"
        }
    EOF
}

pkgbuild-template2 () {
    cat <<-'EOF'
        # Maintainer: Hexchain Tong <i at hexchain dot org>
        pkgname=neovim-remote
        pkgver=2.5.0
        pkgrel=1
        pkgdesc="Support --remote and friends for Neovim"
        arch=(any)
        url="https://github.com/mhinz/neovim-remote"
        license=('MIT')
        depends=('python-pynvim' 'python-psutil')
        makedepends=('git' 'python-setuptools')
        source=("$pkgname-$pkgver.tar.gz::https://github.com/mhinz/neovim-remote/archive/v$pkgver.tar.gz")
        sha256sums=('3ad1c060688e102b2580d01c0360918113021788b0fcc3ac08bb7fc71b4f7658')

        build() {
          cd "$srcdir/$pkgname-$pkgver"
          python setup.py build
        }

        package() {
          cd "$srcdir/$pkgname-$pkgver"
          python setup.py install --optimize=1 --root="$pkgdir/" --prefix=/usr --skip-build
          install -Dm644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
          install -Dm644 contrib/completion.bash "$pkgdir/usr/share/bash-completion/completions/neovim-remote"
          install -Dm644 README.md -t "$pkgdir/usr/share/doc/$pkgname/"
        }
    EOF
}

alias search='grep -riI "" * | fzf'
export QT_QPA_PLATFORMTHEME=qt5ct

Comments