diff --git a/bashrc b/bashrc deleted file mode 100644 index 9eed99f..0000000 --- a/bashrc +++ /dev/null @@ -1,140 +0,0 @@ -#!/bin/bash -# tavo custom bashrc file -# If not running interactively, don't do anything -[[ $- != *i* ]] && return - -# Prompt -PS1='\[\e[0;1;91m\][\[\e[0;1;38;5;87m\]\u\[\e[0;0;38;5;123m\]@\[\e[0;0;38;5;159m\]\h \[\e[0;38;5;247m\]\w\[\e[0;1;91m\]]\n \[\e[0;38;5;247m\]$ \[\e[0m\]' -PROMPT_COMMAND="echo" # Line jump after every command - -# General configs -PATH="$HOME/.config/scripts${PATH:+:${PATH}}" # Enables custom scripts dir -PATH="$HOME/.config/scripts/menu${PATH:+:${PATH}}" -PATH="$HOME/.config/scripts/status${PATH:+:${PATH}}" -bind "set completion-ignore-case on" # Case insensitive TAB complete -shopt -s cdspell # Autocorrect directory name -shopt -s autocd # cd into dir by typing the name -set -o vi # vi mode - -# $HOME cleanup -export \ - XDG_STATE_HOME="$HOME/.local/state" \ - XDG_CACHE_HOME="$HOME/.local/cache" \ - XDG_DATA_HOME="$HOME/.local/share" \ - XDG_CONFIG_HOME="$HOME/.config" \ - PASSWORD_STORE_DIR="$XDG_DATA_HOME/password-store" \ - GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0" \ - MINETEST_USER_PATH="$XDG_DATA_HOME/minetest" \ - VIMINIT="source $XDG_CONFIG_HOME/vim/vimrc" \ - XSERVERRC="$XDG_CONFIG_HOME/X11/xserverrc" \ - XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority" \ - HISTFILE="$XDG_STATE_HOME/bash_history" \ - XINITRC="$XDG_CONFIG_HOME/X11/xinitrc" \ - LESSHISTFILE="$XDG_DATA_HOME/lesshst" \ - WGETRC="$XDG_CONFIG_HOME/wget/wgetrc" \ - ELECTRUMDIR="$XDG_DATA_HOME/electrum" \ - CUDA_CACHE_PATH="$XDG_CACHE_HOME/nv" \ - BASH_ENV="$XDG_CONFIG_HOME/bashrc" \ - GNUPGHOME="$XDG_DATA_HOME/gnupg" \ - -# Aliases -alias \ - prt="cd $HOME/Media/Pictures/Screenshots/ && ls" \ - bkg="cd $HOME/Media/Pictures/Backgrounds/ && ls" \ - vid="cd $HOME/Media/Videos/ && ls" \ - img="cd $HOME/Media/Pictures/ && ls" \ - tmp="cd $HOME/Desktop/temp/ && ls" \ - www="cd $HOME/Desktop/www/ && ls" \ - src="cd $HOME/.local/src/ && ls" \ - doc="cd $HOME/Documents/ && ls" \ - dow="cd $HOME/Downloads/ && ls" \ - prj="cd $HOME/Projects/ && ls" \ - dsk="cd $HOME/Desktop/ && ls" \ - cfg="cd $HOME/.config/ && ls" \ - mus="cd $HOME/Music/ && ls" \ - ent="cd /mnt/Entr/ && ls" \ - fzf-edit-script="fzf_nav /home/$(whoami)/.config/scripts" \ - ls="exa -al --group-directories-first" \ - fzf="fzf --cycle --reverse" \ - newsboat="newsboat -u ~/Documents/personal/rss" \ - diff="diff --color=auto" \ - grep="grep --color=auto" \ - notes="note list" \ - def="dict" \ - calc="bc -l" \ - cp="cp -iv" \ - mv="mv -iv" \ - rm="rm -iv" \ - vim="nvim" \ - -# Useful variables -export \ - GITLAB="ssh://git@gitlab.com/tavo-wasd" \ - QT_QPA_PLATFORMTHEME="qt5ct" \ - GTK_THEME="Materia:dark" \ - WEEK=$(date '+%U') \ - DATE=$(date -I) \ - -# DE opts -# Clipboard -export \ - CM_SELECTIONS="clipboard" \ - CM_MAX_CLIPS=10 \ -# Default programs -export \ - OPENER="xdg-open" \ - READER="zathura" \ - BROWSER="brave" \ - TERMINAL="st" \ - EDITOR="nvim" \ - VISUAL="nvim" \ - IMAGE="sxiv" \ - VIDEO="mpv" \ - -# Functions & binds -fzf_nav() { -[ -d "$1" ] && cd "$1" -# Fun POSIX way of listing stuff -while true ; do - opt=$(/usr/bin/ls -AF1 --group-directories-first) - opt=$(printf "../\n$opt" | fzf --cycle --reverse --padding 2% --preview 'p {}') - [ -d "$opt" ] && cd "$opt" > /dev/null 2>&1 || break -done -ls -[ -n "$opt" ] && printf "\nOpen $opt? [Y/n]: " && read -r open || return 0 -[ "$open" != "n" ] && o "$opt" || return 0 -} - -note() { -# Just edit today's note if no argument is given -[ -z "$1" ] && cd ~/Documents/notes && $EDITOR $HOME/Documents/notes/note-$DATE.md && exit -# 'list' arg will list notes either with fzf or regular ls -if [ "$1" = "list" ] ; then - cd ~/Documents/notes - # If fzf is present, use it, ls otherwise - [ -e '/usr/bin/fzf' ] || ls && fzf_nav -fi -} - -copy_output() { -history 50 | sed 's/[0-9]*\s\s//g' | tac | dmenu -i -p "Copy output:" | $SHELL | xsel -ib -} - -bind '"\C-e":"dragon -x \*\C-m"' -bind '"\C-y":"copy_output\C-m"' -bind '"\C-f":"fzf_nav\C-m"' - -# Autostart dwm after tty login -type systemctl 2>/dev/null 1>&2 && if systemctl -q is-active graphical.target && [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then - cat ~/.config/snippets/welcome - sleep 0.5 - amixer - exec startx -fi - -# nice login prompt -if [ -e "/usr/bin/afetch" -o -e "/usr/local/bin/afetch" ] ; then - afetch -else - fetch min -fi diff --git a/shell/aliasrc b/shell/aliasrc new file mode 100644 index 0000000..79aa277 --- /dev/null +++ b/shell/aliasrc @@ -0,0 +1,30 @@ +#!/bin/bash + +alias \ + prt="cd $HOME/Media/Pictures/Screenshots/ && ls" \ + bkg="cd $HOME/Media/Pictures/Backgrounds/ && ls" \ + img="cd $HOME/Media/Pictures/ && ls" \ + vid="cd $HOME/Media/Videos/ && ls" \ + mus="cd $HOME/Media/Music/ && ls" \ + tmp="cd $HOME/Desktop/local/temp/ && ls" \ + www="cd $HOME/Desktop/www/ && ls" \ + src="cd $HOME/.local/src/ && ls" \ + doc="cd $HOME/Documents/ && ls" \ + dow="cd $HOME/Downloads/ && ls" \ + prj="cd $HOME/Projects/ && ls" \ + dsk="cd $HOME/Desktop/ && ls" \ + cfg="cd $HOME/.config/ && ls" \ + ent="cd /mnt/Entr/ && ls" \ + fzf-edit-script="fzf_nav /home/$(whoami)/.config/scripts" \ + ls="exa -al --group-directories-first" \ + fzf="fzf --cycle --reverse" \ + newsboat="newsboat -u ~/Documents/personal/rss" \ + diff="diff --color=auto" \ + grep="grep --color=auto" \ + notes="note list" \ + def="dict" \ + calc="bc -l" \ + cp="cp -iv" \ + mv="mv -iv" \ + rm="rm -iv" \ + vim="nvim" \ diff --git a/shell/bashrc b/shell/bashrc new file mode 100644 index 0000000..f65f4e2 --- /dev/null +++ b/shell/bashrc @@ -0,0 +1,39 @@ +#!/bin/bash +# tavo custom bashrc file +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +# Prompt +PS1='\[\e[0;1;91m\][\[\e[0;1;38;5;87m\]\u\[\e[0;0;38;5;123m\]@\[\e[0;0;38;5;159m\]\h \[\e[0;38;5;247m\]\w\[\e[0;1;91m\]]\n \[\e[0;38;5;247m\]$ \[\e[0m\]' +PROMPT_COMMAND="echo" # Line jump after every command + +# General configs +PATH="$HOME/.config/scripts${PATH:+:${PATH}}" # Enables custom scripts dir +PATH="$HOME/.config/scripts/menu${PATH:+:${PATH}}" +PATH="$HOME/.config/scripts/status${PATH:+:${PATH}}" +bind "set completion-ignore-case on" # Case insensitive TAB complete +shopt -s cdspell # Autocorrect directory name +shopt -s autocd # cd into dir by typing the name +set -o vi # vi mode + +# External configs +source ~/.config/shell/xdgspec +source ~/.config/shell/envvar +source ~/.config/shell/aliasrc +source ~/.config/shell/functions + +# Binds +bind '"\C-f":"fzf_nav\C-m"' +bind '"\C-y":"copy_output\C-m"' +bind '"\C-e":"dragon -x \*\C-m"' + +# Autostart dwm after tty login +type systemctl 2>/dev/null 1>&2 && if systemctl -q is-active graphical.target && [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then + cat ~/.config/snippets/welcome + sleep 0.5 + amixer + exec startx +fi + +# nice login prompt +[ -e "/usr/bin/afetch" ] && afetch || fetch min diff --git a/shell/envvar b/shell/envvar new file mode 100644 index 0000000..9f1f860 --- /dev/null +++ b/shell/envvar @@ -0,0 +1,30 @@ +#!/bin/bash +# Useful variables + +# Common +export \ + GIT="ssh://git@gitlab.com/tavo-wasd" \ + WEEK=$(date '+%U') \ + DATE=$(date -I) \ + +# Default programs +export \ + OPENER="xdg-open" \ + READER="zathura" \ + BROWSER="brave" \ + TERMINAL="st" \ + EDITOR="nvim" \ + VISUAL="nvim" \ + IMAGE="sxiv" \ + VIDEO="mpv" \ + +# Theming +export \ + QT_QPA_PLATFORMTHEME="qt5ct" \ + GTK_THEME="Materia:dark" \ + +# Clipboard +export \ + CM_SELECTIONS="clipboard" \ + CM_MAX_CLIPS=10 \ + diff --git a/shell/functions b/shell/functions new file mode 100644 index 0000000..84d0328 --- /dev/null +++ b/shell/functions @@ -0,0 +1,37 @@ +#!/bin/bash + +# Navigate using fzf +fzf_nav() { +[ -d "$1" ] && cd "$1" +while true ; do + opt=$(/usr/bin/ls -AF1 --group-directories-first) + opt=$(printf "../\n$opt" | fzf --cycle --reverse --padding 2% --preview 'p {}') + [ -d "$opt" ] && cd "$opt" > /dev/null 2>&1 || break +done +ls +[ -n "$opt" ] && printf "\nOpen $opt? [Y/n]: " && read -r open || return 0 +[ "$open" != "n" ] && o "$opt" || return 0 +} + +# EZ note taking +note() { +# Just edit today's note if no argument is given +[ -z "$1" ] && cd ~/Documents/notes && $EDITOR $HOME/Documents/notes/note-$DATE.md && exit +# 'list' arg will list notes either with fzf or regular ls +if [ "$1" = "list" ] ; then + cd ~/Documents/notes + # If fzf is present, use it, ls otherwise + [ -e '/usr/bin/fzf' ] || ls && fzf_nav +fi +} + +# Copy output of a command +copy_output() { +history 50 | + sed 's/[0-9]*\s\s//g' | + grep -v 'copy_output' | + tac | + menu "Copy output:" | + $SHELL | + xsel -ib +} diff --git a/shell/xdgspec b/shell/xdgspec new file mode 100644 index 0000000..9a64a4f --- /dev/null +++ b/shell/xdgspec @@ -0,0 +1,18 @@ +#!/bin/bash + +export \ + BASH_ENV="$XDG_CONFIG_HOME/shell/bashrc" \ + XDG_STATE_HOME="$HOME/.local/state" \ + XDG_CACHE_HOME="$HOME/.local/cache" \ + XDG_DATA_HOME="$HOME/.local/share" \ + XDG_CONFIG_HOME="$HOME/.config" \ + GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0" \ + VIMINIT="source $XDG_CONFIG_HOME/vim/vimrc" \ + XSERVERRC="$XDG_CONFIG_HOME/X11/xserverrc" \ + XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority" \ + HISTFILE="$XDG_STATE_HOME/bash_history" \ + XINITRC="$XDG_CONFIG_HOME/X11/xinitrc" \ + LESSHISTFILE="$XDG_DATA_HOME/lesshst" \ + WGETRC="$XDG_CONFIG_HOME/wget/wgetrc" \ + ELECTRUMDIR="$XDG_DATA_HOME/electrum" \ + CUDA_CACHE_PATH="$XDG_CACHE_HOME/nv" \