all repos — dotfiles-base @ 03882a3f6b43542b45f5b8edfbf37809a1a467d0

base important configs that can safely be used almost anywhere

Misc. changes, add helix and fish configs
x1phosura x1phosura@x1phosura.zone
Tue, 24 Sep 2024 01:18:00 -0700
commit

03882a3f6b43542b45f5b8edfbf37809a1a467d0

parent

3f59ae560626f07e91f0920400065322ef1f7006

M .bash_profile.bash_profile

@@ -11,7 +11,6 @@ #fi

# rust [ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env" - # opam configuration test -r /home/x1phosura/.opam/opam-init/init.sh && . /home/x1phosura/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true
M .bashrc.bashrc

@@ -11,6 +11,11 @@

# If not running interactively, don't do anything [[ $- != *i* ]] && return +############################################################################ + # SWITCH TO FISH SHELL # + exec fish +############################################################################ + # source global bashrc settings (turned off by default, uncomment otherwise) # [ -f /etc/bashrc ] && source /etc/bashrc

@@ -255,6 +260,8 @@ echo "usage: sync-src-to-dest [src-dir/] [dest-dir/]"

return 1 fi + # for syncing to Android phone + #rsync -rlgo -vhcz -e ssh --stats --progress --delete --force "$1" "$2" rsync -avhcz -e ssh --stats --progress --delete --force "$1" "$2" }

@@ -332,18 +339,21 @@ alias iso-date='date --iso-8601=s '

alias now='date +%s ' alias gdb='gdb -q ' # muzzle gdb alias local_webserver='python -m http.server 8001 ' # can change port number -alias hx='/usr/lib/helix/hx ' +#alias hx='/usr/lib/helix/hx ' +alias hx='helix ' # may be battery_BAT0 alias bat-stat='upower -i /org/freedesktop/UPower/devices/battery_BAT1 | grep --color=never -E "state|to full|percentage"' +alias reload-udev-rules='sudo udevadm control --reload-rules && sudo udevadm trigger' # config editing aliases alias bashrc="$EDITOR ~/.bashrc" alias vimrc="$EDITOR ~/.vimrc" alias init_lua="$EDITOR ~/.config/nvim/init.lua" -alias helix_config="$EDITOR ~/.config/helix/config.toml" +alias helix_config="helix ~/.config/helix/config.toml" alias nanorc="nano ~/.config/nano/nanorc" # just for fun! alias i3config="$EDITOR ~/.config/i3/config && i3-msg reload && i3-msg restart" -# TODO: sway config +#alias swayconfig="$EDITOR ~/.config/sway/config && swaymsg reload" +alias swayconfig="cd ~/.config/sway && $EDITOR config" not_in_vim="echo -e \"You're not in vim doofus!\"" alias :wq="$not_in_vim" ; alias :q="$not_in_vim" ; alias :x="$not_in_vim"
A .config/fish/bashrc_aliases

@@ -0,0 +1,56 @@

+## use 'nvim' if it exists on system +#if [ command -v nvim &> /dev/null ]; then +# export EDITOR='vim' +#else +# export EDITOR='nvim' +# alias vim='nvim ' +#fi + +# miscellaneous aliases +alias cl='clear ' +alias e='exit ' +alias q='exit ' +alias DIE='shutdown now ' +alias cp='cp -i ' # confirm before overwriting a file +alias df='df -h ' +alias fucking='sudo ' +alias bc='bc -l ' # makes bc use 'scale=20' by default +alias rot13="tr 'A-Za-z' 'N-ZA-Mn-za-m' " +alias iso-date='date --iso-8601=s ' +alias now='date +%s ' +alias gdb='gdb -q ' # muzzle gdb +alias local_webserver='python -m http.server 8001 ' # can change port number +#alias hx='/usr/lib/helix/hx ' +alias hx='helix ' +# may be battery_BAT0 +alias bat-stat='upower -i /org/freedesktop/UPower/devices/battery_BAT1 | grep --color=never -E "state|to full|percentage"' +alias reload-udev-rules='sudo udevadm control --reload-rules && sudo udevadm trigger' + +# config editing aliases +alias bashrc="$EDITOR ~/.bashrc" +alias config_fish="$EDITOR ~/.config/fish/config.fish" +alias vimrc="$EDITOR ~/.vimrc" +alias init_lua="$EDITOR ~/.config/nvim/init.lua" +alias helix_config="helix ~/.config/helix/config.toml" +alias nanorc="nano ~/.config/nano/nanorc" # just for fun! +alias i3config="$EDITOR ~/.config/i3/config && i3-msg reload && i3-msg restart" +alias i3config="$EDITOR ~/.config/i3/config && i3-msg reload && i3-msg restart" +#alias swayconfig="$EDITOR ~/.config/sway/config && swaymsg reload" +alias swayconfig="cd ~/.config/sway && $EDITOR config" + +#not_in_vim="echo -e \"You're not in vim doofus!\"" +#alias :wq="$not_in_vim" ; alias :q="$not_in_vim" ; alias :x="$not_in_vim" +#alias ZZ="$not_in_vim" + +# TODO make abbreviations +#alias rager='ranger '; alias anger='ranger '; alias range='ranger ' +#alias rangre='ranger '; alias rangr='ranger ' # <<<-^^^-: common ranger typos + +#[ "$operating_system" = "linux" ] && alias spellcheck='aspell check ' + +alias ls="ls --color=auto " +alias l="ls --color=auto " +alias ll="ls -lh --color=auto " +alias la="ls -A --color=auto " +alias lla="ls -lhA --color=auto " +
A .config/fish/bashrc_functions

