Update shell & dirs config
This commit is contained in:
parent
67c41eef73
commit
498978ddbc
|
@ -1,29 +1,40 @@
|
||||||
|
#! /usr/bin/make
|
||||||
# Shell configuration for Zsh, works almost completely for Bash as well
|
# Shell configuration for Zsh, works almost completely for Bash as well
|
||||||
|
|
||||||
export LESS=-R
|
export LESS=-R
|
||||||
export LC_MESSAGES=C
|
alias info='info --vi-keys'
|
||||||
|
|
||||||
export DIST=$(lsb_release --id | cut -d' ' -f2)
|
export DIST=$(lsb_release --id | cut -d' ' -f2)
|
||||||
|
|
||||||
# Some aliases
|
# Some aliases
|
||||||
alias println='printf "\n"'
|
alias println='printf "\n"'
|
||||||
|
|
||||||
|
# find pruning avoids permission denied errors - see https://unix.stackexchange.com/a/121020/272449
|
||||||
|
alias conf='find ~/.config/nvim ~/.config ~/.gradle/gradle.properties /etc -type d ! \( -readable \) -prune -o -type f -print | fzf --tiebreak=end,index --preview "bat --color=always --style=numbers --line-range :500 {}" --bind "enter:execute(test -O {} && $EDITOR {} || sudoedit {}),del:execute(gio trash {})"'
|
||||||
alias editgrub='sudoedit /etc/default/grub && sudo update-grub'
|
alias editgrub='sudoedit /etc/default/grub && sudo update-grub'
|
||||||
alias editenv='sudoedit /etc/environment'
|
alias editenv='sudoedit /etc/environment'
|
||||||
|
editshell() {
|
||||||
|
nvim $(test $# -lt 1 && echo "$SHELL_FUNCTIONS" || (results=$(find "$dropbox_path/tools/setup" -maxdepth 1 -name "$1.sh") && test "$results" && echo "$results") || echo "$(dirname $SHELL_FUNCTIONS)/$1") && r
|
||||||
|
}
|
||||||
|
|
||||||
|
alias graphics='lspci -vnn | grep VGA --color=never'
|
||||||
|
|
||||||
alias startMinecraftServer='curl https://ipinfo.io/ip | xclip -sel clip && cd ~/daten/games/sharedgames/minecraft/server && java -jar forge-1.12.2-14.23.5.2768-universal.jar -mx 8G'
|
alias startMinecraftServer='curl https://ipinfo.io/ip | xclip -sel clip && cd ~/daten/games/sharedgames/minecraft/server && java -jar forge-1.12.2-14.23.5.2768-universal.jar -mx 8G'
|
||||||
|
|
||||||
# Fast shortcuts
|
# Fast shortcuts
|
||||||
alias t='tree -C | less'
|
alias t='task'
|
||||||
alias c='clear'
|
alias c='clear'
|
||||||
alias q='exit'
|
alias q='exit'
|
||||||
alias v='nvim'
|
alias v='nvim'
|
||||||
|
alias grp='grep -iIn'
|
||||||
|
alias grpr='grp -r'
|
||||||
b() { bat "$@" 2>/dev/null || ls -lah "$@" }
|
b() { bat "$@" 2>/dev/null || ls -lah "$@" }
|
||||||
|
cdd() { cd "$@" 2>/dev/null || cd "$(dirname "$1")" "${@:2}" }
|
||||||
|
tr() { tree -C -a -L 2 "$@" | less }
|
||||||
|
|
||||||
_FUNCTIONS=${BASH_SOURCE[0]:-${(%):-%x}}
|
SHELL_FUNCTIONS="${BASH_SOURCE[0]:-${(%):-%x}}"
|
||||||
alias r="reset && source $_FUNCTIONS"
|
alias r="reset && source $SHELL_FUNCTIONS"
|
||||||
|
|
||||||
dropbox_path=$(cat ~/.dropbox/info.json | grep -Po '"'"path"'"\s*:\s*"\K([^"]*)')
|
dropbox_path="$(cat ~/.dropbox/info.json | grep -Po '"'"path"'"\s*:\s*"\K([^"]*)')"
|
||||||
|
|
||||||
# Add an "alert" alias for long running commands. Use like so: sleep 10; alert
|
# Add an "alert" alias for long running commands. Use like so: sleep 10; alert
|
||||||
#if [ command -v notify-send >/dev/null 2>&1 ]; then
|
#if [ command -v notify-send >/dev/null 2>&1 ]; then
|
||||||
|
@ -38,6 +49,51 @@ man() {
|
||||||
(test "$1" = "zmv" && LESS="$LESS+/^ *zmv *\\[" /usr/bin/man zshcontrib) || /usr/bin/man "$@"
|
(test "$1" = "zmv" && LESS="$LESS+/^ *zmv *\\[" /usr/bin/man zshcontrib) || /usr/bin/man "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sedcomment() { sed -i 's/$1/#\0/' "${@:2}" }
|
||||||
|
seduncomment() { sed -i 's/#\($1\)/\0/' "${@:2}" }
|
||||||
|
|
||||||
|
mozedit() (
|
||||||
|
set -eo pipefail
|
||||||
|
file="$1"
|
||||||
|
tmpfile="/tmp/$(basename $1).tmp"
|
||||||
|
unsetopt multios # https://stackoverflow.com/a/58261480
|
||||||
|
# ( [[ -t 0 ]] && echo 'STDIN is attached to TTY' ) || cat
|
||||||
|
{ echo -en '\x02\x21\x4C\x18TT\x0\x0' && dd if="$file" bs=1 skip=12 } 2>&1 >"$tmpfile" | head -1 | cut -d+ -f1 | xargs printf "%04x\n" | read len
|
||||||
|
tmpfile2="${tmpfile}2"
|
||||||
|
cat "$tmpfile" | sed "s/TT/\\x${len:2:2}\\x${len:0:2}/" | unlz4 >"$tmpfile2"
|
||||||
|
cat "$tmpfile2" | sed "$2" | lz4 -l | dd bs=1 skip=8 seek=12 of="$file" conv=notrunc
|
||||||
|
)
|
||||||
|
|
||||||
|
theme_save="$(xdg-user-dir CACHE)/theme"
|
||||||
|
theme_default="dark"
|
||||||
|
theme() {
|
||||||
|
theme="$1"
|
||||||
|
if test "$2" = "kde" || test "$theme" != "$THEME" -a "$2" != "q"
|
||||||
|
then kcmshell5 kcm_lookandfeel &
|
||||||
|
fi
|
||||||
|
export THEME="$theme"
|
||||||
|
echo "$theme">"$theme_save"
|
||||||
|
|
||||||
|
#mozfile=$(find $HOME/.mozilla/firefox/ -maxdepth 2 -name addonStartup.json.lz4 | grep ".test")
|
||||||
|
case "$theme" in
|
||||||
|
(light)
|
||||||
|
export BAT_THEME="OneHalfLight"
|
||||||
|
konsoleprofile colors="Light"
|
||||||
|
sed -i 's/#\(include.*\/light-256.theme\)/\1/' "$(xdg-user-dir CONFIG)/taskrc"
|
||||||
|
#mozedit $mozfile '/light@mozilla/,/"enabled"/ s/\("enabled":.*\)false/\1true/; /dark@mozilla/,/"enabled"/ s/\("enabled":.*\)true/\1false/'
|
||||||
|
;;
|
||||||
|
(dark)
|
||||||
|
export BAT_THEME="OneHalfDark"
|
||||||
|
konsoleprofile colors="Breeze"
|
||||||
|
sed -i 's/^include.*light-256.theme/#\0/' "$(xdg-user-dir CONFIG)/taskrc"
|
||||||
|
#mozedit $mozfile '/light@mozilla/,/"enabled"/ s/\("enabled":.*\)true/\1false/; /dark@mozilla/,/"enabled"/ s/\("enabled":.*\)false/\1true/'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
export THEME=$(cat "$theme_save" 2> /dev/null)
|
||||||
|
export THEME=${THEME:-$theme_default}
|
||||||
|
theme $THEME
|
||||||
|
|
||||||
updateDeps() {
|
updateDeps() {
|
||||||
name="$1"
|
name="$1"
|
||||||
pattern="$2"
|
pattern="$2"
|
||||||
|
@ -64,8 +120,11 @@ alias updateKotlin='updateDeps build.gradle.kts '\''kotlin(\"jvm\") version \"'\
|
||||||
alias updateGradle='updateDeps gradle-wrapper.properties "services.gradle.org\/distributions\/gradle-" --version'
|
alias updateGradle='updateDeps gradle-wrapper.properties "services.gradle.org\/distributions\/gradle-" --version'
|
||||||
alias updateUtils='updateDeps build.gradle.kts '\''\"com.github.Xerus2000.util\", \".*\", \"'\'' --pattern '\''[^\"]\+'\'' --version'
|
alias updateUtils='updateDeps build.gradle.kts '\''\"com.github.Xerus2000.util\", \".*\", \"'\'' --pattern '\''[^\"]\+'\'' --version'
|
||||||
|
|
||||||
|
# Kill all shell background processes
|
||||||
alias killbg='kill ${${(v)jobstates##*:*:}%=*}'
|
alias killbg='kill ${${(v)jobstates##*:*:}%=*}'
|
||||||
|
|
||||||
|
# Kil all Java processes except IDEA
|
||||||
|
# Pass "-9" to force-kill and "-q" to not output what has been killed
|
||||||
killJava() {
|
killJava() {
|
||||||
pgrep -f 'java' | while read id
|
pgrep -f 'java' | while read id
|
||||||
do if [[ $(ps --no-headers -o cmd $id) != *"idea"* ]]; then
|
do if [[ $(ps --no-headers -o cmd $id) != *"idea"* ]]; then
|
||||||
|
@ -129,7 +188,7 @@ mvk() {
|
||||||
mv "$1" "$2"
|
mv "$1" "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
# moves from $1 to $2 and creates a symlink instead
|
# Moves from $1 to $2 and creates a symlink in place of $2
|
||||||
mvln() {
|
mvln() {
|
||||||
file=$(test -f "$1" && echo 1 || echo 0)
|
file=$(test -f "$1" && echo 1 || echo 0)
|
||||||
if test -d $1; then
|
if test -d $1; then
|
||||||
|
@ -144,10 +203,6 @@ mvln() {
|
||||||
|
|
||||||
# OTHER
|
# OTHER
|
||||||
|
|
||||||
editshell() {
|
|
||||||
nvim $(test $# -lt 1 && echo "$_FUNCTIONS" || (results=$(find "$dropbox_path/tools/setup" -maxdepth 1 -name "$1.sh") && test "$results" && echo "$results") || echo "$(dirname $_FUNCTIONS)/$1") && r
|
|
||||||
}
|
|
||||||
|
|
||||||
pathadd() {
|
pathadd() {
|
||||||
local IFS=":"
|
local IFS=":"
|
||||||
local result="$@"
|
local result="$@"
|
||||||
|
@ -306,7 +361,8 @@ aptrepoinstall() {
|
||||||
# Gets the download url for the latest release of a package provided via GitHub Releases
|
# Gets the download url for the latest release of a package provided via GitHub Releases
|
||||||
# Usage: ghrelease USER REPO [PATTERN]
|
# Usage: ghrelease USER REPO [PATTERN]
|
||||||
ghrelease() {
|
ghrelease() {
|
||||||
curl -s "https://api.github.com/repos/$1/$2/releases/latest" | grep -o "http.*${3:-deb}"
|
result=$(curl -s "https://api.github.com/repos/$1/$2/releases/latest" | grep -o "http.*${3:-deb}" | awk '{ print length(), $0}' | sort -n | cut -d' ' -f2-)
|
||||||
|
echo "$result" | grep amd64 || echo "$result"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Installs a local or remote(http/https) deb package and removes it after installation
|
# Installs a local or remote(http/https) deb package and removes it after installation
|
||||||
|
@ -338,7 +394,7 @@ if test "$BASH_VERSION"
|
||||||
then _clean_map=([m]=~/.mozilla [c]=~/.cache)
|
then _clean_map=([m]=~/.mozilla [c]=~/.cache)
|
||||||
else _clean_map=(m ~/.mozilla c ~/.cache)
|
else _clean_map=(m ~/.mozilla c ~/.cache)
|
||||||
fi
|
fi
|
||||||
_clean_folders=(~/.oracle_jre_usage ~/.gradle-kotlin-dsl ~/.thumbnails $ZDOTDIR/.zcompdump*)
|
_clean_folders=(~/.oracle_jre_usage ~/.gradle-kotlin-dsl ~/.thumbnails)
|
||||||
clean() {
|
clean() {
|
||||||
|
|
||||||
for f in $_clean_folders
|
for f in $_clean_folders
|
||||||
|
@ -376,8 +432,12 @@ function zipdiff() {
|
||||||
|
|
||||||
# PROJECTS
|
# PROJECTS
|
||||||
|
|
||||||
source "$(dirname $_FUNCTIONS)/git"
|
source "$(dirname $SHELL_FUNCTIONS)/git"
|
||||||
source "$(dirname $_FUNCTIONS)/projects"
|
source "$(dirname $SHELL_FUNCTIONS)/projects"
|
||||||
|
|
||||||
|
pdiff() {
|
||||||
|
diff -r $1 $2 -x .git -x .idea -x .gradle
|
||||||
|
}
|
||||||
|
|
||||||
genssh() {
|
genssh() {
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
|
@ -388,10 +448,6 @@ genssh() {
|
||||||
fi && echo "SSH Public key copied to clipboard"
|
fi && echo "SSH Public key copied to clipboard"
|
||||||
}
|
}
|
||||||
|
|
||||||
pdiff() {
|
|
||||||
diff -r $1 $2 -x .git -x .idea -x .gradle
|
|
||||||
}
|
|
||||||
|
|
||||||
createproject() {
|
createproject() {
|
||||||
mkcd $1
|
mkcd $1
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,14 @@
|
||||||
# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
|
# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
|
||||||
# absolute path. No other format is supported.
|
# absolute path. No other format is supported.
|
||||||
#
|
#
|
||||||
XDG_DESKTOP_DIR="$HOME/desktop"
|
XDG_CONFIG_DIR="$HOME/.config"
|
||||||
XDG_DOWNLOAD_DIR="$HOME/daten/downloads"
|
XDG_CACHE_DIR="$HOME/.cache"
|
||||||
|
XDG_DATA_DIR="$HOME/.local/share"
|
||||||
|
XDG_DESKTOP_DIR="$HOME/.local/desktop"
|
||||||
XDG_TEMPLATES_DIR="$HOME/.local/templates"
|
XDG_TEMPLATES_DIR="$HOME/.local/templates"
|
||||||
XDG_DOCUMENTS_DIR="$HOME/daten"
|
XDG_DOWNLOAD_DIR="$HOME/daten/downloads"
|
||||||
XDG_MUSIC_DIR="$HOME/daten/musik"
|
XDG_MUSIC_DIR="$HOME/"
|
||||||
XDG_PICTURES_DIR="$HOME/daten/bilder"
|
XDG_PICTURES_DIR="$HOME/"
|
||||||
XDG_VIDEOS_DIR="$HOME/daten/videos"
|
XDG_VIDEOS_DIR="$HOME/daten/videos"
|
||||||
XDG_PUBLICSHARE_DIR="$HOME/"
|
XDG_DOCUMENTS_DIR="$HOME/daten/Dropbox/dokumente"
|
||||||
|
XDG_PUBLICSHARE_DIR="$HOME/daten/share"
|
||||||
|
|
|
@ -11,5 +11,9 @@ echo "Defaults timestamp_timeout=20" | sudo tee /etc/sudoers.d/timeout
|
||||||
# Stop logind from suspending my laptop
|
# Stop logind from suspending my laptop
|
||||||
sudo sed -i 's/#HandleLidSwitch=suspend/HandleLidSwitch=ignore/' /etc/systemd/logind.conf
|
sudo sed -i 's/#HandleLidSwitch=suspend/HandleLidSwitch=ignore/' /etc/systemd/logind.conf
|
||||||
|
|
||||||
|
# Fix Chrysalis for keyboardio - https://github.com/keyboardio/Chrysalis/wiki/Troubleshooting
|
||||||
|
echo 'SUBSYSTEM=="tty", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="230[0-3]", TAG+="uaccess"' | sudo tee /etc/udev/rules.d/keyboardio.rules
|
||||||
|
systemctl disable ModemManager
|
||||||
|
|
||||||
# Colorize Pacman
|
# Colorize Pacman
|
||||||
test -f /etc/pacman.conf && sudo sed -i 's/#Color/Color/' /etc/pacman.conf
|
test -f /etc/pacman.conf && sudo sed -i 's/#Color/Color/' /etc/pacman.conf
|
||||||
|
|
|
@ -4,6 +4,7 @@ export EDITOR=/usr/bin/nvim
|
||||||
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
|
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
|
||||||
|
|
||||||
export PASSWORD_STORE_DIR="$HOME/.local/share/pass"
|
export PASSWORD_STORE_DIR="$HOME/.local/share/pass"
|
||||||
|
export TIMEWARRIORDB="$HOME/.local/share/timewarrior"
|
||||||
|
|
||||||
export ZDOTDIR="$HOME/.config/zsh"
|
export ZDOTDIR="$HOME/.config/zsh"
|
||||||
export _Z_DATA="$HOME/.local/share/zsh/z"
|
export _Z_DATA="$HOME/.local/share/zsh/z"
|
||||||
|
|
Loading…
Reference in New Issue