config/shell: reformat to tabs

This commit is contained in:
xeruf 2021-05-05 08:55:44 +02:00
parent 6c0fb2482e
commit 49179953f6
2 changed files with 52 additions and 50 deletions

View File

@ -14,11 +14,11 @@ alias info='info --vi-keys'
xdh="$XDG_DATA_HOME" xdh="$XDG_DATA_HOME"
xch="$XDG_CONFIG_HOME" xch="$XDG_CONFIG_HOME"
if test -d "$DATA"; then if test -d "$DATA"; then
da=$(cd $DATA/_* && pwd) da=$(cd $DATA/_* && pwd)
d1=$(cd $DATA/1* && pwd) d1=$(cd $DATA/1* && pwd)
d2=$(cd $DATA/2* && pwd) d2=$(cd $DATA/2* && pwd)
d3=$(cd $DATA/3* && pwd) d3=$(cd $DATA/3* && pwd)
d4=$(cd $DATA/4* && pwd) d4=$(cd $DATA/4* && pwd)
fi 2>/dev/null fi 2>/dev/null
ulimit -c unlimited # Enable core dumps ulimit -c unlimited # Enable core dumps
@ -27,11 +27,11 @@ which lsb_release >/dev/null && export DIST=$(lsb_release --id | cut -d' ' -f2)
unalias rd 2>/dev/null unalias rd 2>/dev/null
rd() { rd() {
while test $# -gt 0 while test $# -gt 0
do do
test -d "$1" && find "$1" -maxdepth 1 -type d -empty -printf "Removing %p\n" -delete || rm -iv "$@" test -d "$1" && find "$1" -maxdepth 1 -type d -empty -printf "Removing %p\n" -delete || rm -iv "$@"
shift shift
done done
} }
rr() { mv "$@" /tmp } rr() { mv "$@" /tmp }
@ -43,8 +43,8 @@ alias jnc='jn -contains'
# like "which", but shows contents if it resolves to a file # like "which", but shows contents if it resolves to a file
wh() { wh() {
res=$(which "$@") res=$(which "$@")
test -r "$res" && b --plain "$res" || echo "$res" test -r "$res" && b --plain "$res" || echo "$res"
} }
alias logoff="loginctl terminate-user $USER" alias logoff="loginctl terminate-user $USER"
@ -91,17 +91,17 @@ edshell() {
} }
edbin() { edbin() {
file="$(f=$(which $1) && test -f "$f" && echo $f || echo "$HOME/.local/bin/scripts/$1")" file="$(f=$(which $1) && test -f "$f" && echo $f || echo "$HOME/.local/bin/scripts/$1")"
edit "$file" edit "$file"
case "$file" in ($HOME*) yadm add "$file";; esac case "$file" in ($HOME*) yadm add "$file";; esac
} }
alias l="ls -l --almost-all --human-readable --group-directories-first --file-type" alias l="ls -l --almost-all --human-readable --group-directories-first --file-type"
cd() { cd() {
test ! -d "$1" && test $# -eq 1 && dir=$(f --glob "$1*" "$DATA" --maxdepth 2 --type d --max-results 1) && test ! -d "$1" && test $# -eq 1 && dir=$(f --glob "$1*" "$DATA" --maxdepth 2 --type d --max-results 1) &&
test -n "$dir" && cd "$dir" && return test -n "$dir" && cd "$dir" && return
builtin cd $1 && builtin cd $1 &&
command ls --file-type --group-directories-first --color=always --format=vertical -w $COLUMNS | head -3 command ls --file-type --group-directories-first --color=always --format=vertical -w $COLUMNS | head -3
} }
swap() { swap() {
@ -112,13 +112,14 @@ swap() {
# Task management & time tracking # Task management & time tracking
t() { t() {
if test "$#" -eq 0 && which tn >/dev/null if test "$#" -eq 0 && which tn >/dev/null
then tn then tn
else if test "$1" = "do" else
then test "$2" -gt 0 2>/dev/null && task mod sched:today "${@:2}" || task add sched:today "${@:2}" if test "$1" = "do"
else task "$@" then test "$2" -gt 0 2>/dev/null && task mod sched:today "${@:2}" || task add sched:today "${@:2}"
fi else task "$@"
fi fi
fi
} }
alias tw='timew' alias tw='timew'
@ -146,10 +147,10 @@ browse-unsafe() {
} }
xo() { xo() {
while test $# -gt 0; do while test $# -gt 0; do
xdg-open "$1" xdg-open "$1"
shift shift
done done
} }
alias sqli='rlwrap sqlite3 -column -header -cmd .tables' alias sqli='rlwrap sqlite3 -column -header -cmd .tables'
__loci='locate --ignore-case --basename' __loci='locate --ignore-case --basename'
@ -169,18 +170,18 @@ alias gdiff='git diff --word-diff=color --word-diff-regex=. --no-index'
alias sc='sudo systemctl' alias sc='sudo systemctl'
alias sce='sudo systemctl enable --now' alias sce='sudo systemctl enable --now'
scs() { scs() {
sudo systemctl status "*$1*" sudo systemctl status "*$1*"
systemctl --user status "*$1*" systemctl --user status "*$1*"
} }
alias scu='systemctl --user' alias scu='systemctl --user'
alias scue='systemctl --user enable --now' alias scue='systemctl --user enable --now'
scb() { scb() {
sudo systemctl stop -T "$1" sudo systemctl stop -T "$1"
systemctl --user stop -T "$1" systemctl --user stop -T "$1"
read read
sudo systemctl start -T "$1" sudo systemctl start -T "$1"
systemctl --user start -T "$1" systemctl --user start -T "$1"
} }
alias jcl='sudo SYSTEMD_LESS=FRKi journalctl --boot --no-hostname -e' alias jcl='sudo SYSTEMD_LESS=FRKi journalctl --boot --no-hostname -e'
@ -233,7 +234,7 @@ updateDeps() {
done done
echo name $name depth $depth pattern $oldversion version $version echo name $name depth $depth pattern $oldversion version $version
find -maxdepth $depth -type f -name $name | while read f find -maxdepth $depth -type f -name $name | while read f
do echo $f do echo $f
sed -i "s/\($pattern\)$oldversion/\1$version/gw /dev/stdout" $f sed -i "s/\($pattern\)$oldversion/\1$version/gw /dev/stdout" $f
done done
} }

View File

@ -1,7 +1,7 @@
# A tool for managing multiple git projects quickly. Simply source this in your bashrc or zshrc. # A tool for managing multiple git projects quickly. Simply source this in your bashrc or zshrc.
# This assumes a common directory that contains all projects. Subfolders are detected as well. # This assumes a common directory that contains all projects. Subfolders are detected as well.
# You can set $projects_dir before or after sourcing this script, or adjust it below. # You can set $projects_dir before or after sourcing this script, or adjust it below.
# The standard command I execute daily is "p status", it updates all projects and shows their status. # The regular command is "p status" to update all projects and show their status.
# Common root for all projects # Common root for all projects
projects_dir=${projects_dir:-$DATA/4-incubator/dev} projects_dir=${projects_dir:-$DATA/4-incubator/dev}
@ -13,14 +13,14 @@ projects_subfolder_level=4
# Lists all projects under $projects_dir or the current directory if that is a subfolder of $projects_dir and not a git repository. # Lists all projects under $projects_dir or the current directory if that is a subfolder of $projects_dir and not a git repository.
# This is done by searching for corresponding ".git" folders and then listing their parent directories via "dirname" # This is done by searching for corresponding ".git" folders and then listing their parent directories via "dirname"
listprojects() { listprojects() {
if test "$1" = "--all" if test "$1" = "--all"
then find $projects_dir -mindepth 2 -maxdepth $projects_subfolder_level -type d -name ".git" | xargs dirname then find $projects_dir -mindepth 2 -maxdepth $projects_subfolder_level -type d -name ".git" | xargs dirname
else else
if test "$(echo $PWD | grep $projects_dir/)" && ! git rev-parse --git-dir > /dev/null 2>&1 if test "$(echo $PWD | grep $projects_dir/)" && ! git rev-parse --git-dir > /dev/null 2>&1
then find $PWD -mindepth 2 -maxdepth $projects_subfolder_level -type d -name ".git" | xargs dirname 2> /dev/null || listprojects --all then find $PWD -mindepth 2 -maxdepth $projects_subfolder_level -type d -name ".git" | xargs dirname 2> /dev/null || listprojects --all
else find $projects_dir -mindepth 2 -maxdepth $projects_subfolder_level -type d -not -path "*_*" -name ".git" | xargs dirname else find $projects_dir -mindepth 2 -maxdepth $projects_subfolder_level -type d -not -path "*_*" -name ".git" | xargs dirname
fi fi
fi fi
} }
# Underline the project names # Underline the project names
@ -29,10 +29,11 @@ highlight() { echo "$1" }
# Lists all projects and evaluates the given command. # Lists all projects and evaluates the given command.
alias p=projects alias p=projects
projects() { projects() {
test "$1" = "--all" && all="$1" && shift test "$1" = "--all" && all="$1" && shift
case $1 in case $1 in
"build") "build")
# Builds all found gradle projects in parallel and then prints the results in batches - WARNING: This is likely to considerably slow down your computer! # Builds all found gradle projects in parallel and then prints the results in batches
# WARNING: This is likely to considerably slow down your computer!
listprojects $all | while read d; do listprojects $all | while read d; do
if test "$(find $d -maxdepth 1 -name "*gradle*")"; then if test "$(find $d -maxdepth 1 -name "*gradle*")"; then
builtin cd $d builtin cd $d
@ -73,7 +74,7 @@ projects() {
test $behind -gt 0 && st+=("behind $behind") test $behind -gt 0 && st+=("behind $behind")
local stashes=$(git stash list | wc -l) local stashes=$(git stash list | wc -l)
test $stashes -gt 0 && st+=("stashed $stashes") test $stashes -gt 0 && st+=("stashed $stashes")
test "$st" && name+=" [$(IFS=, eval 'JOINED="${st[*]}"' && echo $JOINED)]" test "$st" && name+=" [$(IFS=, eval 'JOINED="${st[*]}"' && echo $JOINED)]"
highlight $(basename $d) highlight $(basename $d)
eval "$com" eval "$com"
fi fi