Files
daniel fusser beeefb13a7 initial commit
2026-06-21 15:35:58 +02:00

212 lines
8.3 KiB
Plaintext

export HISTFILESIZE=10000
export HISTCONTROL=ignoredups
export HISTFILE=$HOME/.cache/mksh_history
export PAGER="less"
export FCEDIT=nvim
export EDITOR="nvim"
export WORDCHARS="*?_-.[]~=&!#$%^(){}<>"
export QUOTING_STYLE=literal
ulimit -c unlimited
stty -ixon
bind '^l'=clear-screen
bind '^k'=kill-line
bind '^j'=kill-to-eol
bind '^e'=edit-line
# alias dot='/usr/bin/git --work-tree=$DOTS --git-dir=$DOTS/.git'
\\builtin alias c='clear' q='exit' df='df -h'
\\builtin alias ..='cd ..' ...='cd ../..'
\\builtin alias cp='cp -r' scp='scp -r' rm='rm -r'
\\builtin alias rscp='rsync -aP --inplace --progress --human-readable' rsmv='rscp --remove-source-files --force'
\: "${MKSH:=$(\\builtin whence -p mksh)}${MKSH:=/bin/mksh}"
\\builtin export MKSH
\\builtin export SHELL=$MKSH MANWIDTH=80 LESSHISTFILE=-
\\builtin alias cls='\\builtin print -n \\ec'
\: "${EDITOR:=/bin/ed}${TERM:=vt100}${USER:=$(\\builtin ulimit -c 0; id -un \
2>/dev/null)}${HOSTNAME:=$(\\builtin ulimit -c 0; hostname 2>/dev/null)}"
[[ $HOSTNAME = ?(?(ip6-)localhost?(6)) ]] && HOSTNAME=nil;
\\builtin export EDITOR HOSTNAME TERM USER="${USER:-?}"
# paths
export PATH=$HOME/.config/bin:$PATH
export PATH=$HOME/.local/bin:$PATH
export PATH=$HOME/.local/bin/sh:$PATH
test -d $HOME/.local/share/nvim/mason/bin && export PATH=$HOME/.local/share/mason/bin:$PATH
test -r ~/.config/local_paths && source ~/.config/local_paths
# colors
txtblk="$(tput setaf 0 2>/dev/null || echo '\e[0;30m')" # Black
txtred="$(tput setaf 1 2>/dev/null || echo '\e[0;31m')" # Red
txtgrn="$(tput setaf 2 2>/dev/null || echo '\e[0;32m')" # Green
txtylw="$(tput setaf 3 2>/dev/null || echo '\e[0;33m')" # Yellow
txtblu="$(tput setaf 4 2>/dev/null || echo '\e[0;34m')" # Blue
txtpur="$(tput setaf 5 2>/dev/null || echo '\e[0;35m')" # Purple
txtcyn="$(tput setaf 6 2>/dev/null || echo '\e[0;36m')" # Cyan
txtwht="$(tput setaf 7 2>/dev/null || echo '\e[0;37m')" # White
txtgry="$(tput setaf 8 2>/dev/null || echo '\e[0;38m')" # Gray
# Bold
bld="$(tput bold 2>/dev/null || echo '\e[1m')"
# italics
ita="$(tput sitm 2>/dev/null || echo '\e[3m')"
# Underline
und="$(tput smul 2>/dev/null || echo '\e[4m')"
# Reset
rst="$(tput sgr 0 2>/dev/null || echo '\e[0m')" # Text Reset
# rust
export PATH=$PATH:$HOME/.cargo/bin
# go
# export GOSRC=~/bin/go/src
export GOPATH=$HOME/.local/share/go
export CGO_CFLAGS="-g -O2 -Wno-return-local-addr"
export CGO_ENABLED=0
export PATH=$PATH:$GOPATH/bin
# npm
# export NPM_PACKAGES="${HOME}/.cache/npm-packages"
# npm config set prefix "$NPM_PACKAGES"
export NPM_PACKAGES="${HOME}/.local/share/npm"
export PATH="$PATH:$NPM_PACKAGES/bin"
export PATH="$PATH:${HOME}/.npm-packages/bin"
# ls TODO: $(dircolors ..)
export LS_COLORS='no=00:rs=0:fi=01;37:di=01;37;40:ln=01;36:mh=04;36:pi=03;31:so=04;33:do=04;01;36:bd=01;33:cd=33:or=31:mi=01;37;41:ex=01;33:su=01;04;37:sg=01;04;37:ca=01;37:tw=01;37;44:ow=01;04;34:st=04;37;44:*.c=01;32:*.h=01;35:*.sh=01;32:*.rc=01;32:*.md=01;35:*.txt=30:*~=30:*.bak=30:*.BAK=30:*.log=30:*.log=30:*.old=30:*.OLD=30:*.orig=30:*.ORIG=30:*.swo=30:*.swp=30:*.7z=01;31:*.ace=01;31:*.alz=01;31:*.arc=01;31:*.arj=01;31:*.bz=01;31:*.bz2=01;31:*.cab=01;31:*.cpio=01;31:*.deb=01;31:*.dz=01;31:*.ear=01;31:*.gz=01;31:*.jar=01;31:*.lha=01;31:*.lrz=01;31:*.lz=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.lzo=01;31:*.rar=01;31:*.rpm=01;31:*.rz=01;31:*.sar=01;31:*.t7z=01;31:*.tar=01;31:*.taz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tgz=01;31:*.tlz=01;31:*.txz=01;31:*.tz=01;31:*.tzo=01;31:*.tzst=01;31:*.war=01;31:*.xz=01;31:*.z=01;31:*.Z=01;31:*.zip=01;31:*.zoo=01;31:*.zst=01;31:*.aac=02;37:*.au=02;37:*.flac=02;37:*.m4a=02;37:*.mid=02;37:*.midi=02;37:*.mka=02;37:*.mp3=02;37:*.mpa=02;37:*.mpeg=02;37:*.mpg=02;37:*.ogg=02;37:*.opus=02;37:*.ra=02;37:*.wav=02;37:*.bmp=02;37:*.cgm=02;37:*.dl=02;37:*.dvi=02;37:*.emf=02;37:*.eps=02;37:*.gif=02;37:*.jpeg=02;37:*.jpg=02;37:*.JPG=02;37:*.mng=02;37:*.pbm=02;37:*.pcx=02;37:*.pgm=02;37:*.png=02;37:*.PNG=02;37:*.ppm=02;37:*.pps=02;37:*.ppsx=02;37:*.ps=02;37:*.svg=02;37:*.svgz=02;37:*.tga=02;37:*.tif=02;37:*.tiff=02;37:*.xbm=02;37:*.xcf=02;37:*.xpm=02;37:*.xwd=02;37:*.xwd=02;37:*.yuv=02;37:*.anx=02;37:*.asf=02;37:*.avi=02;37:*.axv=02;37:*.flc=02;37:*.fli=02;37:*.flv=02;37:*.gl=02;37:*.m2v=02;37:*.m4v=02;37:*.mkv=02;37:*.mov=02;37:*.MOV=02;37:*.mp4=02;37:*.mpeg=02;37:*.mpg=02;37:*.nuv=02;37:*.ogm=02;37:*.ogv=02;37:*.ogx=02;37:*.qt=02;37:*.rm=02;37:*.rmvb=02;37:*.swf=02;37:*.vob=02;37:*.webm=02;37:*.wmv=02;37:';
test -r ~/.dir_colors && eval $(dircolors ~/.dir_colors)
# -> eval $(dircolors "$XDG_CONFIG_HOME"/dircolors/dircolors)
\\builtin alias ls='ls --color=always --group-directories-first -h' l='ls ' la='l -a' ll='l -l' lo='l -alo'
# less
export LESS="-Q -R -C -i -j4 -M -PM?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x..%t"
export LESSBINFMT='*u[%X]'
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;40;37m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'
export LESSHISTFILE=$HOME/.cache/lesshist
# xdg dirs
export XDG_DATA_HOME=$HOME/.local/share
export XDG_CONFIG_HOME=$HOME/.config
export XDG_STATE_HOME=$HOME/.local/state
export XDG_CACHE_HOME=$HOME/.cache
# xdg fixes
export DOCKER_CONFIG="$XDG_CONFIG_HOME"/docker
export GNUPGHOME="$XDG_DATA_HOME"/gnupg
export LESSHISTFILE="$XDG_STATE_HOME"/less/history
export RUSTUP_HOME="$XDG_DATA_HOME"/rustup
export SQLITE_HISTORY="$XDG_CACHE_HOME"/sqlite_history
export NPM_CONFIG_USERCONFIG=$XDG_CONFIG_HOME/npm/npmrc
export W3M_DIR="~/.cache/w3m"
alias w3m='w3m -config ~/.config/w3m/config'
alias docker='doas docker'
# funcs
fcd() {
d=$(fd . -t directory ~ | fzf) && cd "${d}"
}
fapk() {
apk search -q "$@" | fzf -m | xargs -r apk add
}
weechat() {
docker ps -a --format '{{.Names}}' | grep "weechat" | xargs -r -o docker attach
}
dkr() {
if (( USER_ID )) ; then doas="doas" ; fi
cmd="docker $@"
[ -z "$@" ] && cmd="echo" # just echo containername if no subcommand is specified
$doas sh -c ". ~/.config/sh/fzf.sh ; docker ps -a --format 'table {{.Names}}\t{{.Status}}' | \
grep -E -v '^NAMES' | \
fzf -p -e -m | \
cut -f1 -d' ' | \
xargs -ro $cmd"
}
loop() { while true ; do $@; sleep 1; done ;}
# prompt
_prompt_git(){
# from polyglot.sh
GITREF="$(env git symbolic-ref --quiet HEAD 2> /dev/null)"
case $? in # See what the exit code is.
0) ;; # $GITREF contains the name of a checked-out branch.
128) return ;; # No Git repository here.
# Otherwise, see if HEAD is in a detached state.
*) GITREF="$(env git rev-parse --short HEAD 2> /dev/null)" || return ;;
esac
if [ -n "$GITREF" ]; then
GITSTATUS=$(LC_ALL=C GIT_OPTIONAL_LOCKS=0 env git status -uno 2>&1)
GITSYMBOLS=''
case $GITSTATUS in
*' have diverged,'*) GITSYMBOLS="${GITSYMBOLS}&*" ;;
esac
case $GITSTATUS in
*'Your branch is behind '*) GITSYMBOLS="${GITSYMBOLS}&" ;;
esac
case $GITSTATUS in
*'Your branch is ahead of '*) GITSYMBOLS="${GITSYMBOLS}*" ;;
esac
case $GITSTATUS in
*'new file: '*) GITSYMBOLS="${GITSYMBOLS}+" ;;
esac
case $GITSTATUS in
*'deleted: '*) GITSYMBOLS="${GITSYMBOLS}x" ;;
esac
case $GITSTATUS in
*'modified: '*)
GITSYMBOLS="${GITSYMBOLS}!"
;;
esac
case $GITSTATUS in
*'renamed: '*) GITSYMBOLS="${GITSYMBOLS}>" ;;
esac
case $GITSTATUS in
*'Untracked files:'*) GITSYMBOLS="${GITSYMBOLS}?" ;;
esac
[ -n "$GITSYMBOLS" ] && GITSYMBOLS="$GITSYMBOLS"
GITREF=${GITREF#refs/heads/main} # empty if main
printf "  %s%s" "${GITREF#refs/heads/}" "$GITSYMBOLS"
fi
unset GITREF GITSTATUS GITSYMBOLS
}
# prompts - modified from /etc/mkshrc
PS4='[$EPOCHREALTIME] '; PS1='#'; (( USER_ID )) && PS1='→'; PS1=$'\001\r''${|
\\builtin typeset e=$?
(( e )) && REPLY+="${txtred}$e${txtgry} "
{ ( [[ -n $SSH_CLIENT ]] || [[ -n $SSH_TTY ]] ) && [[ -z $TMUX ]] } && REPLY+="${ita}${txtgry}${HOSTNAME} ${rst}"
# REPLY+=${USER}@${HOSTNAME%%.*}:
\\builtin typeset d=${PWD:-?}/ p=~; [[ $p = ?(*/) ]] || d=${d/#$p\//\~/}
d=${d%/}; [[ -n $d ]] || d=/
case $d in
"~"|/) ;;
"~/"*/*) d=…/${d##*/} ;;
"~/"*) ;;
*) d=…/${d##*/} ;;
esac
REPLY+=${ita}${txtgry}$d
REPLY+="$(_prompt_git)${rst}"
print -n "\e]133;A\e\\" # foot sequence for ctrl+shift+x/z
\\builtin return $e
} '"${txtylw}${bld}$PS1 ${rst}"