minor updates, still want to migrate to bash if possible.

This commit is contained in:
Solomon Laing 2023-02-17 23:07:10 +10:30
parent 9533d52a8d
commit 58a6c2c3b0
2 changed files with 44 additions and 58 deletions

View File

@ -29,6 +29,7 @@ export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quo
bind '"\C-o":"lfcd\n"'
bind '"\C-t":"tms\n"'
bind '"\C-n":"zk edit --interactive --sort modified-\n"'
bind '"\C-f":"$(dirname "$(fzf)")\n"'
# use lf to switch directories and bind it to ctrl-o
function lfcd() {
@ -37,24 +38,10 @@ function lfcd() {
lf -last-dir-path="$tmp" "$@"
if [ -f "$tmp" ]; then
dir="$(cat "$tmp")"
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" || return
fi
}
function pomo() {
arg1=$1
shift
args="$*"
min=${arg1:?Example: pomo 25 Take a break}
sec=$((min * 60))
msg="${args:?Example: pomo 25 Take a break}"
while true; do
date '+%H:%M' && sleep "${sec:?}" && notify-send -u critical -t 0 -a pomo "${msg:?}"
done
}
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
@ -64,7 +51,7 @@ if [ -f ~/.config/shell/aliasrc ]; then
. ~/.config/shell/aliasrc
fi
# enable programmable completion features (you don't need to enable
# Enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
@ -77,21 +64,20 @@ fi
set_exit_code() {
exit_code=$?
[[ $exit_code -eq 0 ]] || printf "$(tput setaf 1) $exit_code $(tput sgr0)"
[[ $exit_code -eq 0 ]] || printf "%s %s %s" "$(tput setaf 1)" "$exit_code" "$(tput sgr0)"
}
set_prompt() {
PS1_BAT="$(bash-status-bat)"
PS1_GIT="$(bash-status-git)"
dir_perm=$(ls -ld | awk '{ print $3 }')
if [[ "$dir_perm" == "$USER" ]]; then
if [[ -n $(find . -user "$(id -u)" -print -prune -o -prune) ]]; then
dir="\[\033[00;36m\]\w"
else
dir="\[\033[00;31m\]\w"
fi
PS1L="\[\033[00;32m\]\u\[\033[00;34m\]@\[\033[01;32m\]\h \[\033[00m\]\$PS1_BAT $dir\[\033[00m\] $PS1_GIT"
PS1L="\[\033[00;32m\]\u\[\033[00;34m\]@\[\033[01;32m\]\h \[\033[00m\]$PS1_BAT $dir\[\033[00m\] $PS1_GIT"
PS1R=$(date +"%R:%S")
PS1=$(printf "%*s\r%s\n\[\033[00m\]\$(set_exit_code)-[ " "$(tput cols)" "$PS1R" "$PS1L")
}