minor updates, still want to migrate to bash if possible.
This commit is contained in:
parent
9533d52a8d
commit
58a6c2c3b0
@ -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-o":"lfcd\n"'
|
||||||
bind '"\C-t":"tms\n"'
|
bind '"\C-t":"tms\n"'
|
||||||
bind '"\C-n":"zk edit --interactive --sort modified-\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
|
# use lf to switch directories and bind it to ctrl-o
|
||||||
function lfcd() {
|
function lfcd() {
|
||||||
@ -37,24 +38,10 @@ function lfcd() {
|
|||||||
lf -last-dir-path="$tmp" "$@"
|
lf -last-dir-path="$tmp" "$@"
|
||||||
if [ -f "$tmp" ]; then
|
if [ -f "$tmp" ]; then
|
||||||
dir="$(cat "$tmp")"
|
dir="$(cat "$tmp")"
|
||||||
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
|
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" || return
|
||||||
fi
|
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.
|
# Alias definitions.
|
||||||
# You may want to put all your additions into a separate file like
|
# You may want to put all your additions into a separate file like
|
||||||
# ~/.bash_aliases, instead of adding them here directly.
|
# ~/.bash_aliases, instead of adding them here directly.
|
||||||
@ -64,7 +51,7 @@ if [ -f ~/.config/shell/aliasrc ]; then
|
|||||||
. ~/.config/shell/aliasrc
|
. ~/.config/shell/aliasrc
|
||||||
fi
|
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
|
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
||||||
# sources /etc/bash.bashrc).
|
# sources /etc/bash.bashrc).
|
||||||
if ! shopt -oq posix; then
|
if ! shopt -oq posix; then
|
||||||
@ -77,21 +64,20 @@ fi
|
|||||||
|
|
||||||
set_exit_code() {
|
set_exit_code() {
|
||||||
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() {
|
set_prompt() {
|
||||||
PS1_BAT="$(bash-status-bat)"
|
PS1_BAT="$(bash-status-bat)"
|
||||||
PS1_GIT="$(bash-status-git)"
|
PS1_GIT="$(bash-status-git)"
|
||||||
|
|
||||||
dir_perm=$(ls -ld | awk '{ print $3 }')
|
if [[ -n $(find . -user "$(id -u)" -print -prune -o -prune) ]]; then
|
||||||
if [[ "$dir_perm" == "$USER" ]]; then
|
|
||||||
dir="\[\033[00;36m\]\w"
|
dir="\[\033[00;36m\]\w"
|
||||||
else
|
else
|
||||||
dir="\[\033[00;31m\]\w"
|
dir="\[\033[00;31m\]\w"
|
||||||
fi
|
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")
|
PS1R=$(date +"%R:%S")
|
||||||
PS1=$(printf "%*s\r%s\n\[\033[00m\]\$(set_exit_code)-[ " "$(tput cols)" "$PS1R" "$PS1L")
|
PS1=$(printf "%*s\r%s\n\[\033[00m\]\$(set_exit_code)-[ " "$(tput cols)" "$PS1R" "$PS1L")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,50 +4,50 @@ setopt prompt_subst
|
|||||||
|
|
||||||
() {
|
() {
|
||||||
|
|
||||||
local PR_USER PR_USER_OP PR_PROMPT PR_HOST
|
local PR_USER PR_USER_OP PR_PROMPT PR_HOST
|
||||||
|
|
||||||
# Check the UID
|
# Check the UID
|
||||||
if [[ $UID -ne 0 ]]; then # normal user
|
if [[ $UID -ne 0 ]]; then # normal user
|
||||||
PR_USER='%F{green}%n%f'
|
PR_USER='%F{green}%n%f'
|
||||||
PR_USER_OP='%F{green}%[ %f'
|
PR_USER_OP='%F{green}%[ %f'
|
||||||
PR_PROMPT='%f[ %f'
|
PR_PROMPT='%f[ %f'
|
||||||
else # root
|
else # root
|
||||||
PR_USER='%F{red}%n%f'
|
PR_USER='%F{red}%n%f'
|
||||||
PR_USER_OP='%F{red}%[# %f'
|
PR_USER_OP='%F{red}%[# %f'
|
||||||
PR_PROMPT='%F{red}[# %f'
|
PR_PROMPT='%F{red}[# %f'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if we are on SSH or not
|
# Check if we are on SSH or not
|
||||||
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
|
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
|
||||||
PR_HOST='%B%F{red}%M%f%b' # SSH
|
PR_HOST='%B%F{red}%M%f%b' # SSH
|
||||||
else
|
else
|
||||||
PR_HOST='%B%F{green}%M%f%b' # no SSH
|
PR_HOST='%B%F{green}%M%f%b' # no SSH
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local return_code="%(?..%F{red}%?↵%f)"
|
local return_code="%(?..%F{red}%?↵%f)"
|
||||||
|
|
||||||
local user_host="${PR_USER}%F{blue}@${PR_HOST}"
|
local user_host="${PR_USER}%F{blue}@${PR_HOST}"
|
||||||
local current_dir="%F{cyan}%~%f"
|
local current_dir="%F{cyan}%~%f"
|
||||||
local git_branch='$(bash-status-git)'
|
local git_branch='$(bash-status-git)'
|
||||||
local bat='$(bash-status-bat | sed "s/%/%%/")'
|
local bat='$(bash-status-bat | sed "s/%/%%/")'
|
||||||
|
|
||||||
PROMPT="${user_host} ${bat} ${current_dir} ${git_branch}
|
PROMPT="${user_host} ${bat} ${current_dir} ${git_branch}
|
||||||
-$PR_PROMPT"
|
-$PR_PROMPT"
|
||||||
RPROMPT="]${return_code} %*"
|
RPROMPT="]${return_code} %*"
|
||||||
|
|
||||||
# all git prompt overrides for easy modification
|
# all git prompt overrides for easy modification
|
||||||
ZSH_THEME_GIT_PROMPT_PREFIX="("
|
ZSH_THEME_GIT_PROMPT_PREFIX="("
|
||||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%b)"
|
ZSH_THEME_GIT_PROMPT_SUFFIX="%b)"
|
||||||
ZSH_THEME_GIT_PROMPT_SEPARATOR="|"
|
ZSH_THEME_GIT_PROMPT_SEPARATOR="|"
|
||||||
ZSH_THEME_GIT_PROMPT_BRANCH="%{$fg_bold[magenta]%}"
|
ZSH_THEME_GIT_PROMPT_BRANCH="%{$fg_bold[magenta]%}"
|
||||||
ZSH_THEME_GIT_PROMPT_STAGED="%{$fg[red]%}%{+%G%}"
|
ZSH_THEME_GIT_PROMPT_STAGED="%{$fg[red]%}%{+%G%}"
|
||||||
ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$fg[red]%}%{x%G%}"
|
ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$fg[red]%}%{x%G%}"
|
||||||
ZSH_THEME_GIT_PROMPT_CHANGED="%{$fg[blue]%}%{*%G%}"
|
ZSH_THEME_GIT_PROMPT_CHANGED="%{$fg[blue]%}%{*%G%}"
|
||||||
ZSH_THEME_GIT_PROMPT_BEHIND="%{↓%G%}"
|
ZSH_THEME_GIT_PROMPT_BEHIND="%{↓%G%}"
|
||||||
ZSH_THEME_GIT_PROMPT_AHEAD="%{↑%G%}"
|
ZSH_THEME_GIT_PROMPT_AHEAD="%{↑%G%}"
|
||||||
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%}%{…%G%}"
|
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%}%{…%G%}"
|
||||||
ZSH_THEME_GIT_PROMPT_STASHED="%{$fg_bold[blue]%}%{s%G%}"
|
ZSH_THEME_GIT_PROMPT_STASHED="%{$fg_bold[blue]%}%{s%G%}"
|
||||||
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}%{~%G%}"
|
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}%{~%G%}"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user