#!/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/.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="$1" end_time="$2" input_file="$3" 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 ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' # ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ # ┃ Prompt with git status ┃ # ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ # 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 %# '