feat: split existing stuff into new atructure

This commit is contained in:
Jan-Ole Hübner 2025-04-06 19:09:40 +02:00
parent 38035a3c00
commit 29e363d419
13 changed files with 2178 additions and 0 deletions

View file

@ -0,0 +1,25 @@
function autosource {
local zsh_function_dirs zsh_function_dir
# Check for required argument
if (( $# == 0 )); then
echo "autosource: basename of a file in ZSH_FUNC_PATH required"
echo "autosource: usage: autosource basename [arguments]"
return 1
fi
# Split ZSH_FUNC_PATH into an array
IFS=':' read -rA zsh_function_dirs <<< "${ZSH_FUNC_PATH}"
# Search each dir for a matching .zsh file
for zsh_function_dir in "${zsh_function_dirs[@]}"; do
if [[ -r "${zsh_function_dir}/${1}.zsh" ]]; then
source "${zsh_function_dir}/${1}.zsh" "${@:2}"
return
fi
done
echo "autosource: no ${1} in (${ZSH_FUNC_PATH})"
return 1
}

View file

@ -0,0 +1 @@
echo test autosourced

View file

@ -0,0 +1,4 @@
DOTFILES_ACTIVE=true
DOTFILES_DIR="${HOME}/.dotfiles"
DOTFILES_GITDIR="${HOME}/.dotgit"
ZSH_FUNC_PATH="${HOME}/.zsh_functions:${DOTFILES_DIR}/.zsh_functions"

6
.environment.d/path.env Normal file
View file

@ -0,0 +1,6 @@
# Add directories to PATH
export PATH="/opt/homebrew/bin:$PATH"
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/Library/Python/3.9/bin:$PATH"
export PATH="$HOME/.cargo/bin:$PATH"
export PATH="$HOME/bin:$PATH"

20
.gitignore vendored Normal file
View file

@ -0,0 +1,20 @@
applications/
desktop/
documents/
downloads/
library/
movies/
music/
pictures/
public/
bin/
clipboard_debug.log
dev/
dropshare@jan-ole.download.dsconn
istripper/
keyfile.keyx
last_check.log
last_insta.log
nv.log
package-lock.json
test.sh

1831
.p10k.zsh Executable file

File diff suppressed because it is too large Load diff

15
.zprofile Executable file
View file

@ -0,0 +1,15 @@
export PATH="$PATH:$HOME/.local/bin:$HOME/bin"
# ── 2. Load .env files from ~/.environment.d/ ───────────────────
# Automatically export all variables defined while sourcing .env files
setopt allexport
for file in ~/.environment.d/*.env(.N); do
source "$file"
done
unset file
unsetopt allexport
# ── 3. Source ~/.zshrc (if this is a login shell sourcing a profile file) ─
# In Zsh, this is unnecessary in most setups unless you separate login/init logic.
[[ -r ~/.zshrc ]] && source ~/.zshrc

4
.zsh_functions/milan.zsh Normal file
View file

@ -0,0 +1,4 @@
rsize() {
local dir=${1:-/mnt/Default/Ole/restic} # Default to specified directory
ssh mi.lan "source .zshrc && rsize"
}

13
.zsh_functions/nas.zsh Normal file
View file

@ -0,0 +1,13 @@
patreon() {
ssh janolehuebner@192.168.84.3 "zsh /mnt/hdd/DATA/.scripts/patreon.sh"
}
fansly () {
local users="$*"
ssh janolehuebner@192.168.84.3 "cd /mnt/hdd/DATA/.scripts && echo $(pass sudo-hannah) | sudo -S ./fansly.sh \"$users\""
}
onlyfans() {
ssh janolehuebner@192.168.84.3 "cd /mnt/hdd/DATA/.scripts && echo $(pass sudo-hannah) | sudo -S ./of.sh"
}

107
.zsh_functions/youtube.zsh Normal file
View file

@ -0,0 +1,107 @@
# Function to extract the video ID from a YouTube URL
video_id() {
local url=$1
local video_id=""
# Extract the video ID using Zsh pattern matching
if [[ $url =~ (v=|\/)([0-9A-Za-z_-]{11}).* ]]; then
video_id=${match[2]}
else
echo "Invalid YouTube URL"
return 1
fi
echo $video_id
}
# Function to initiate the download process
ytr () {
if [[ $# -eq 0 ]]; then
echo "Usage: ytr <Youtube_URL>"
return 1
fi
local youtube_url=$1
local youtube_id=$(video_id "$youtube_url")
if [[ $? -ne 0 ]]; then
echo "Failed to extract video ID"
return 1
fi
local token="$(pass tube.lan)"
local json_data=$(jq -n --arg youtube_id "$youtube_id" '{
data: [
{
youtube_id: $youtube_id,
status: "pending",
}
],
autostart: true
}')
curl -X POST -H "Content-Type: application/json" -H "Authorization: Token $token" -d "$json_data" http://192.168.84.3:4601/api/download/
}
#############
####function to check missed shorts
# Add this to your ~/.bashrc or ~/.bash_profile
yts() {
# Check if the user provided a channel name
if [ -z "$1" ]; then
echo "Error: No channel name provided."
echo "Usage: yts <channel_name>"
return 1
fi
# Set the token and URL
local token="$(pass tube.lan)"
# Initialize an empty array to store video data
local video_data="[]"
# Get the video IDs from yt-dlp and loop through each one
while read -r youtube_id; do
# Add each video ID to the array of data (accumulating in $video_data)
video_data=$(echo "$video_data" | jq --arg youtube_id "$youtube_id" '. + [{youtube_id: $youtube_id, status: "priority"}]')
done < <(yt-dlp "https://www.youtube.com/@$1/shorts" --flat-playlist --print "%(id)s")
# Check if video_data is still an empty array (meaning no videos were found)
if [[ "$video_data" == "[]" ]]; then
echo "No videos found for channel $1."
return 1
fi
# Create the final JSON payload with the accumulated video data
json_data=$(jq -n --argjson video_data "$video_data" '{
data: $video_data,
autostart: true
}')
curl -X POST -H "Content-Type: application/json" -H "Authorization: Token $token" -d "$json_data" http://192.168.84.3:4601/api/download/
}
###### check all
#
check_shorts() {
# List of channels to check (you can hardcode them or pass them as arguments)
channels=(
"DarkBlondii"
"littlesiha"
"lenaindica"
)
# Loop through each channel and call yts
for channel in "${channels[@]}"; do
echo "Checking shorts for channel: $channel"
yts "$channel"
done
}
#

28
.zshrc Executable file
View file

@ -0,0 +1,28 @@
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Load a function that allows us to import other function definitions from
# the ZSH_FUNC_PATH without providing their exact location
source "$DOTFILES_DIR/.zsh_functions/autosource.sh"
# Load the rest of the zsh configs in ~/.zshrc.d/
setopt allexport
for file in ~/.zshrc.d/*.zsh(.N); do
source "$file"
done
unset file
unsetopt allexport
autosource youtube
autosource milan
autosource nas
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"

12
.zshrc.d/aliases.zsh Normal file
View file

@ -0,0 +1,12 @@
# Aliases
alias d="/Users/janolehuebner/dev/bin/mdl"
alias vim="nvim"
alias vi="nvim"
alias nano="nvim"
alias tg="terragrunt"
alias tf="tofu"
alias terraform="tofu"
alias pip="pip3"
alias python="python3"
alias cookies="open /Users/janolehuebner/Library/Containers/com.apple.Safari/Data/Library/Cookies/"
alias dotfiles="git --work-tree=$HOME --git-dir=$HOME/.dotgit "

112
.zshrc.d/p10k.zsh Normal file
View file

@ -0,0 +1,112 @@
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
#------
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="powerlevel10k/powerlevel10k"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment one of the following lines to change the auto-update behavior
# zstyle ':omz:update' mode disabled # disable automatic updates
# zstyle ':omz:update' mode auto # update automatically without asking
# zstyle ':omz:update' mode reminder # just remind me to update when it's time
# Uncomment the following line to change how often to auto-update (in days).
# zstyle ':omz:update' frequency 13
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh