#!/bin/zsh # Exports export LANG="en_US.UTF-8" export LC_ALL="en_US.UTF-8" export XDG_DOWNLOAD_DIR="${HOME}/downloads" export XDG_CONFIG_HOME="${HOME}/.config" export XDG_CACHE_HOME="${HOME}/.cache" export XDG_DATA_HOME="${HOME}/.local/share" export XDG_DESKTOP_DIR="${HOME}/desktop" export XDG_TEMPLATES_DIR="${HOME}/temp" export XDG_PUBLICSHARE_DIR="${HOME}/public" export XDG_DOCUMENTS_DIR="${HOME}/documents" export XDG_MUSIC_DIR="${HOME}/music" export XDG_PICTURES_DIR="${HOME}/pictures" export XDG_VIDEOS_DIR="${HOME}/videos" export PATH="$PATH:$HOME/.cargo/bin" export PATH="$PATH:$HOME/go/bin" export PATH="$PATH:$HOME/.local/bin" export EDITOR="nvim" export HISTFILE="${HOME}/.zsh_history" export HISTCONTROL="ignoredups:ignorespace" export HISTSIZE="100000" export HISTFILESIZE="200000" export SAVEHIST="${HISTSIZE}" # ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ # ┃ Functions ┃ # ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ function _have { prog="${1}" os="${2}" if [ "${os}" != "" ] && [ "${os}" != "${OS}" ] then return 1 fi type "${prog}" > /dev/null return "$?" } # Set the runtime variable if _have sway linux then alias sway-launch="dbus-launch --exit-with-session sway" if test -z "${XDG_RUNTIME_DIR}"; then export XDG_RUNTIME_DIR=/tmp/"${UID}"-runtime-dir if ! test -d "${XDG_RUNTIME_DIR}"; then mkdir "${XDG_RUNTIME_DIR}" chmod 0700 "${XDG_RUNTIME_DIR}" fi fi fi # === Media === function video-to-gif() { fps="$3" if [[ "$3" == "" ]]; then fps="10" fi ffmpeg \ -i "$1" \ -filter_complex \ $(printf "%s%s%s%s" \ "[0:v]setpts=0.5*PTS,fps=" \ $fps \ ",scale=800:-1:flags=lanczos,split[s0][s1];" \ "[s0]palettegen[p];[s1][p]paletteuse") \ -filter:a 'atempo=1,atempo=1' \ -loop 0 \ "$2" } function cut() { start_time="$2" end_time="$3" input_file="$1" if [[ "$end_time" == "" ]]; then ffmpeg -ss "$start_time" \ -i "$input_file" \ -c copy "$(date +"%Y%m%d_%H%M ")$input_file" \ || printf "Usage: %s \n" "$0" elif [[ "$end_time" != "" ]]; then ffmpeg -ss "$start_time" -to "$end_time" \ -i "$input_file" \ -c copy "$(date +"%Y%m%d_%H%M ")$input_file" \ || printf "Usage: %s \n" "$0" fi } # make an executable file w/ one line function tx(){ file="$1" [[ "$file" == "" ]] && echo -e "Usage: $0 \n" if [ -f "$file" ]; then echo "$file already exists. Making it executable." chmod +x "$file" else touch "$file" && chmod +x "$file" fi } # Waydroid function droid(){ case "$1" in stop) waydroid session stop ;; restart) if [ pgrep -a waydroid != "" ]; then waydroid session stop setsid -f waydroid session start else setsid -f waydroid session start fi ;; *) printf "Usage: %s {start|stop}\n" "$0" exit 1 esac } # ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ # ┃ ZSH Plugins ┃ # ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ZSH_CUSTOM="$HOME/.config/zsh/plugins" plugins=( # zsh-autosuggestions # zsh-syntax-highlighting ) for plugin in $plugins; do source "$ZSH_CUSTOM/$plugin/${plugin}.zsh" done ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#999999" # ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ # ┃ Completion system (modern menu) ┃ # ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ autoload -Uz compinit && compinit zstyle ':completion:*' menu select # arrow-key menu zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' # case insensitive zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" # colored completion zstyle ':completion:*' rehash true # auto-refresh completion if new programs installed # ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ # ┃ Keybinds ┃ # ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ bindkey '^[[Z' autosuggest-accept # Shift+Tab accepts suggestion bindkey '^ ' autosuggest-accept # Ctrl+Space also accepts bindkey '^[[A' history-beginning-search-backward # Up arrow: search history bindkey '^[[B' history-beginning-search-forward # Down arrow: search history # Common bindings for Alt + Arrow (Meta + Arrow) bindkey '^[[1;3C' forward-word # Alt + Right bindkey '^[[1;3D' backward-word # Alt + Left # cd into a directory with fzf source <(fzf --zsh) bindkey -s '^f' '~/.local/bin/tmux-sessionizer\n' # ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ # ┃ Alias ┃ # ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ alias ls='ls --color=auto --group-directories-first' alias ll='ls -lh --color=auto --group-directories-first' alias la='ls -lah --color=auto --group-directories-first' alias grep='grep --color=auto' alias nv='nvim' alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' # ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ # ┃ Prompt with git status ┃ # ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ # ========================= Single line prompt ====================== # Load version control info # autoload -Uz vcs_info # Load colors # autoload -Uz colors && colors # Run vcs_info before each prompt # precmd_functions+=(vcs_info) # Enable prompt substitution # setopt prompt_subst # Configure the format for git # zstyle ':vcs_info:git:*' formats ' (%b)' # zstyle ':vcs_info:git:*' enable git # Set the PROMPT variable to include the vcs_info_msg_0_ variable # PROMPT='%F{#bb9af7}%~%f%F{#7dcfff}${vcs_info_msg_0_}%f %# ' # ===================== Double line prompt ====================== autoload -Uz vcs_info # loads zsh's version-control info system setopt PROMPT_SUBST # allows variable/command expansion inside PROMPT # palette — catppuccin mocha (prominent accents) MAUVE='%F{#cba6f7}' # signature Mocha accent — used for username BLUE='%F{#89b4fa}' # used for current path TEAL='%F{#94e2d5}' # used for git branch name YELLOW='%F{#f9e2af}' # used for unstaged-changes marker PEACH='%F{#fab387}' # used for staged-changes marker PINK='%F{#f5c2e7}' # used for git action (rebase/merge/etc) RED='%F{#f38ba8}' # used for prompt arrow on command failure GREEN='%F{#a6e3a1}' # used for prompt arrow on command success SUBTEXT='%F{#a6adc8}' # muted tone for structural characters/text RESET='%f' # resets foreground color back to default # format for normal git state (branch + unstaged/staged indicators) zstyle ':vcs_info:git:*' formats "${SUBTEXT}on ${TEAL}%b${YELLOW}%u${PEACH}%c${RESET}" # format used during an in-progress git action (e.g. rebase, merge) zstyle ':vcs_info:git:*' actionformats "${SUBTEXT}on ${TEAL}%b${SUBTEXT}|${PINK}%a${RESET}" zstyle ':vcs_info:*' check-for-changes true # enable staged/unstaged detection (can slow big repos) zstyle ':vcs_info:*' unstagedstr ' *' # symbol shown when there are unstaged changes zstyle ':vcs_info:*' stagedstr ' +' # symbol shown when there are staged changes precmd() { vcs_info } # runs vcs_info before each prompt draw, refreshing git status PROMPT=' ${SUBTEXT}╭─${MAUVE}%n${SUBTEXT}@%m ${BLUE}%~${RESET} ${vcs_info_msg_0_} ${SUBTEXT}╰─%(?.${GREEN}.${RED})❯${RESET} ' # line 1: top border, username (%n), host (%m), current dir (%~), git info # line 2: bottom border + arrow — %(?.X.Y) is a ternary: X if last command # succeeded (exit code 0), Y otherwise # Starship prompt # for times when prompt gets boring # eval "$(starship init zsh)"