forked from VonHeikemen/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fce652f
commit f768e1f
Showing
5 changed files
with
325 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# ~/.bashrc: executed by bash(1) for non-login shells. | ||
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | ||
# for examples | ||
|
||
# If not running interactively, don't do anything | ||
case $- in | ||
*i*) ;; | ||
*) return;; | ||
esac | ||
|
||
# If set, the pattern "**" used in a pathname expansion context will | ||
# match all files and zero or more directories and subdirectories. | ||
#shopt -s globstar | ||
|
||
# make less more friendly for non-text input files, see lesspipe(1) | ||
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" | ||
|
||
# set variable identifying the chroot you work in (used in the prompt below) | ||
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then | ||
debian_chroot=$(cat /etc/debian_chroot) | ||
fi | ||
|
||
# enable color support of ls and also add handy aliases | ||
if [ -x /usr/bin/dircolors ]; then | ||
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" | ||
#alias ls='ls --color=auto' | ||
#alias dir='dir --color=auto' | ||
#alias vdir='vdir --color=auto' | ||
|
||
#alias grep='grep --color=auto' | ||
#alias fgrep='fgrep --color=auto' | ||
#alias egrep='egrep --color=auto' | ||
fi | ||
|
||
# enable programmable completion features (you don't need to enable | ||
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile | ||
# sources /etc/bash.bashrc). | ||
if ! shopt -oq posix; then | ||
if [ -f /usr/share/bash-completion/bash_completion ]; then | ||
. /usr/share/bash-completion/bash_completion | ||
elif [ -f /etc/bash_completion ]; then | ||
. /etc/bash_completion | ||
fi | ||
fi | ||
|
||
# Some setup | ||
. ~/my-configs/bash/rc.bash | ||
|
||
# Pretty prompt | ||
. ~/my-configs/bash/theme.bash | ||
|
||
# The Good Stuff | ||
. ~/my-configs/bash/aliases.bash | ||
|
||
# Custom functions | ||
. ~/my-configs/bash/custom-functions.bash | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env bash | ||
|
||
export PATH="$HOME/bin:$HOME/.npm-packages/bin:$PATH" | ||
export EDITOR='nvim' | ||
export PYTHONUSERBASE=~/.local | ||
export TERMINAL='kitty' | ||
export FZF_DEFAULT_COMMAND='rg --files --hidden --follow --glob "!.git/*" --glob "!cache/*" --glob "!node_modules/*"' | ||
export FZF_DEFAULT_OPTS='--layout=reverse --border' | ||
|
||
alias duh='du -d 1 -h' | ||
|
||
alias -- -='cd -' | ||
alias c1='cd ..' | ||
alias c2='cd ../..' | ||
alias c3='cd ../../..' | ||
alias c4='cd ../../../..' | ||
|
||
alias cl='clear' | ||
alias cp='cp -i' | ||
|
||
alias np='pnpm' | ||
alias npr='pnpm run' | ||
|
||
alias lzg='lazygit' | ||
|
||
alias ta='tmux attach -t' | ||
alias tl='tmux list-sessions' | ||
alias ts='tmux new-session -A -D -s' | ||
alias tmus='ts music "$(which cmus)"' | ||
|
||
alias pmd-start='ts pomodoro gone -e "notify-send -u critical Pomodoro Timeout"' | ||
alias pomd='gone -e "notify-send -u critical Pomodoro Timeout"' | ||
|
||
alias tvi='ts vi' | ||
alias vi-s='nvim -S Session.vim' | ||
|
||
alias dcc='docker-compose' | ||
|
||
alias doc-start='systemctl start docker' | ||
alias doc-ls='docker ps -a' | ||
|
||
# alias ls='ls --color=auto' | ||
# alias la='ls -lAh' | ||
alias ls='exa' | ||
alias la='exa --git --header --long --all' | ||
|
||
alias yt="youtube-dl -f 'bestvideo[height<=720]+bestaudio/best[height<=720]'" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Make directory then cd into it | ||
newdir () | ||
{ | ||
mkdir $1 | ||
cd $1 | ||
} | ||
|
||
# Give nnn the ability to cd into a directory | ||
ll () | ||
{ | ||
# Block nesting of nnn in subshells | ||
if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ]; then | ||
echo "nnn is already running" | ||
return | ||
fi | ||
|
||
# The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE is set) | ||
# To cd on quit only on ^G, remove the "export" as in: | ||
# NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd" | ||
# NOTE: NNN_TMPFILE is fixed, should not be modified | ||
export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd" | ||
|
||
# Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn | ||
# stty start undef | ||
# stty stop undef | ||
# stty lwrap undef | ||
# stty lnext undef | ||
|
||
nnn "$@" | ||
|
||
if [ -f "$NNN_TMPFILE" ]; then | ||
. "$NNN_TMPFILE" | ||
rm -f "$NNN_TMPFILE" > /dev/null | ||
fi | ||
} | ||
|
||
# Show how to burn an iso into a usb device | ||
burnusb () | ||
{ | ||
local device="99" | ||
local iso="99" | ||
|
||
for arg in "$@" | ||
do | ||
case "$arg" in | ||
-d=*|--device=*) | ||
device="${arg#*=}" | ||
shift;; | ||
-d|--device) | ||
device="$2" | ||
shift 2;; | ||
-i|--iso) | ||
iso="$2" | ||
shift 2;; | ||
-i=*|--iso=*) | ||
device="${arg#*=}" | ||
shift;; | ||
-h|--help) | ||
echo "\nUsage: $0 --device /device/path --iso /path/to/iso" | ||
echo "Might want to use \`fdisk -l\` or \`lsblk\` to check the available devices" | ||
return | ||
esac | ||
done | ||
|
||
if [ "$device" = "99" ]; | ||
then | ||
echo "\nMust provide a --device/-d parameter" | ||
return | ||
fi | ||
|
||
if [ "$iso" = "99" ]; | ||
then | ||
echo "\nMust provide a --iso/-i parameter" | ||
return | ||
fi | ||
|
||
local cmd="sudo dd bs=4M if=$iso of=$device status=progress oflag=sync" | ||
|
||
echo "\nUsing device $device" | ||
echo "Using image $iso\n" | ||
echo "This is the command you should use" | ||
echo "$cmd\n" | ||
} | ||
|
||
# Transform the arguments into a valid url querystring | ||
urlencode() | ||
{ | ||
local args="$@" | ||
jq -nr --arg v "$args" '$v|@uri'; | ||
} | ||
|
||
# Query duckduckgo | ||
duckduckgo() | ||
{ | ||
w3m "https://lite.duckduckgo.com/lite/?q=$(urlencode "$@")" | ||
} | ||
|
||
# Interactive scratchpad using neovim | ||
codi() | ||
{ | ||
if [ -z "$1" ];then | ||
echo "Must specify a language" | ||
return 1; | ||
fi | ||
|
||
local syntax="${1}" | ||
shift | ||
nvim -c \ | ||
"set bt=nofile ls=0 noru nonu nornu |\ | ||
Codi $syntax" "$@" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Append to the history file, don't overwrite it | ||
shopt -s histappend | ||
|
||
# Save multi-line commands as one command | ||
shopt -s cmdhist | ||
|
||
# use readline on history | ||
shopt -s histreedit | ||
|
||
# load history line onto readline buffer for editing | ||
shopt -s histverify | ||
|
||
# save history with newlines instead of ; where possible | ||
shopt -s lithist | ||
|
||
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) | ||
HISTSIZE=1000 | ||
HISTFILESIZE=2000 | ||
|
||
# Avoid duplicate entries | ||
HISTCONTROL="erasedups:ignoreboth" | ||
|
||
# Don't record some commands | ||
export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history:clear" | ||
|
||
# check the window size after each command and, if necessary, | ||
# update the values of LINES and COLUMNS. | ||
shopt -s checkwinsize | ||
|
||
# Prepend cd to directory names automatically | ||
shopt -s autocd 2> /dev/null | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env bash | ||
|
||
black="\[\e[0;30m\]" | ||
red="\[\e[0;31m\]" | ||
green="\[\e[0;32m\]" | ||
yellow="\[\e[0;33m\]" | ||
blue="\[\e[0;34m\]" | ||
purple="\[\e[0;35m\]" | ||
cyan="\[\e[0;36m\]" | ||
white="\[\e[0;37m\]" | ||
orange="\[\e[0;91m\]" | ||
|
||
bold_black="\[\e[30;1m\]" | ||
bold_red="\[\e[31;1m\]" | ||
bold_green="\[\e[32;1m\]" | ||
bold_yellow="\[\e[33;1m\]" | ||
bold_blue="\[\e[34;1m\]" | ||
bold_purple="\[\e[35;1m\]" | ||
bold_cyan="\[\e[36;1m\]" | ||
bold_white="\[\e[37;1m\]" | ||
bold_orange="\[\e[91;1m\]" | ||
|
||
normal="\[\e[0m\]" | ||
reset_color="\[\e[39m\]" | ||
|
||
STATUS_THEME_PROMPT_BAD="${bold_red}❯${reset_color}${normal} " | ||
STATUS_THEME_PROMPT_OK="${bold_purple}❯${reset_color}${normal} " | ||
|
||
# This can do the same thing `_dirtrim` does | ||
# but it only works on Bash 4+ | ||
# PROMPT_DIRTRIM=3 | ||
|
||
_dirtrim() | ||
{ | ||
echo "$1" | rev | cut -d"/" -f1-3 | rev | ||
} | ||
|
||
_git_current_branch() | ||
{ | ||
local ref | ||
ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null) | ||
local ret=$? | ||
if [[ $ret != 0 ]]; then | ||
[[ $ret == 128 ]] && return # no git repo. | ||
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return | ||
fi | ||
echo ${ref#refs/heads/} | ||
} | ||
|
||
_git_state() | ||
{ | ||
if [ -z "$(git status -s)" ];then # it's "clean" | ||
echo "${green}✔" | ||
else | ||
echo "${red}✗" | ||
fi | ||
} | ||
|
||
_git_info() | ||
{ | ||
if git rev-parse --git-dir > /dev/null 2>&1; then | ||
echo "${green}$(_git_current_branch) $(_git_state)${reset_color}" | ||
fi | ||
} | ||
|
||
_myprompt() | ||
{ | ||
local ret_status="$( [ $? -eq 0 ] && echo -e "$STATUS_THEME_PROMPT_OK" || echo -e "$STATUS_THEME_PROMPT_BAD")" | ||
PS1="\n${blue}\$(_dirtrim \"\w\") $(_git_info)\n${ret_status}" | ||
} | ||
|
||
PROMPT_COMMAND=_myprompt |