feature t script

This commit is contained in:
thek4n 2024-11-20 20:37:27 +03:00
parent e98e06cc87
commit 10c7e768a5
4 changed files with 40 additions and 4 deletions

View File

@ -15,6 +15,7 @@ __pycache__/
*.spec *.spec
.env .env
*.env
*.log *.log
*.bak *.bak
*~ *~

View File

@ -39,7 +39,7 @@ bind-key Y {
display-popup -E -w 90% -h 80% "nvim /tmp/tmux-buffer" display-popup -E -w 90% -h 80% "nvim /tmp/tmux-buffer"
} }
bind t display-popup -E -h 70% -w 60% bind t display-popup -E -h 70% -w 60% -d "${HOME}"

View File

@ -32,7 +32,7 @@ GREP_OPTIONS=(
) )
alias grep='grep $GREP_OPTIONS' alias grep='grep $GREP_OPTIONS'
alias g='grep --dereference-recursive' alias g='grep --dereference-recursive --line-number'
alias _='sudo' alias _='sudo'
alias root='sudo --login TMOUT=450' alias root='sudo --login TMOUT=450'

View File

@ -5,10 +5,40 @@ set -o errexit
set -o nounset set -o nounset
readonly ENV_FILE=".t.env"
readonly EXIT_SUCCESS=0 readonly EXIT_SUCCESS=0
readonly NOTES_DIR_BASE="${HOME}/.t" readonly NOTES_DIR_BASE="${HOME}/.t"
readonly NOTES_DIR="${NOTES_DIR_BASE}/${t:-default}" readonly DEFAULT_NAMESPACE="def"
find_file_up_fs() (
file_to_find="${1}"
while [ ! "$(pwd)" = "/" ]
do
if [ -f "${file_to_find}" ]; then
realpath "${file_to_find}"
break
fi
cd ..
done
)
load_env_if_found() {
env_file="$(find_file_up_fs "./${ENV_FILE}")"
if [ -n "${env_file}" ]; then
. "${env_file}"
fi
}
if [ -z "${t+x}" ]; then
load_env_if_found
fi
readonly t="${t:-${DEFAULT_NAMESPACE}}"
readonly NOTES_DIR="${NOTES_DIR_BASE}/${t}"
TAB="$(printf -- '\t')" TAB="$(printf -- '\t')"
readonly TAB readonly TAB
@ -58,6 +88,11 @@ get_notes_with_indexes() {
SAVEIFS="${IFS}" SAVEIFS="${IFS}"
IFS=';' IFS=';'
if ${_TO_SHOW:-false}; then
printf -- '\033[1m# %s\033[0m\n\n' "${t}"
fi
index=1 index=1
for note in $(IFS="${IFS}" get_notes_sorted_by_access_time) for note in $(IFS="${IFS}" get_notes_sorted_by_access_time)
do do