config/shell: script adjustments
This commit is contained in:
parent
bab2d6effc
commit
156ff8784d
|
@ -7,33 +7,33 @@ cdd() { cd "$@" 2>/dev/null || cd "$(dirname "$1")" "${@:2}" }
|
|||
|
||||
# Go up a number of dirs
|
||||
up() {
|
||||
if [[ $# < 1 ]] ; then
|
||||
cd ..
|
||||
else
|
||||
CDSTR=""
|
||||
for i in {1..$1} ; do
|
||||
CDSTR="../$CDSTR"
|
||||
done
|
||||
cd $CDSTR
|
||||
fi
|
||||
if [[ $# < 1 ]] ; then
|
||||
cd ..
|
||||
else
|
||||
CDSTR=""
|
||||
for i in {1..$1} ; do
|
||||
CDSTR="../$CDSTR"
|
||||
done
|
||||
cd $CDSTR
|
||||
fi
|
||||
}
|
||||
|
||||
# Switch directory & ls
|
||||
cl() {
|
||||
builtin cd $1
|
||||
ls --almost-all --group-directories-first --file-type
|
||||
builtin cd $1
|
||||
ls --almost-all --group-directories-first --file-type
|
||||
}
|
||||
|
||||
mkcd() {
|
||||
mkdir -p "$1" && cd "$1"
|
||||
mkdir -p "$1" && cd "$1"
|
||||
}
|
||||
|
||||
cd() {
|
||||
test "$1" != "-" -a ! -d "$1" -a $# -eq 1 &&
|
||||
dir=$(f --glob "$1*" "$DATA" --maxdepth 2 --type d --max-results 1) &&
|
||||
test -n "$dir" && cd "$dir" && return
|
||||
builtin cd $1 &&
|
||||
command ls --file-type --group-directories-first --color=always --format=vertical -w $COLUMNS | head -3
|
||||
test -d "$DATA" && test "$1" != "-" -a ! -d "$1" -a $# -eq 1 &&
|
||||
dir=$(f --glob "$1*" "$DATA" --maxdepth 2 --type d --max-results 1) &&
|
||||
test -n "$dir" && cd "$dir" && return
|
||||
builtin cd $1 &&
|
||||
command ls --file-type --group-directories-first --color=always --format=vertical -w $COLUMNS | head -3
|
||||
}
|
||||
|
||||
# ZOXIDE
|
||||
|
|
|
@ -254,7 +254,9 @@ swap() {
|
|||
}
|
||||
|
||||
|
||||
alias f="noglob $(which fd >/dev/null && echo fd || echo fdfind) --hidden --no-ignore-vcs --one-file-system"
|
||||
alias f="noglob fdd"
|
||||
fdd() { $(which fd >/dev/null && echo fd || echo fdfind) --color=always --hidden --no-ignore-vcs --one-file-system "$@" | less -F; }
|
||||
compdef f=fd
|
||||
#alias f='find -not -path "*.sync*" -and -not \( -name daten -prune \)'
|
||||
#alias f1='find -mindepth 1 -maxdepth 1'
|
||||
|
||||
|
|
|
@ -12,7 +12,8 @@ echo "fs.inotify.max_user_watches=800000" | sudo tee /etc/sysctl.d/60-max-user-w
|
|||
sudo sysctl --system
|
||||
|
||||
highlight "Default sudoers configuration"
|
||||
echo "Defaults editor=/usr/bin/nvim" | sudo tee /etc/sudoers.d/editor
|
||||
echo 'Defaults editor=/usr/bin/nvim
|
||||
Defaults env_keep="EDITOR"' | sudo tee /etc/sudoers.d/editor
|
||||
echo -e "Defaults timestamp_timeout=120\nDefaults passwd_timeout=30" | sudo tee /etc/sudoers.d/timeout
|
||||
highlight "password-free reboot"
|
||||
echo "$USER ALL = NOPASSWD: /sbin/halt, /sbin/reboot, /usr/sbin/reboot, /sbin/poweroff, /usr/sbin/shutdown" | sudo tee /etc/sudoers.d/shutdown
|
||||
|
|
|
@ -8,7 +8,7 @@ for last; do true; done
|
|||
last=${last:-.}
|
||||
|
||||
# Elevate permissions if the file exists but is not accessible
|
||||
test -r "$(dirname $last)" || elevate=sudo
|
||||
test -x "$(dirname $last)" || elevate=sudo
|
||||
tput setaf 4 && $elevate file -E "$last" | ( grep -v --color=never 'directory$' || true )
|
||||
|
||||
case "$($elevate file --dereference --mime "$last")" in
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
#!/bin/sh
|
||||
# Checks whether the current user has rights to the respective file,
|
||||
#!/bin/sh -e
|
||||
# Checks whether the current user has rights to the respective file(s),
|
||||
# even if it does not exist.
|
||||
# First parameter defines which rights are required and is passed to "test".
|
||||
dir="$2"
|
||||
while ! test -e "$dir"
|
||||
do dir="$(dirname "$dir")"
|
||||
flag=$1
|
||||
while test $# -gt 1; do
|
||||
shift
|
||||
dir="$1"
|
||||
while ! test -e "$dir"
|
||||
do dir="$(dirname "$dir")"
|
||||
done
|
||||
test $flag "$dir"
|
||||
done
|
||||
test $1 "$dir"
|
||||
|
|
|
@ -5,7 +5,7 @@ alias dedup='awk '"'"'!a[$0]++'"'"
|
|||
listconf() {
|
||||
{ cat "$conf_cache";
|
||||
fd --hidden --type file --size -1m --max-depth 1 . ~;
|
||||
find "${XDG_CONFIG_HOME:-$HOME/.config}" /etc -maxdepth 3 -follow -type f -readable -exec grep -lI '' {} + 2>/dev/null; } | dedup
|
||||
find "${XDG_CONFIG_HOME:-$HOME/.config}" /etc /var/lib/postgres -maxdepth 4 -follow -type f -readable -exec grep -lI '' {} + 2>/dev/null; } | dedup
|
||||
}
|
||||
|
||||
conf_cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/edconf"
|
||||
|
@ -21,6 +21,6 @@ case "$sel" in
|
|||
/etc/fstab) sudoedit "$sel" && sudo findmnt --verify;;
|
||||
/etc/default/grub) sudoedit "$sel" && sudo grub-mkconfig -o /boot/grub/grub.cfg;;
|
||||
/etc/locale.gen) sudoedit "$sel" && sudo locale-gen;;
|
||||
*) edit "$sel";;
|
||||
*) $(test -w "$sel" || echo sudo) "$EDITOR" "$sel";;
|
||||
esac
|
||||
echo "$sel" | cat - "$conf_cache" | head -20 >"$conf_tmp" && mv "$conf_tmp" "$conf_cache"
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
#!/bin/sh
|
||||
git rev-parse @{upstream} >/dev/null 2>&1 || git branch --set-upstream-to=@{push}
|
||||
git pull --rebase --autostash "$@" || (printf "\e[31;1mError - aborting rebase!\e[0m\n" >&2 && git rebase --abort)
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
# Automatically elevates if missing permissions.
|
||||
for last; do true; done
|
||||
! test -e "$1" && echo "$1 does not exist" && exit 1
|
||||
checkaccess -w "$last" || elevate=sudo
|
||||
checkaccess -w "$@" || elevate=sudo
|
||||
$elevate mkdir -p $(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac)
|
||||
$elevate mv -n "$@"
|
||||
|
|
Loading…
Reference in New Issue