202412301735586432 HAPPY NEW YEAR
This commit is contained in:
parent
9789a3db29
commit
65240b8408
10 changed files with 29481 additions and 25 deletions
|
@ -12,7 +12,7 @@ indent_character: '|'
|
||||||
journals:
|
journals:
|
||||||
default:
|
default:
|
||||||
display_format: markdown
|
display_format: markdown
|
||||||
encrypt: false
|
encrypt: true
|
||||||
journal: /home/fz0x1/PKM/diary/diary.jrnl
|
journal: /home/fz0x1/PKM/diary/diary.jrnl
|
||||||
linewrap: 80
|
linewrap: 80
|
||||||
tagsymbols: '@'
|
tagsymbols: '@'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
setlocal syntax=markdown
|
" setlocal syntax=markdown
|
||||||
setlocal textwidth=80
|
setlocal textwidth=80
|
||||||
setlocal spell
|
setlocal spell
|
||||||
|
|
||||||
|
@ -30,3 +30,4 @@ function! JrnlFoldExpr()
|
||||||
" Все остальные строки не участвуют в свёртке
|
" Все остальные строки не участвуют в свёртке
|
||||||
return "="
|
return "="
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,8 @@ local config = function()
|
||||||
"jsonls",
|
"jsonls",
|
||||||
"clangd",
|
"clangd",
|
||||||
"biome", -- will install for formatting only
|
"biome", -- will install for formatting only
|
||||||
|
"marksman",
|
||||||
|
"ruff",
|
||||||
-- "marksman",
|
-- "marksman",
|
||||||
},
|
},
|
||||||
automatic_installation = true,
|
automatic_installation = true,
|
||||||
|
|
|
@ -47,23 +47,9 @@ ex ()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
diary ()
|
|
||||||
{
|
|
||||||
if [[ ! -v "$1" ]]; then
|
|
||||||
arg1=1
|
|
||||||
else
|
|
||||||
arg1="$1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$2" == "md" ]]; then
|
|
||||||
jrnl -n "$arg1" | glow
|
|
||||||
else
|
|
||||||
jrnl -n "$arg1"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# aliases
|
# aliases
|
||||||
|
## just
|
||||||
|
alias j="just"
|
||||||
## tmux
|
## tmux
|
||||||
alias tsc='tmux switch-client -t'
|
alias tsc='tmux switch-client -t'
|
||||||
alias tsd='tmux new-session -d -s'
|
alias tsd='tmux new-session -d -s'
|
||||||
|
@ -104,9 +90,9 @@ alias py='python'
|
||||||
## todo.txt
|
## todo.txt
|
||||||
alias todo="todo.sh -d ~/Dropbox/TODO/todo.cfg"
|
alias todo="todo.sh -d ~/Dropbox/TODO/todo.cfg"
|
||||||
## eton
|
## eton
|
||||||
alias et="eton"
|
# alias et="eton"
|
||||||
alias zk="eton zk"
|
# alias zk="eton zk"
|
||||||
alias di=" eton diary"
|
# alias di=" eton diary"
|
||||||
## toipe (https://github.com/Samyak2/toipe)
|
## toipe (https://github.com/Samyak2/toipe)
|
||||||
alias to="toipe -f ~/Productivity/TextSync/typing_wordlists/most_problems"
|
alias to="toipe -f ~/Productivity/TextSync/typing_wordlists/most_problems"
|
||||||
## jrnl.sh
|
## jrnl.sh
|
||||||
|
@ -115,8 +101,8 @@ alias lj="jrnl -n 3 --format json | jq '.entries[].date'"
|
||||||
## jupyter
|
## jupyter
|
||||||
alias jup="jupyter lab"
|
alias jup="jupyter lab"
|
||||||
## hledger
|
## hledger
|
||||||
#alias hledger='hledger -f ~/PKM/ledger/2024.journal'
|
alias ledger='just -f ~/.hledger/justfile'
|
||||||
alias ehledger='nvim ~/PKM/ledger/2024.journal'
|
alias ehledger='nvim ~/.hledger/2024.journal'
|
||||||
## other
|
## other
|
||||||
alias cclear="reset && tmux clear-history && cd"
|
alias cclear="reset && tmux clear-history && cd"
|
||||||
## git
|
## git
|
||||||
|
@ -132,6 +118,8 @@ alias frmm="find . -type f -exec shred -n 7 -z -u {} +"
|
||||||
alias resmacs="killall emacs &> /dev/null && emacs --daemon &> /dev/null"
|
alias resmacs="killall emacs &> /dev/null && emacs --daemon &> /dev/null"
|
||||||
alias em="emacsclient -c"
|
alias em="emacsclient -c"
|
||||||
alias relmacs="doom sync"
|
alias relmacs="doom sync"
|
||||||
|
## diary
|
||||||
|
alias di="diary.sh"
|
||||||
|
|
||||||
# bindkeys
|
# bindkeys
|
||||||
## autosuggest
|
## autosuggest
|
||||||
|
|
Binary file not shown.
121
global/scripts/bin/diary.sh
Executable file
121
global/scripts/bin/diary.sh
Executable file
|
@ -0,0 +1,121 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
tput clear
|
||||||
|
|
||||||
|
source "${HOME:?}/scripts/functions.sh"
|
||||||
|
|
||||||
|
CITY_FILE="${HOME:?}/scripts/cities.txt"
|
||||||
|
# do we use weather info?
|
||||||
|
weather=1
|
||||||
|
tools=("fzf" "jq" "jrnl" "nvim" "sha256sum")
|
||||||
|
check_tools "$tools"
|
||||||
|
|
||||||
|
if [[ -z "$OPENWEATHER_APIKEY" ]]; then
|
||||||
|
die "openweathermap api key is not set"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "$CITY_FILE" ]]; then
|
||||||
|
die "cities.txt is not found"
|
||||||
|
fi
|
||||||
|
|
||||||
|
CITY=$(cat "$CITY_FILE" | fzf --prompt="Type a city: ")
|
||||||
|
|
||||||
|
# Проверяем, выбран ли город
|
||||||
|
if [[ -z "$CITY" ]]; then
|
||||||
|
die "city not selected"
|
||||||
|
fi
|
||||||
|
|
||||||
|
set_text_color 43
|
||||||
|
set_bold_text
|
||||||
|
echo -n "Type a title: "
|
||||||
|
reset_text_format
|
||||||
|
read TITLE
|
||||||
|
|
||||||
|
if [[ -z "$TITLE" ]]; then
|
||||||
|
die "title not found"
|
||||||
|
fi
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
set_text_color 43
|
||||||
|
set_bold_text
|
||||||
|
echo -n "Type a geo: "
|
||||||
|
reset_text_format
|
||||||
|
read GEO
|
||||||
|
|
||||||
|
# if a string is empty then skip it
|
||||||
|
if [[ -z "$GEO" ]]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$GEO" =~ ^-?[0-9]+\.[0-9]+,-?[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
set_text_color 1
|
||||||
|
set_bold_text
|
||||||
|
echo "Wrong geo format (lat and lon 52.18969496420507,20.90814238187223)"
|
||||||
|
reset_text_format
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
RESPONSE=$(curl -s "https://api.openweathermap.org/data/2.5/weather?q=${CITY}&appid=${OPENWEATHER_APIKEY}&units=metric")
|
||||||
|
|
||||||
|
if [[ "$(echo "$RESPONSE" | jq '.cod')" != "200" ]]; then
|
||||||
|
set_text_color 1
|
||||||
|
set_bold_text
|
||||||
|
echo "Error: API Response: $RESPONSE"
|
||||||
|
reset_text_format
|
||||||
|
while true; do
|
||||||
|
set_text_color 50
|
||||||
|
set_bold_text
|
||||||
|
read -p "continue? (y|n) " bad_weather_answer
|
||||||
|
reset_text_format
|
||||||
|
if [[ "$bad_weather_answer" = "n" ]]; then
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
weather=0
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Парсим данные о погоде
|
||||||
|
if [[ "$weather" -eq 1 ]]; then
|
||||||
|
WEATHER="$(echo "$RESPONSE" | jq -r '.weather[0].description')"
|
||||||
|
TZ="$(calculate_timezone "$(echo "$RESPONSE" | jq -r '.timezone')")"
|
||||||
|
WEATHER_ICON="$(echo "$RESPONSE" | jq -r '.weather[0].icon')"
|
||||||
|
TEMPERATURES="🌡️ $(round $(echo "$RESPONSE" | jq -r '.main.temp')) ($(round $(echo "$RESPONSE" | jq -r '.main.feels_like')))"
|
||||||
|
|
||||||
|
SUNRISE="$(date --date='@'"$(echo "$RESPONSE" | jq -r '.sys.sunrise')" +'%H:%M')"
|
||||||
|
SUNSET="$(date --date='@'"$(echo "$RESPONSE" | jq -r '.sys.sunset')" +'%H:%M')"
|
||||||
|
SUNINFO="🌅 "$SUNRISE", 🌇 "$SUNSET""
|
||||||
|
IFS=',' read -r geo1 geo2 <<<"$GEO"
|
||||||
|
fi
|
||||||
|
|
||||||
|
TEMPLATE="${TITLE}
|
||||||
|
- ${weather_emoji[WEATHER_ICON]} Weather:
|
||||||
|
- ${CITY}
|
||||||
|
- ${TEMPERATURES:-"none"}
|
||||||
|
- ${SUNINFO:-"none"}
|
||||||
|
- Geo:
|
||||||
|
- ${geo1:-"none"}
|
||||||
|
- ${geo2:-"none"}"
|
||||||
|
|
||||||
|
FILENAME="/tmp/$(generate_random_string).jrnl"
|
||||||
|
echo "$TEMPLATE" >"${FILENAME:?}"
|
||||||
|
CHECKSUMM="$(checksumm "${FILENAME:?}")"
|
||||||
|
|
||||||
|
nvim "${FILENAME:?}" || rm "${FILENAME:?}"
|
||||||
|
|
||||||
|
if [[ "$CHECKSUMM" = "$(checksumm "${FILENAME:?}")" ]]; then
|
||||||
|
rm "${FILENAME:?}"
|
||||||
|
set_bold_text
|
||||||
|
echo "Nothing saving..."
|
||||||
|
reset_text_format
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
tput clear
|
||||||
|
|
||||||
|
jrnl --import --file "${FILENAME:?}"
|
29272
global/scripts/cities.txt
Normal file
29272
global/scripts/cities.txt
Normal file
File diff suppressed because it is too large
Load diff
71
global/scripts/functions.sh
Normal file
71
global/scripts/functions.sh
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
declare -A weather_emoji
|
||||||
|
|
||||||
|
weather_emoji[01d]=🌞
|
||||||
|
weather_emoji[02d]=🌥
|
||||||
|
weather_emoji[03d]=☁
|
||||||
|
weather_emoji[04d]=☁
|
||||||
|
weather_emoji[09d]=🌧
|
||||||
|
weather_emoji[10d]=🌦
|
||||||
|
weather_emoji[11d]=⛈
|
||||||
|
weather_emoji[13d]=❄
|
||||||
|
weather_emoji[50d]=🌫
|
||||||
|
weather_emoji[01n]=🌑
|
||||||
|
weather_emoji[02n]=🌑
|
||||||
|
weather_emoji[03n]=☁
|
||||||
|
weather_emoji[04n]=☁☁
|
||||||
|
weather_emoji[09n]=🌧
|
||||||
|
weather_emoji[10n]=☔
|
||||||
|
weather_emoji[11n]=⛈
|
||||||
|
weather_emoji[13n]=❄
|
||||||
|
weather_emoji[50n]=🌫
|
||||||
|
|
||||||
|
function set_text_color() {
|
||||||
|
tput setaf "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_bold_text() {
|
||||||
|
tput bold
|
||||||
|
}
|
||||||
|
|
||||||
|
function reset_text_format() {
|
||||||
|
tput sgr0
|
||||||
|
}
|
||||||
|
|
||||||
|
function die() {
|
||||||
|
set_text_color 1
|
||||||
|
echo "Script failed: $1, exiting..."
|
||||||
|
reset_text_format
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function round() {
|
||||||
|
echo $(echo "$1" | awk '{print ($1 > int($1)) ? int($1)+1 : int($1)}')
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_tools() {
|
||||||
|
tools="$1"
|
||||||
|
for tool in "${tools[@]}"; do
|
||||||
|
if [ ! -x "$(command -v "$tool")" ]; then
|
||||||
|
die "$tool is not installed"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function calculate_timezone() {
|
||||||
|
offset_hours=$(("${1:?}" / 3600))
|
||||||
|
sign="+"
|
||||||
|
if ((offset_hours < 0)); then
|
||||||
|
sign="-"
|
||||||
|
offset_hours=$((-"$offset_hours"))
|
||||||
|
fi
|
||||||
|
echo "${offset_hours:?}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function generate_random_string() {
|
||||||
|
length="${1:-10}"
|
||||||
|
echo $(cat /dev/urandom | tr -dc 'a-zA-Z09' | head -c "$length")
|
||||||
|
}
|
||||||
|
|
||||||
|
function checksumm() {
|
||||||
|
echo $(sha256sum "${1:?}" | awk '{print $1}')
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ x-scheme-handler/terminal=Alacritty.desktop
|
||||||
application/pdf=com.github.xournalpp.xournalpp.desktop
|
application/pdf=com.github.xournalpp.xournalpp.desktop
|
||||||
application/x-extension-burp=install4j_psxmh6-BurpSuiteCommunity.desktop
|
application/x-extension-burp=install4j_psxmh6-BurpSuiteCommunity.desktop
|
||||||
application/vnd.openxmlformats-officedocument.wordprocessingml.document=libreoffice-base.desktop
|
application/vnd.openxmlformats-officedocument.wordprocessingml.document=libreoffice-base.desktop
|
||||||
|
application/zip=doublecmd.desktop
|
||||||
|
|
||||||
[Added Associations]
|
[Added Associations]
|
||||||
application/xhtml+xml=librewolf.desktop;
|
application/xhtml+xml=librewolf.desktop;
|
||||||
|
|
|
@ -5,8 +5,8 @@ export DISABLE_AUTO_TITLE='true'
|
||||||
## fzf dracula theme
|
## fzf dracula theme
|
||||||
export FZF_DEFAULT_OPTS=$FZF_DEFAULT_OPTS'
|
export FZF_DEFAULT_OPTS=$FZF_DEFAULT_OPTS'
|
||||||
--color=dark
|
--color=dark
|
||||||
--color=fg:-1,bg:-1,hl:#5fff87,fg+:-1,bg+:-1,hl+:#ffaf5f
|
--color=fg:-1,bg:-1,hl:#00d7af,fg+:-1,bg+:-1,hl+:#ffaf5f
|
||||||
--color=info:#af87ff,prompt:#5fff87,pointer:#ff87d7,marker:#ff87d7,spinner:#ff87d7'
|
--color=info:#af87ff,prompt:#00d7af,pointer:#ff87d7,marker:#ff87d7,spinner:#ff87d7'
|
||||||
## all from local/bin
|
## all from local/bin
|
||||||
export PATH=$PATH:$HOME/.local/bin
|
export PATH=$PATH:$HOME/.local/bin
|
||||||
## pdtm
|
## pdtm
|
||||||
|
|
Loading…
Add table
Reference in a new issue