@@ -0,0 +1,198 @@

+############################## user functions ############################## + +# find-keyword [directory path] [keyword]: find and list files with keyword in +# the filename +find-keyword() { + if [ "$#" -ne 2 ]; then # if not given 2 arguments + echo "Usage: find-keyword [directory path] [keyword]" + else + find $1 -name "*$2*" -ls + fi +} + +# find-string [string] [directory path]: find and list files containing the +# provided string (and list all occurences/line numbers of the string) +find-string() { + if [ "$#" -ne 2 ]; then # if not given 2 arguments + echo "Usage: find-string [string] [directory path]" + else + grep -nR "$1" "$2" + fi +} + +# img_loop_here: $1 = seconds until next photo displayed +# BUG: currently, after running this function, the user needs to manually run +# 'reset' to unscrew the terminal +img-loop-here() { + if [ "$1" = "" ]; then + echo "Usage: img_loop_here [seconds until next photo displayed]" + else + while true; do + for g in $(ls .); do + timeout "$1" chafa -c full "$g" + done + done + fi +} + +# rainbow-shell: print out a looping rainbow in the shell. Happy pride month! +# For best results, run in full-screened terminal (Mod+f in i3) +rainbow-shell() { + yes "$(seq 231 -1 16)" | while read i; do + printf "\x1b[48;5;${i}m\n" + sleep .02 + done +} + +# colors - print out current color values set in terminal +colors() { + local fgc bgc vals seq0 + + printf "Color escapes are %s\n" '\e[${value};...;${value}m' + printf "Values 30..37 are \e[33mforeground colors\e[m\n" + printf "Values 40..47 are \e[43mbackground colors\e[m\n" + printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n" + + # foreground colors + for fgc in {30..37}; do + # background colors + for bgc in {40..47}; do + fgc=${fgc#37} # white + bgc=${bgc#40} # black + + vals="${fgc:+$fgc;}${bgc}" + vals=${vals%%;} + + seq0="${vals:+\e[${vals}m}" + printf " %-9s" "${seq0:-(default)}" + printf " ${seq0}TEXT\e[m" + printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m" + done + echo; echo + done +} + +# term-color-vals: print all 256-bit color values in their associated color +term-color-vals() { + for i in {0..255}; do + printf "\x1b[38;5;${i}mcolor%-5i\x1b[0m" $i + if ! (( ($i + 1 ) % 8 )); then + echo + fi + done +} + +# ex - archive extractor +# usage: ex <file> +ex() { + if [ -f $1 ] ; then + case $1 in + *.tar.bz2) tar xjf $1 ;; + *.tar.gz) tar xzf $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) unrar x $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xf $1 ;; + *.tbz2) tar xjf $1 ;; + *.tgz) tar xzf $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1 ;; + *.7z) 7z x $1 ;; + *) echo "'$1' cannot be extracted via ex()" ;; + esac + else + echo "'$1' is not a valid file" + fi +} + +# prune_bash_history - remove certain frequently-used/"clutter" command entries +# from .bash_history +prune_bash_history() { +sed 's/^l$//g ; s/^ll$//g ; s/^la$//g ; s/^lla$//g ; s/^cl$//g ; s/^range$//g ; s/^e$//g ; s/^q$//g ; /^$/d ' \ + "$HOME"/.bash_history > \ + "$HOME"/.bash_history-BAK + if [ -f "$HOME"/.bash_history-BAK ]; then + mv "$HOME"/.bash_history-BAK "$HOME"/.bash_history + else + echo "[ERROR] .bash_history-BAK was not created. Aborting..." + fi +} + +# public-ip: fetch current public IP address +public-ip() { + curl 'http://icanhazip.com/' + #curl 'https://j3s.sh/ip.html' +} + +# scan-for-printers: look for printers on the connected LAN +scan-for-printers() { + sudo lpinfo -v +} + +# wifi-strength: get some WiFi statistics in real time +wifi-strength() { + watch -n 1 cat /proc/net/wireless +} + +sync-src-to-dest() { + if [ ! "$#" = 2 ]; then + echo "A useful rsync helper, semi-unsafe if used thoughtlessly" + echo "usage: sync-src-to-dest [src-dir/] [dest-dir/]" + return 1 + fi + + # for syncing to Android phone + #rsync -rlgo -vhcz -e ssh --stats --progress --delete --force "$1" "$2" + rsync -avhcz -e ssh --stats --progress --delete --force "$1" "$2" +} + +# STILL has one edge case (if argument contains '..' AND goes through symlink) +mkcd() { + [ -z "$1" ] && return 1 + case "$1" in /*) :;; *) set -- "./$1";; esac # for weird directories "-xx/" + mkdir "$1" && cd "$1" +} + +# create executable file containing 'sh' shebang +touch-script() { + if [ "$#" = 0 ]; then + echo "usage: $0 [path(s) to one or more script file(s) to init...] " + return 1 + else + touch "$@" + chmod +x "$@" + for f in "$@"; do + printf '#!/bin/sh\n\n' > "$f" + done + fi +} + +# pick file path with fzf, open in $EDITOR +fzvim() { + file_path="$(fzf)" + if [ -e "$file_path" ]; then + echo "Editing $file_path..." + "$EDITOR" "$file_path" + elif [ "$file_path" = "" ]; then # no entries chosen from fzf + : # do nothing + else + echo "$file_path not found." + fi +} + +# Note: has a limit of like 10k or something, I forget +hex2bin() { + if [ "$#" = 0 ]; then + echo "usage: $0 [path of file containing hex digits to bindump]" + return 1 + fi + sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' "$1" | xargs printf +} + +bin2hex() { + if [ "$#" = 0 ]; then + echo "usage: $0 [path of file to hexdump]" + return 1 + fi + hexdump -v -e '1/1 "%02x"' "$1" +}
A .config/fish/config.fish

