feature: move mdl into dotfiles
This commit is contained in:
parent
3f0a914c8c
commit
f201724cbd
4 changed files with 105 additions and 20 deletions
19
.zprofile
19
.zprofile
|
@ -1,15 +1,8 @@
|
|||
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.
|
||||
# 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
|
||||
[[ -r ~/.zshrc ]] && source ~/.zshrc
|
||||
|
||||
|
|
85
.zsh_functions/download.zsh
Normal file
85
.zsh_functions/download.zsh
Normal file
|
@ -0,0 +1,85 @@
|
|||
if ! typeset -f ytr >/dev/null; then
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
source ~/.zsh_functions/youtube.zsh
|
||||
fi
|
||||
|
||||
d () {
|
||||
local url="${1:-$(pbpaste)}"
|
||||
if [[ -z "$url" ]]; then
|
||||
echo "No URL provided and clipboard is empty."
|
||||
return 1
|
||||
fi
|
||||
case "$url" in
|
||||
(*youtube*|*youtu.be*) echo "Detected YouTube URL: $url"
|
||||
ytr "$url" ;;
|
||||
(*qobuz*) echo "Detected Qobuz URL: $url"
|
||||
mdl "$url" ;;
|
||||
(*) echo "Unknown URL: $url" ;;
|
||||
esac
|
||||
}
|
||||
mdl () {
|
||||
cwd=$(pwd)
|
||||
share_on_nas="192.168.84.3/media"
|
||||
path_on_nas="Music/__INBOX"
|
||||
check_smb_mount() {
|
||||
mount | grep -q "$mount_point"
|
||||
}
|
||||
|
||||
mount_point="$HOME/NAS/Music"
|
||||
if [ ! -d "$mount_point" ]; then
|
||||
echo "Creating mount point directory..."
|
||||
mkdir -p "$mount_point"
|
||||
fi
|
||||
|
||||
if ! check_smb_mount; then
|
||||
echo "Mounting SMB share..."
|
||||
/sbin/mount_smbfs "smb://janolehuebner:$(pass sudo-lana)@$share_on_nas" "$mount_point"
|
||||
fi
|
||||
|
||||
if ! check_smb_mount; then
|
||||
echo "Failed to mount SMB share. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Move to target directory
|
||||
cd "$mount_point/$path_on_nas"
|
||||
|
||||
echo "SMB share mounted successfully."
|
||||
if [[ "$*" == *"tidal.com"* ]]; then
|
||||
echo "TIDAL DETECTED"
|
||||
tidal-dl -l $*
|
||||
else
|
||||
echo "QOBUZ DETECTED"
|
||||
qobuz-dl dl $*
|
||||
fi
|
||||
|
||||
echo "Unmounting SMB share..."
|
||||
sleep 1
|
||||
umount "$mount_point"
|
||||
cd $cwd
|
||||
open "http://bliss.lan/"
|
||||
}
|
20
.zshrc
20
.zshrc
|
@ -1,9 +1,16 @@
|
|||
# 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
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
# Load a function that allows us to import other function definitions from
|
||||
# the ZSH_FUNC_PATH without providing their exact location
|
||||
|
@ -22,6 +29,7 @@ autosource youtube
|
|||
autosource milan
|
||||
autosource nas
|
||||
autosource fuck
|
||||
autosource download
|
||||
|
||||
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# Aliases
|
||||
alias d="$HOME/dev/bin/mdl"
|
||||
alias vim="nvim"
|
||||
alias vi="nvim"
|
||||
alias nano="nvim"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue