Compare commits
3 Commits
d9b21ce70d
...
41f13f65d3
Author | SHA1 | Date |
---|---|---|
|
41f13f65d3 | |
|
e186fdf7db | |
|
79640e5a96 |
|
@ -169,21 +169,26 @@ export MAIL="timo42@proton.me"
|
|||
|
||||
export GOPATH="$HOME/go"
|
||||
|
||||
ld_lib_path_append "${LD_LIBRARY_PATH}:${HOME}/.local/lib"
|
||||
export LD_LIBRARY_PATH
|
||||
# ld_lib_path_append \
|
||||
# "${HOME}/.local/lib"
|
||||
# export LD_LIBRARY_PATH
|
||||
|
||||
path_prepend "/bin" \
|
||||
path_prepend \
|
||||
"/bin" \
|
||||
"/sbin" \
|
||||
"/usr/bin" \
|
||||
"/usr/sbin" \
|
||||
"/usr/local/bin" \
|
||||
"/usr/lcoal/sbin" \
|
||||
"/usr/local/games" \
|
||||
"/usr/local/sbin" \
|
||||
"/usr/games" \
|
||||
"/usr/local/games" \
|
||||
"/snap/bin" \
|
||||
|
||||
path_append \
|
||||
"${HOME}/bin" \
|
||||
"${HOME}/.bin" \
|
||||
"${HOME}/.local/bin" \
|
||||
"${HOME}/.local/include" \
|
||||
"${HOME}/.local/sbin" \
|
||||
"${HOME}/.brew/bin" \
|
||||
"${GOPATH}/bin"
|
||||
export PATH
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#! /bin/bash --
|
||||
# ex: set ts=4 sw=4 ft=sh
|
||||
|
||||
# TODO: Test on solaris (and other unices). Many tools will fail since we're not considering /usr/xpg4/bin
|
||||
|
||||
# Exit when noninteractive. This is more portable than checking PS1.
|
||||
[ "${-#*i}" = "${-}" ] && return
|
||||
|
||||
|
@ -52,6 +54,73 @@ hash -r
|
|||
unalias -a
|
||||
unset POSIXLY_CORRECT
|
||||
|
||||
################################# environment ##################################
|
||||
export EDITOR="$({ type -P nvim ||
|
||||
type -P vim ||
|
||||
type -P vi ||
|
||||
type -P nvi ||
|
||||
type -P hx ||
|
||||
type -P nano ||
|
||||
type -P ex ||
|
||||
type -P ed ; } 2>/dev/null)"
|
||||
export GIT_SSH_COMMAND='ssh -oIdentitiesOnly=yes -F"${HOME-}"/.ssh/config'
|
||||
export LANG='en_US.UTF-8'
|
||||
export USER="${USER:-$(whoami)}"
|
||||
export VISUAL="${EDITOR-}"
|
||||
export SUDO_EDITOR="${EDITOR-}"
|
||||
export XDG_RUNTIME_DIR="/run/user/$(id -u)"
|
||||
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
|
||||
export GIT_CONFIG_GLOBAL="$HOME/.gitconfig"
|
||||
export GPG_TTY="$(tty)"
|
||||
export _JAVA_AWT_WM_NONREPARENTING="1"
|
||||
export USER42="tischmid"
|
||||
export EMAIL42="timo42@proton.me"
|
||||
export MAIL="timo42@proton.me"
|
||||
export GOPATH="$HOME/go"
|
||||
export MANPAGER='nvim +Man!'
|
||||
# export MANPAGER='less -X'
|
||||
export BAT_THEME='gruvbox-dark'
|
||||
# export BAT_THEME='gruvbox-light'
|
||||
export PATH
|
||||
export LD_LIBRARY_PATH
|
||||
|
||||
if ! [ -n "${USER-}" ] ; then
|
||||
if ! USER="$(2>/dev/null ps -o user= -p "${$}" | awk '{print $1}')" ; then
|
||||
if ! USER="$(2>/dev/null whoami)" ; then
|
||||
if ! USER="$(2>/dev/null id -u -n)"; then
|
||||
if ! USER="$(basename -- "$(HOME=~ && printf %s "${HOME}")")" ; then
|
||||
if ! USER="$(2>/dev/null logname)" ; then
|
||||
if USER="${LOGNAME-}" ; [ -z "${USER}" ] ; then
|
||||
unset USER
|
||||
fi; fi; fi; fi; fi; fi; fi
|
||||
|
||||
if ! [ -n "${HOME-}" ] ; then
|
||||
if ! HOME="$(getent passwd "$(id -u "${USER}")" | cut -d: -f6)" ; then
|
||||
if ! HOME="$(getent passwd "${UID}" | cut -d: -f6)" ; then
|
||||
if ! HOME="$(awk -v FS=':' -v user="${USER}" '($1==user) {print $6}' "/etc/passwd")" ; then
|
||||
unset HOME
|
||||
HOME=~
|
||||
if [ "${HOME}" = "~" ] ; then
|
||||
if ! mkdir "/tmp/${USER}" && HOME="/tmp/${USER}" ; then
|
||||
unset HOME
|
||||
fi; fi ; fi ; fi ; fi; fi
|
||||
|
||||
[ -n "${DISPLAY-}" ] || log.warn 'DISPLAY not set'
|
||||
|
||||
if [ ! "${TERM-}" = "linux" ] ; then
|
||||
if [ -f '/usr/share/terminfo/x/xterm-256color' ] ; then
|
||||
export TERM='xterm-256color'
|
||||
elif [ -f '/usr/share/terminfo/x/xterm-color' ] ; then
|
||||
export TERM='xterm-color'
|
||||
elif [ -f '/usr/share/terminfo/x/xterm' ] ; then
|
||||
export TERM='xterm'
|
||||
elif [ -f '/usr/share/terminfo/s/screen-256color' ] ; then
|
||||
export TERM='screen-256color'
|
||||
elif [ -f '/usr/share/terminfo/s/screen' ] ; then
|
||||
export TERM='screen'
|
||||
fi
|
||||
fi
|
||||
|
||||
######################## path append & prepend (posix) #########################
|
||||
pathvarprepend () {
|
||||
# prepending paths to pathvar denoted by the expansion of the PATHVAR parameter
|
||||
|
@ -207,21 +276,22 @@ readonly BASH_SESSION_NAME="${$}"
|
|||
HISTSIZE='-1'
|
||||
HISTFILESIZE='-1'
|
||||
REAL_HISTFILE="${HOME}/.better_bash_history/.bash_history_$(printf "%(%Y-%m-%d)T")_daily"
|
||||
REAL_HISTDIR="$(dirname -- "${REAL_HISTFILE}")"
|
||||
HISTFILE="${HOME}/.better_bash_history/.bash_history_$(printf '%(%Y-%m-%d-%H-%M-%S)T')_${BASH_SESSION_NAME}"
|
||||
HISTDIR="$(dirname -- "$HISTFILE")"
|
||||
HISTDIR="$(dirname -- "${HISTFILE}")"
|
||||
HISTTIMEFORMAT=$'\033[m%F %T: '
|
||||
HISTCONTROL='ignoreboth'
|
||||
history -c
|
||||
history -r -- "${REAL_HISTFILE}"
|
||||
write_history () {
|
||||
[ -d "${REAL_HISTFILE}" ] || { rm -f -- "$(dirname -- "${REAL_HISTFILE}")" && mkdir -p -- "$(dirname -- "${REAL_HISTFILE}")" ; }
|
||||
[ -d "${REAL_HISTDIR}" ] || { rm -f -- "${REAL_HISTDIR}" && mkdir -p -- "${REAL_HISTDIR}" ; }
|
||||
[ -f "${HISTFILE}" ] &&
|
||||
[ -r "${HISTFILE}" ] &&
|
||||
<"${HISTFILE}" 1>/dev/null tee -a -- "${REAL_HISTFILE}" &&
|
||||
rm -f -- "${HISTFILE}"
|
||||
} && trap 'write_history' EXIT
|
||||
|
||||
############################# VIM ALIASES (posix) ##############################
|
||||
############################# vim aliases (posix) ##############################
|
||||
if _have nvim ; then
|
||||
alias vi="$(_path_lookup nvim)"
|
||||
elif _have vim ; then
|
||||
|
@ -532,46 +602,7 @@ clone42 () {
|
|||
} || { printf '%s\n' "Could not clone repo!" ; }
|
||||
}
|
||||
|
||||
################################# ENVIRONMENT ##################################
|
||||
export GIT_SSH_COMMAND='ssh -oIdentitiesOnly=yes -F"${HOME-}"/.ssh/config'
|
||||
|
||||
export LANG='en_US.UTF-8'
|
||||
export USER="${USER:-$(whoami)}"
|
||||
|
||||
export EDITOR="$({ type -P nvim ||
|
||||
type -P vim ||
|
||||
type -P vi ||
|
||||
type -P nvi ||
|
||||
type -P hx ||
|
||||
type -P nano ||
|
||||
type -P ex ||
|
||||
type -P ed ; } 2>/dev/null)"
|
||||
export VISUAL="${EDITOR-}"
|
||||
export SUDO_EDITOR="${EDITOR-}"
|
||||
|
||||
export MANPAGER='nvim +Man!'
|
||||
# export MANPAGER='less -X'
|
||||
|
||||
export BAT_THEME='gruvbox-dark'
|
||||
# export BAT_THEME='gruvbox-light'
|
||||
|
||||
[ -n "${DISPLAY-}" ] || log.warn 'DISPLAY not set'
|
||||
|
||||
if [ ! "${TERM-}" = "linux" ] ; then
|
||||
if [ -f '/usr/share/terminfo/x/xterm-256color' ] ; then
|
||||
export TERM='xterm-256color'
|
||||
elif [ -f '/usr/share/terminfo/x/xterm-color' ] ; then
|
||||
export TERM='xterm-color'
|
||||
elif [ -f '/usr/share/terminfo/x/xterm' ] ; then
|
||||
export TERM='xterm'
|
||||
elif [ -f '/usr/share/terminfo/s/screen-256color' ] ; then
|
||||
export TERM='screen-256color'
|
||||
elif [ -f '/usr/share/terminfo/s/screen' ] ; then
|
||||
export TERM='screen'
|
||||
fi
|
||||
fi
|
||||
|
||||
################################ BASH PRE-EXEC #################################
|
||||
################################ bash pre-exec #################################
|
||||
if [ ! -f "${HOME}"/.bash-preexec.sh ] ; then
|
||||
curl -sfkSL "https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh" -o "${HOME}"/.bash-preexec.sh
|
||||
fi
|
||||
|
@ -603,7 +634,7 @@ precmd() {
|
|||
fi
|
||||
}
|
||||
|
||||
#################################### PROMPT ####################################
|
||||
#################################### prompt ####################################
|
||||
GIT_PS1_SHOWDIRTYSTATE='1'
|
||||
GIT_PROMPT='1'
|
||||
if [ ! -f "${HOME}"/git-prompt.sh ] && [ "${GIT_PROMPT-}" -eq "1" ] ; then
|
||||
|
@ -648,7 +679,7 @@ fi
|
|||
# Show shell level
|
||||
# PS1='[${SHLVL}] '"${PS1}"
|
||||
|
||||
# ##################################### AOC ######################################
|
||||
# ##################################### aoc ######################################
|
||||
AOC_DIR="${HOME}/projects/aoc" # remember to change this to whatever your AOC directory is
|
||||
alias aos='< in.txt python3 solution.py'
|
||||
alias aot='< test.txt printf '\033[34m' ; python3 solution.py ; printf '\033[m''
|
||||
|
@ -759,7 +790,7 @@ aocload () {
|
|||
tmux send-keys "nvim './solution.py'" ENTER
|
||||
}
|
||||
|
||||
############################## TERMINAL SETTINGS ###############################
|
||||
############################## terminal settings ###############################
|
||||
tabs -4
|
||||
set -o emacs
|
||||
_have lesspipe && eval "$(SHELL=/bin/sh lesspipe)"
|
||||
|
@ -771,7 +802,10 @@ _have xset && 2>/dev/null xset r rate 200 60
|
|||
# Disable bell
|
||||
_have xset && 2>/dev/null xset -b
|
||||
|
||||
################################# COMPLETIONS ##################################
|
||||
################################# completions ##################################
|
||||
complete -F _command vimw
|
||||
complete -C backup_dir backup_dir
|
||||
complete -C backup_file backup_file
|
||||
|
||||
################################### sources ####################################
|
||||
_source_if "${HOME}/.userbashrc"
|
||||
|
|
|
@ -1 +1,6 @@
|
|||
0 * * * * /home/tosuman/.local/bin/system_update.sh
|
||||
# PATH="${PATH:+$PATH:}${HOME}/.local/bin"
|
||||
WHATEVER="$(echo hi)"
|
||||
* * * * * echo $PATH > tmp.txt
|
||||
* * * * * echo $WHATEVER > tmp2.txt
|
||||
# 0 * * * * /home/tosuman/.local/bin/system_update.sh
|
||||
# * * * * * PATH="$PATH:" /home/tosuman/.local/bin/backup_file /home/tosuman/
|
||||
|
|
|
@ -24,7 +24,7 @@ def main() -> int:
|
|||
input("Press any key to exit")
|
||||
return 1
|
||||
matches = re.findall(URL_REGEX, pane_out.decode())
|
||||
sp.run([os.environ['HOME'] + '/.local/bin/tui_choice.sh'] + matches)
|
||||
sp.run([os.environ['HOME'] + '/.local/bin/tui_choice'] + matches)
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
#! /bin/sh -
|
||||
# Depends on GNU cp, log.err
|
||||
|
||||
############################### completion start ###############################
|
||||
options='--no-chattr --no-sudo'
|
||||
if [ -n "${COMP_LINE}" ] ; then
|
||||
if [ "${1}" = "${3}" ] && [ ! "${2#-}" = "${2}" ] ; then
|
||||
for option in $options ; do
|
||||
case "${option}" in
|
||||
"${2}"*) printf '%s\n' "${option}" ;;
|
||||
esac
|
||||
done
|
||||
elif [ "${2#-}" = "${2}" ] ; then
|
||||
find "$(dirname -- "${2}")" -mindepth 1 -maxdepth 1 -path "$(dirname -- "${2}")/$(basename -- "${2}")*"
|
||||
fi
|
||||
exit
|
||||
fi
|
||||
################################ completion end ################################
|
||||
|
||||
############################ argument parsing start ############################
|
||||
no_chattr=0
|
||||
no_sudo=0
|
||||
while : ; do
|
||||
case "${1}" in
|
||||
--no-chattr|-c) no_chattr=1 ;;
|
||||
--no-sudo|-s) no_sudo=1 ;;
|
||||
-*) log.err "Invalid option argument: '${1}'" ; exit 1 ;;
|
||||
*) break ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
test "${#}" -ne "2" && { log.err "Usage: backup_dir [--no-chattr] [--no-sudo] BACKUP_DIR DIR" ; exit 1 ; }
|
||||
|
||||
backupdir="${1:-${HOME}/backups}"
|
||||
srcdir="${2}"
|
||||
############################# argument parsing end #############################
|
||||
|
||||
if [ "${no_sudo}" = "1" ] ; then
|
||||
sudo_cmd=""
|
||||
else
|
||||
sudo_cmd="sudo --"
|
||||
fi
|
||||
|
||||
backupname="$(basename -- "$srcdir")"
|
||||
|
||||
[ -d "${srcdir}" ] || { log.err "Directory '${srcdir}' does not exist" ; exit 2 ; }
|
||||
[ -d "${backupdir}" ] || mkdir -p -- "${backupdir}" || { log.err "Backup Directory '${backupdir}' couldn't be created" ; exit 3 ; }
|
||||
|
||||
if [ -e "${backupdir}/${backupname}" ] && [ "${no_chattr}" = "0" ] ; then
|
||||
$sudo_cmd chattr -i "${backupdir}/${backupname}" || { log.err "Can't chattr -i '${backupdir}/${backupname}'" ; exit 4 ; }
|
||||
fi
|
||||
tar --backup=t -cvzf "${backupdir}/${backupname}" "${srcdir}" || { log.err "Can't tar --backup=t -cvzf '${backupdir}/${backupname}' '${srcdir}'" ; exit 5 ; }
|
||||
|
||||
if [ "${no_chattr}" = "0" ] ; then
|
||||
$sudo_cmd find "${backupdir}" -mindepth 1 -exec chattr +i {} + || { log.err "Can't chattr +i some files" ; exit 6 ; }
|
||||
fi
|
|
@ -0,0 +1,57 @@
|
|||
#! /bin/sh -
|
||||
# Depends on GNU cp, log.err
|
||||
|
||||
############################### completion start ###############################
|
||||
options='--no-chattr --no-sudo'
|
||||
if [ -n "${COMP_LINE}" ] ; then
|
||||
if [ "${1}" = "${3}" ] && [ ! "${2#-}" = "${2}" ] ; then
|
||||
for option in $options ; do
|
||||
case "${option}" in
|
||||
"${2}"*) printf '%s\n' "${option}" ;;
|
||||
esac
|
||||
done
|
||||
elif [ "${2#-}" = "${2}" ] ; then
|
||||
find "$(dirname -- "${2}")" -mindepth 1 -maxdepth 1 -path "$(dirname -- "${2}")/$(basename -- "${2}")*"
|
||||
fi
|
||||
exit
|
||||
fi
|
||||
################################ completion end ################################
|
||||
|
||||
############################ argument parsing start ############################
|
||||
no_chattr=0
|
||||
no_sudo=0
|
||||
while : ; do
|
||||
case "${1}" in
|
||||
--no-chattr|-c) no_chattr=1 ;;
|
||||
--no-sudo|-s) no_sudo=1 ;;
|
||||
-*) log.err "Invalid option argument: '${1}'" ; exit 1 ;;
|
||||
*) break ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
test "${#}" -ne "2" && { log.err "Usage: backup_dir [--no-chattr] [--no-sudo] BACKUP_DIR DIR" ; exit 1 ; }
|
||||
|
||||
backupdir="${1:-${HOME}/backups}"
|
||||
srcfile="${2}"
|
||||
############################# argument parsing end #############################
|
||||
|
||||
if [ "${no_sudo}" = "1" ] ; then
|
||||
sudo_cmd=""
|
||||
else
|
||||
sudo_cmd="sudo --"
|
||||
fi
|
||||
|
||||
backupname="$(basename -- "$srcfile")"
|
||||
|
||||
[ -f "${srcfile}" ] || { log.err "Regular File '${srcfile}' does not exist" ; exit 2 ; }
|
||||
[ -d "${backupdir}" ] || mkdir -p -- "${backupdir}" || { log.err "Backup Directory '${backupdir}' couldn't be created" ; exit 3 ; }
|
||||
|
||||
if [ -e "${backupdir}/${backupname}" ] && [ "${no_chattr}" = "0" ] ; then
|
||||
$sudo_cmd chattr -i "${backupdir}/${backupname}" || { log.err "Can't chattr -i '${backupdir}/${backupname}'" ; exit 4 ; }
|
||||
fi
|
||||
cp --backup=t "${srcfile}" "${backupdir}/${backupname}" || { log.err "Can't cp --backup=t '${srcfile}' '${backupdir}/${backupname}'" ; exit 5 ; }
|
||||
|
||||
if [ "${no_chattr}" = "0" ] ; then
|
||||
$sudo_cmd find "${backupdir}" -mindepth 1 -exec chattr +i {} + || { log.err "Can't chattr +i some files" ; exit 6 ; }
|
||||
fi
|
Loading…
Reference in New Issue