@@ -0,0 +1,6 @@

+# x1phosura's fish config + +if status is-interactive + # Commands to run in interactive sessions can go here + set -U fish_greeting # can also use '-g' (TODO decide which to use) +end
A .config/fish/fish_variables

@@ -0,0 +1,32 @@

+# This file contains fish universal variable definitions. +# VERSION: 3.0 +SETUVAR __fish_initialized:3400 +SETUVAR fish_color_autosuggestion:brblack +SETUVAR fish_color_cancel:\x2dr +SETUVAR fish_color_command:blue +SETUVAR fish_color_comment:red +SETUVAR fish_color_cwd:green +SETUVAR fish_color_cwd_root:red +SETUVAR fish_color_end:green +SETUVAR fish_color_error:brred +SETUVAR fish_color_escape:brcyan +SETUVAR fish_color_history_current:\x2d\x2dbold +SETUVAR fish_color_host:normal +SETUVAR fish_color_host_remote:yellow +SETUVAR fish_color_normal:normal +SETUVAR fish_color_operator:brcyan +SETUVAR fish_color_param:cyan +SETUVAR fish_color_quote:yellow +SETUVAR fish_color_redirection:cyan\x1e\x2d\x2dbold +SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_status:red +SETUVAR fish_color_user:brgreen +SETUVAR fish_color_valid_path:\x2d\x2dunderline +SETUVAR fish_greeting:\x1d +SETUVAR fish_key_bindings:fish_default_key_bindings +SETUVAR fish_pager_color_completion:normal +SETUVAR fish_pager_color_description:yellow\x1e\x2di +SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline +SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan +SETUVAR fish_pager_color_selected_background:\x2dr
A .config/fish/functions/DIE.fish

@@ -0,0 +1,4 @@

+function DIE --wraps='shutdown now ' --description 'alias DIE=shutdown now ' + shutdown now $argv + +end
A .config/fish/functions/bashrc.fish

