First commit
This commit is contained in:
commit
da3d3a5bcc
1549
.zsh_history
Normal file
1549
.zsh_history
Normal file
File diff suppressed because it is too large
Load Diff
111
.zshrc
Normal file
111
.zshrc
Normal file
@ -0,0 +1,111 @@
|
||||
export PATH=/Users/norets/.cargo/bin:$PATH
|
||||
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
|
||||
export PATH=/Users/norets/.local/bin:$PATH
|
||||
export PATH=/usr/local/opt/llvm/bin:$PATH
|
||||
export PATH=/usr/local/sbin:$PATH
|
||||
export PATH=/usr/bin:$PATH
|
||||
export PATH=/usr/sbin:$PATH
|
||||
export PATH=/usr/local/opt/make/libexec/gnubin:$PATH
|
||||
export PATH=/Library/TeX/texbin:$PATH
|
||||
export PATH="/usr/local/bin:$PATH"
|
||||
export PATH="/Users/norets/opt/neovim/bin:$PATH"
|
||||
# export ANDROID_SDK_ROOT=/Users/norets/opt
|
||||
# export PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin
|
||||
# export PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/platform-tools
|
||||
# export PATH=$PATH:$ANDROID_SDK_ROOT/build-tools/30.0.3
|
||||
# export PATH=/usr/local/opt/gnu-sed/libexec/gnubin:$PATH
|
||||
|
||||
export TOKEN_RO=t.zw2IDNZvkfFaAK3jUZUUSay-Yc_Gi2Um-7lhmBCPVEAZtQ8lKJqLGb75vFKJwDCUOkN5eClLOipB5DDWqEq0RA
|
||||
|
||||
|
||||
# source /usr/local/share/zsh-autocomplete/zsh-autocomplete.plugin.zsh
|
||||
|
||||
|
||||
# Folders with projects
|
||||
# export WORKON_HOME=$HOME/.virtualenvs
|
||||
# export PROJECT_HOME=$HOME/projects
|
||||
|
||||
|
||||
export LANG="en_US.UTF-8"
|
||||
export LC_CTYPE="en_US.UTF-8"
|
||||
|
||||
# Functions for zsh.
|
||||
source ~/.config/zsh/my_zsh_func.zsh
|
||||
|
||||
# History
|
||||
# хранить историю в указанном файле
|
||||
export HISTFILE=~/.config/zsh/.zsh_history
|
||||
# максимальное число команд, хранимых в сеансе
|
||||
export HISTSIZE=10000
|
||||
export SAVEHIST=$HISTSIZE
|
||||
# включить историю команд
|
||||
setopt APPEND_HISTORY
|
||||
# убрать повторяющиеся команды, пустые строки и пр.
|
||||
setopt HIST_IGNORE_ALL_DUPS
|
||||
setopt HIST_IGNORE_SPACE
|
||||
setopt HIST_REDUCE_BLANKS
|
||||
setopt SHARE_HISTORY
|
||||
|
||||
alias server1c='ssh norets@135.181.253.33'
|
||||
alias vdsina='ssh norets@88.210.3.57'
|
||||
alias twc='ssh norets@147.45.135.158'
|
||||
alias turcia='ssh root@65.108.243.87'
|
||||
# alias l='eza --tree --level=1 --icons=always --no-user --no-time --no-permissions --group-directories-first'
|
||||
alias ls='ls --color=always'
|
||||
alias ll='ls -lah'
|
||||
alias emacs='~/programm_sources/emacs/nextstep/Emacs.app/Contents/MacOS/Emacs --init-directory ~/.config/emacs.terminal --eval "(x-focus-frame nil)"'
|
||||
alias enw='~/programm_sources/emacs/nextstep/Emacs.app/Contents/MacOS/Emacs -nw --init-directory ~/.config/emacs.terminal/'
|
||||
alias ctags="`brew --prefix`/bin/ctags"
|
||||
#
|
||||
# alias enw='emacs -nw'
|
||||
# alias ec='/usr/local/bin/emacsclient -nw -c "$@"'
|
||||
# alias ega='exa -lah --git'
|
||||
# alias exat='exa -hT --git'
|
||||
# alias nls='exa -la --color=always --git --group-directories-first $*'
|
||||
# alias em='emacs -nw'
|
||||
# alias doomem='emacs --with-profile doom'
|
||||
|
||||
# Привязываем клавишу для вызова функции (например, Ctrl+w)
|
||||
# bindkey '^w' switch_or_create_tmux_session_widget
|
||||
|
||||
bindkey -s ^w "~/.config/zsh/tmux-sessionizer\n"
|
||||
|
||||
|
||||
parse_git_branch() {
|
||||
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
|
||||
}
|
||||
setopt PROMPT_SUBST
|
||||
# PROMPT='[%F{243}%n@%m%f %F{gray}%B%1~%b%f] %F{cyan}$(parse_git_branch)%f %F{yellow}>>%f '
|
||||
PROMPT='[%n@%F{243}%m%f %F{gray}%1~%f]$ '
|
||||
# COLOR_DEF='%f'
|
||||
# COLOR_USR='%F{243}'
|
||||
# COLOR_DIR='%F{197}'
|
||||
# COLOR_GIT='%F{39}'
|
||||
# # About the prefixed `$`: https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_03.html#:~:text=Words%20in%20the%20form%20%22%24',by%20the%20ANSI%2DC%20standard.
|
||||
# NEWLINE=$'\n'
|
||||
# # Set zsh option for prompt substitution
|
||||
# setopt PROMPT_SUBST
|
||||
# export PROMPT='${COLOR_USR}%n@%M ${COLOR_DIR}%d ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF}${NEWLINE}%% '
|
||||
|
||||
|
||||
# Auto sug
|
||||
# source ~/.config/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||
# zsh
|
||||
source <(fzf --zsh)
|
||||
# fzf
|
||||
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
||||
|
||||
autoload -U compinit promptinit
|
||||
|
||||
promptinit
|
||||
# prompt pure
|
||||
|
||||
compinit
|
||||
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # ignore case
|
||||
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} = # colorz !
|
||||
fpath=(/usr/local/share/zsh-completions $fpath)
|
||||
|
||||
# source /usr/local/share/zsh-syntax-highlighting.zsh
|
||||
# export PATH="/usr/local/opt/m4/bin:$PATH"
|
||||
|
||||
141
my_zsh_func.zsh
Normal file
141
my_zsh_func.zsh
Normal file
@ -0,0 +1,141 @@
|
||||
# Start the tmux session if not alraedy in the tmux session
|
||||
# if [[ ! -n $TMUX ]]; then
|
||||
# # Get the session IDs
|
||||
# session_ids="$(tmux list-sessions)"
|
||||
|
||||
# # Create new session if no sessions exist
|
||||
# if [[ -z "$session_ids" ]]; then
|
||||
# tmux new-session
|
||||
# fi
|
||||
|
||||
# # Select from following choices
|
||||
# # - Attach existing session
|
||||
# # - Create new session
|
||||
# # - Start without tmux
|
||||
# create_new_session="Create new session"
|
||||
# start_without_tmux="Start without tmux"
|
||||
# choices="$session_ids\n${create_new_session}:\n${start_without_tmux}:"
|
||||
# choice="$(echo $choices | fzf | cut -d: -f1)"
|
||||
# selected_name=$(basename "$choice" | tr . _)
|
||||
|
||||
# if expr "$choice" : "[0-9a-zA-Z]*$" >&/dev/null; then
|
||||
# # if expr "$choice" : "[0-9]*$" >&/dev/null; then
|
||||
# # Attach existing session
|
||||
# tmux attach-session -t "$choice"
|
||||
# elif [[ "$choice" = "${create_new_session}" ]]; then
|
||||
# # Create new session
|
||||
# tmux new-session
|
||||
# elif [[ "$choice" = "${start_without_tmux}" ]]; then
|
||||
# # Start without tmux
|
||||
# :
|
||||
# fi
|
||||
# fi
|
||||
|
||||
switch_or_create_tmux_session() {
|
||||
# Если передан один аргумент, используем его
|
||||
if [[ $# -eq 1 ]]; then
|
||||
selected=$1
|
||||
else
|
||||
# Используем fzf для выбора директории
|
||||
selected=$(find ~/.config ~/projects -mindepth 1 -maxdepth 1 -type d | fzf)
|
||||
fi
|
||||
|
||||
# Если ничего не выбрано, выходим
|
||||
if [[ -z $selected ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Получаем имя для сессии tmux, заменяя точки на подчеркивания
|
||||
selected_name=$(basename "$selected" | tr . _)
|
||||
|
||||
# Проверяем, запущен ли tmux
|
||||
tmux_running=$(pgrep tmux)
|
||||
|
||||
# Если tmux не запущен и мы не в сессии tmux, создаем новую сессию
|
||||
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
|
||||
tmux new-session -s $selected_name -c $selected
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Создаем новую сессию, если такой еще нет
|
||||
if ! tmux has-session -t=$selected_name 2> /dev/null; then
|
||||
tmux new-session -ds $selected_name -c $selected
|
||||
fi
|
||||
|
||||
# Переключаемся на существующую сессию, если она есть, или подключаемся к ней
|
||||
if ! tmux switch-client -t $selected_name 2> /dev/null; then
|
||||
tmux attach-session -t $selected_name
|
||||
fi
|
||||
}
|
||||
|
||||
zle -N switch_or_create_tmux_session_widget switch_or_create_tmux_session
|
||||
|
||||
# Function for cd and showing including files.
|
||||
cd() {
|
||||
# Переход в указанный каталог
|
||||
builtin cd "$1"
|
||||
# Печать полного пути к текущему каталогу
|
||||
# Цвет текста:
|
||||
BLACK='\033[0;30m' # ${BLACK} # чёрный цвет знаков
|
||||
RED='\033[0;31m' # ${RED} # красный цвет знаков
|
||||
GREEN='\033[0;32m' # ${GREEN} # зелёный цвет знаков
|
||||
YELLOW='\033[0;33m' # ${YELLOW} # желтый цвет знаков
|
||||
BLUE='\033[0;34m' # ${BLUE} # синий цвет знаков
|
||||
MAGENTA='\033[0;35m' # ${MAGENTA} # фиолетовый цвет знаков
|
||||
CYAN='\033[0;36m' # ${CYAN} # цвет морской волны знаков
|
||||
GRAY='\033[0;37m' # ${GRAY} # серый цвет знаков
|
||||
LRED='\033[1;31m'
|
||||
NC='\033[0m'
|
||||
echo "${MAGENTA}Current directory${NC}: ${YELLOW}$(pwd)${NC}"
|
||||
# # Вывод содержимого каталога
|
||||
# gls -aCAGF --color=always --group-directories-first
|
||||
# eza -aAGF --color=always --group-directories-first
|
||||
ls -aAGF --color=always
|
||||
}
|
||||
|
||||
# Function for creating a new note in Obsidian.
|
||||
cnn() {
|
||||
# Основная директория с заметками для Obsidian
|
||||
local notes_base_dir="$HOME/Library/Mobile Documents/iCloud~md~obsidian/Documents/Main"
|
||||
|
||||
# Проверяем, существует ли основная директория
|
||||
if [ ! -d "$notes_base_dir" ]; then
|
||||
echo "Папка с заметками не найдена: $notes_base_dir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Добавляем пункт для создания новой папки в меню выбора
|
||||
local selected_dir=$(echo -e "Создать новую папку\n$(find "$notes_base_dir" -mindepth 1 -maxdepth 1 -type d)" | fzf --prompt="Выберите папку")
|
||||
|
||||
# Если выбран пункт "Создать новую папку"
|
||||
if [[ "$selected_dir" == "Создать новую папку" ]]; then
|
||||
echo "Введите название новой папки:"
|
||||
read new_dir_name
|
||||
selected_dir="$notes_base_dir/$new_dir_name"
|
||||
mkdir -p "$selected_dir"
|
||||
echo "Создана новая папка: $selected_dir"
|
||||
fi
|
||||
|
||||
# Если не выбрана папка и не создана новая
|
||||
if [ -z "$selected_dir" ]; then
|
||||
echo "Папка не выбрана. Отмена создания заметки."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Если аргумент передан, используем его как имя файла, иначе используем текущую дату и время
|
||||
local file_name
|
||||
if [ -n "$1" ]; then
|
||||
file_name="$1"
|
||||
else
|
||||
file_name=$(date "+%Y-%m-%d-%H%M%S")
|
||||
fi
|
||||
|
||||
local note_file="$selected_dir/$file_name.md"
|
||||
|
||||
# Создаем новый Markdown файл
|
||||
touch "$note_file"
|
||||
|
||||
# Открываем файл в nvim с obsidian.nvim
|
||||
nvim "$note_file"
|
||||
}
|
||||
|
||||
48
tmux-sessionizer
Executable file
48
tmux-sessionizer
Executable file
@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
switch_to() {
|
||||
if [[ -z $TMUX ]]; then
|
||||
tmux attach-session -t $1
|
||||
else
|
||||
tmux switch-client -t $1
|
||||
fi
|
||||
}
|
||||
|
||||
has_session() {
|
||||
tmux list-sessions | grep -q "^$1:"
|
||||
}
|
||||
|
||||
hydrate() {
|
||||
if [ -f $2/.tmux-sessionizer ]; then
|
||||
tmux send-keys -t $1 "source $2/.tmux-sessionizer" c-M
|
||||
elif [ -f $HOME/.tmux-sessionizer ]; then
|
||||
tmux send-keys -t $1 "source $HOME/.tmux-sessionizer" c-M
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ $# -eq 1 ]]; then
|
||||
selected=$1
|
||||
else
|
||||
# If someone wants to make this extensible, i'll accept
|
||||
# PR
|
||||
selected=$(find ~/projects ~/.config ~/Nextcloud -mindepth 1 -maxdepth 1 -type d | fzf)
|
||||
fi
|
||||
|
||||
if [[ -z $selected ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
selected_name=$(basename "$selected" | tr . _)
|
||||
tmux_running=$(pgrep tmux)
|
||||
|
||||
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
|
||||
tmux new-session -s $selected_name -c $selected
|
||||
hydrate $selected_name $selected
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! has_session $selected_name; then
|
||||
tmux new-session -ds $selected_name -c $selected
|
||||
hydrate $selected_name $selected
|
||||
fi
|
||||
|
||||
switch_to $selected_name
|
||||
Loading…
Reference in New Issue
Block a user