@@ -0,0 +1,4 @@

+function bashrc --wraps='nvim ~/.bashrc' --description 'alias bashrc=nvim ~/.bashrc' + nvim ~/.bashrc $argv + +end
A .config/fish/functions/bat-stat.fish

@@ -0,0 +1,4 @@

+function bat-stat --wraps='upower -i /org/freedesktop/UPower/devices/battery_BAT1 | grep --color=never -E "state|to full|percentage"' --description 'alias bat-stat=upower -i /org/freedesktop/UPower/devices/battery_BAT1 | grep --color=never -E "state|to full|percentage"' + upower -i /org/freedesktop/UPower/devices/battery_BAT1 | grep --color=never -E "state|to full|percentage" $argv + +end
A .config/fish/functions/bc.fish

@@ -0,0 +1,4 @@

+function bc --description 'alias bc=bc -l ' + command bc -l $argv + +end
A .config/fish/functions/cl.fish

@@ -0,0 +1,4 @@

+function cl --wraps='clear ' --description 'alias cl=clear ' + clear $argv + +end
A .config/fish/functions/config_fish.fish

@@ -0,0 +1,4 @@

+function config_fish --wraps='nvim ~/.config/fish/config.fish' --description 'alias config_fish=nvim ~/.config/fish/config.fish' + nvim ~/.config/fish/config.fish $argv + +end
A .config/fish/functions/cp.fish

@@ -0,0 +1,4 @@

+function cp --description 'alias cp=cp -i ' + command cp -i $argv + +end
A .config/fish/functions/df.fish

@@ -0,0 +1,4 @@

+function df --description 'alias df=df -h ' + command df -h $argv + +end
A .config/fish/functions/e.fish

@@ -0,0 +1,4 @@

+function e --wraps='exit ' --description 'alias e=exit ' + exit $argv + +end
A .config/fish/functions/fucking.fish

@@ -0,0 +1,4 @@

+function fucking --wraps='sudo ' --description 'alias fucking=sudo ' + sudo $argv + +end
A .config/fish/functions/gdb.fish

@@ -0,0 +1,4 @@

+function gdb --description 'alias gdb=gdb -q ' + command gdb -q $argv + +end
A .config/fish/functions/helix_config.fish

@@ -0,0 +1,4 @@

+function helix_config --wraps='helix ~/.config/helix/config.toml' --description 'alias helix_config=helix ~/.config/helix/config.toml' + helix ~/.config/helix/config.toml $argv + +end
A .config/fish/functions/hx.fish

@@ -0,0 +1,4 @@

+function hx --wraps='helix ' --description 'alias hx=helix ' + helix $argv + +end
A .config/fish/functions/i3config.fish

@@ -0,0 +1,4 @@

+function i3config --wraps='nvim ~/.config/i3/config && i3-msg reload && i3-msg restart' --description 'alias i3config=nvim ~/.config/i3/config && i3-msg reload && i3-msg restart' + nvim ~/.config/i3/config && i3-msg reload && i3-msg restart $argv + +end
A .config/fish/functions/init_lua.fish

@@ -0,0 +1,4 @@

+function init_lua --wraps='nvim ~/.config/nvim/init.lua' --description 'alias init_lua=nvim ~/.config/nvim/init.lua' + nvim ~/.config/nvim/init.lua $argv + +end
A .config/fish/functions/iso-date.fish

@@ -0,0 +1,4 @@

+function iso-date --wraps='date --iso-8601=s ' --description 'alias iso-date=date --iso-8601=s ' + date --iso-8601=s $argv + +end
A .config/fish/functions/l.fish

@@ -0,0 +1,4 @@

+function l --wraps='ls --color=auto ' --description 'alias l=ls --color=auto ' + ls --color=auto $argv + +end
A .config/fish/functions/la.fish

@@ -0,0 +1,4 @@

+function la --wraps='ls -A --color=auto ' --description 'alias la=ls -A --color=auto ' + ls -A --color=auto $argv + +end
A .config/fish/functions/ll.fish

@@ -0,0 +1,4 @@

+function ll --wraps='ls -lh --color=auto ' --description 'alias ll=ls -lh --color=auto ' + ls -lh --color=auto $argv + +end
A .config/fish/functions/lla.fish

@@ -0,0 +1,4 @@

+function lla --wraps='ls -lhA --color=auto ' --description 'alias lla=ls -lhA --color=auto ' + ls -lhA --color=auto $argv + +end
A .config/fish/functions/local_webserver.fish

@@ -0,0 +1,4 @@

+function local_webserver --wraps='python -m http.server 8001 ' --description 'alias local_webserver=python -m http.server 8001 ' + python -m http.server 8001 $argv + +end
A .config/fish/functions/nanorc.fish

@@ -0,0 +1,4 @@

+function nanorc --wraps='nano ~/.config/nano/nanorc' --description 'alias nanorc=nano ~/.config/nano/nanorc' + nano ~/.config/nano/nanorc $argv + +end
A .config/fish/functions/now.fish

@@ -0,0 +1,4 @@

+function now --wraps='date +%s ' --description 'alias now=date +%s ' + date +%s $argv + +end
A .config/fish/functions/q.fish

@@ -0,0 +1,4 @@

+function q --wraps='exit ' --description 'alias q=exit ' + exit $argv + +end
A .config/fish/functions/reload-udev-rules.fish

@@ -0,0 +1,4 @@

+function reload-udev-rules --wraps='sudo udevadm control --reload-rules && sudo udevadm trigger' --description 'alias reload-udev-rules=sudo udevadm control --reload-rules && sudo udevadm trigger' + sudo udevadm control --reload-rules && sudo udevadm trigger $argv + +end
A .config/fish/functions/rot13.fish

@@ -0,0 +1,4 @@

+function rot13 --wraps=tr\ \'A-Za-z\'\ \'N-ZA-Mn-za-m\'\ --description alias\ rot13=tr\ \'A-Za-z\'\ \'N-ZA-Mn-za-m\'\ + tr 'A-Za-z' 'N-ZA-Mn-za-m' $argv + +end
A .config/fish/functions/swayconfig.fish

@@ -0,0 +1,4 @@

+function swayconfig --wraps='cd ~/.config/sway && nvim config' --description 'alias swayconfig=cd ~/.config/sway && nvim config' + cd ~/.config/sway && nvim config $argv + +end
A .config/fish/functions/vimrc.fish

@@ -0,0 +1,4 @@

+function vimrc --wraps='nvim ~/.vimrc' --description 'alias vimrc=nvim ~/.vimrc' + nvim ~/.vimrc $argv + +end
A .config/helix/config.toml

@@ -0,0 +1,16 @@

+# helix config + +theme = "jellybeans" +#theme = "base16_transparent" +#theme = "rasmus" + +[editor] +mouse = true +line-number = "absolute" +rulers = [80] +color-modes = true + +[editor.soft-wrap] +enable = true +wrap-indicator = "" +
M .config/nvim/colors/x1ph-off.vim.config/nvim/colors/x1ph-off.vim

@@ -89,8 +89,8 @@ \ "cterm=" (has_key(a:style, "cterm") ? a:style.cterm : "NONE")

endfunction call s:h("Normal", {"bg": s:bg, "fg": s:norm}) -call s:h("Cursor", {"bg": s:blue, "fg": s:norm }) -call s:h("Comment", {"fg": s:bg_subtle_comment, "gui": "italic"}) +call s:h("Cursor", {"bg": s:blue, "fg": s:norm}) +call s:h("Comment", {"fg": s:bg_subtle_comment}) call s:h("Constant", {"fg": s:actual_white}) "hi! link Constant Normal
M .config/nvim/vimrc.vim.config/nvim/vimrc.vim

@@ -15,8 +15,9 @@

" TODO: check _if_ mypeachpuff exists, if not, use peachpuff set background=dark "colorscheme peachpuff -colorscheme x1ph-off " TODO: check _if_ x1ph-off exists, if not, use default +"colorscheme x1ph-off " TODO: check _if_ x1ph-off exists, if not, use default "colorscheme default +colorscheme lunaperche syntax on set guicursor= "force using block cursor (for neovim)
M place-dotfiles-base.shplace-dotfiles-base.sh

@@ -1,7 +1,5 @@

#!/bin/sh - # place-dotfiles-base.sh: simple script to symlink my core dotfiles -# TODO: currently doesn't work, needs updating # by x1phosura dotfiles_root="$HOME"/73h4x/dotfiles/dotfiles-base # where dotfiles live

@@ -26,7 +24,9 @@ .bashrc \

.gdbinit \ .lynxrc \ .tmux.conf \ -.config/nvim" +.config/fish \ +.config/nvim \ +.config/helix" # Note: directly symlink items to .config instead of symlinking .config itself # because I don't want to preserve everything that programs create there