diff options
| author | Marcelo Lira <mlira@acumera.com> | 2025-03-07 00:41:38 -0300 |
|---|---|---|
| committer | Marcelo Lira <mlira@acumera.com> | 2025-03-19 20:35:19 -0300 |
| commit | 7343a15f123c78d7c29ff7a189798de689869026 (patch) | |
| tree | 462f4fbe3f17ee36c3adad2bc57531e2f8f371a7 /terminal | |
Diffstat (limited to 'terminal')
| m--------- | terminal/.config/tmux/plugins/tmux-current-pane-hostname | 0 | ||||
| -rw-r--r-- | terminal/.config/tmux/tmux.conf | 117 | ||||
| -rwxr-xr-x | terminal/.local/bin/urlhandler | 25 | ||||
| -rw-r--r-- | terminal/dot-zimrc | 16 | ||||
| -rw-r--r-- | terminal/dot-zshrc | 142 |
5 files changed, 300 insertions, 0 deletions
diff --git a/terminal/.config/tmux/plugins/tmux-current-pane-hostname b/terminal/.config/tmux/plugins/tmux-current-pane-hostname new file mode 160000 +Subproject 6bb3c95250f8120d8b072f46a807d2678ecbc97 diff --git a/terminal/.config/tmux/tmux.conf b/terminal/.config/tmux/tmux.conf new file mode 100644 index 0000000..1070843 --- /dev/null +++ b/terminal/.config/tmux/tmux.conf @@ -0,0 +1,117 @@ +unbind C-b +unbind C-Space +set-option -g prefix C-Space +bind C-Space send-prefix + +# Source: https://michenriksen.com/notes/alacritty-tmux-neovim-colors-and-undercurl/#codeblock-01 +set -g default-terminal "tmux-256color" +# Enable undercurl and color. +set -ga terminal-features ",*:usstyle" +# Support RGB color with SGR escape sequences. +set -gs terminal-overrides ",*:RGB" + +set -g mouse on +set -g base-index 1 +setw -g xterm-keys on +set -s escape-time 10 +set -sg repeat-time 600 +set -s focus-events on + +set -g status-position bottom +set -g status-justify centre +set-option -g status-style bg=#181A1B + +set-option -ag message-style fg=yellow,blink +set-option -ag message-style bg=default + +set -g status-left '#[fg=blue,bg=white,bold] #S #[bg=default] ' +set -g status-left-length 20 + +set -g @tpm_plugins "tmux-plugins/tpm soyuka/tmux-current-pane-hostname" + +set -g status-right "#[fg=none,bg=none]#{?client_prefix,⌨ , }#[fg=orange,bg=black] #H #[fg=black,bg=orange] %a " +set -g status-right-length 50 + +set-window-option -g window-status-separator ' ' +set-window-option -g window-status-current-style 'bold' +set-window-option -g window-status-last-style 'bold' +set-window-option -g window-status-style 'none' + +set-window-option -g window-status-current-format '#[fg=white,bg=blue] #I| #W ' +set-window-option -g window-status-format '#[fg=lightblue] #I| #W ' + +set-window-option -g pane-active-border-style "bg=default fg=#fdf070" + +# Rather than constraining window size to the maximum size of any client +# connected to the *session*, constrain window size to the maximum size of any +# client connected to *that window*. Much more reasonable. +setw -g aggressive-resize on + +# Bindings + +bind \; command-prompt +bind r command-prompt -I "rename-window #{window_name}" +bind e command-prompt -I "rename-session #{session_name}" + +# Source: https://hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/ +# split panes using | and - +bind | split-window -h -c '#{pane_current_path}' +bind \\ split-window -h -c '#{pane_current_path}' +bind - split-window -v -c '#{pane_current_path}' +bind _ split-window -v -c '#{pane_current_path}' +unbind '"' +unbind % + +# Split right, left, down, up +# bind -r C-l split-pane -h -c '#{pane_current_path}' +# bind -r C-h split-pane -hb -c '#{pane_current_path}' +# bind -r C-j split-pane -v -c '#{pane_current_path}' +# bind -r C-k split-pane -vb -c '#{pane_current_path}' + +bind Enter new-window -c '#{pane_current_path}' + +# Source: https://hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/ +# switch panes using Alt-arrow without prefix +bind -n M-Left select-pane -L +bind -n M-Right select-pane -R +bind -n M-Up select-pane -U +bind -n M-Down select-pane -D + +bind -n M-h select-pane -L +bind -n M-l select-pane -R +bind -n M-k select-pane -U +bind -n M-j select-pane -D + +bind -r h select-pane -L +bind -r l select-pane -R +bind -r k select-pane -U +bind -r j select-pane -D + +bind -r [ select-pane -t :.- +bind -r ] select-pane -t :.+ + +bind -r p previous-window +bind -r n next-window + +bind -r Space next-layout + +# Resize right, left, down, up +bind -r -T prefix M-k resize-pane -U 5 +bind -r -T prefix M-j resize-pane -D 5 +bind -r -T prefix M-h resize-pane -L 5 +bind -r -T prefix M-l resize-pane -R 5 +bind -r -T prefix C-k resize-pane -U +bind -r -T prefix C-j resize-pane -D +bind -r -T prefix C-h resize-pane -L +bind -r -T prefix C-l resize-pane -R + +# Easier vertical scroll +bind -n M-U copy-mode -e \; send-keys -X -N 5 scroll-up +bind -T copy-mode M-D copy-mode -e \; send-keys -X -N 5 scroll-down + +set -gq allow-passthrough on +set -g visual-activity off +set-option -ga terminal-features ",alacritty:usstyle" + +# Source: https://github.com/soyuka/tmux-current-pane-hostname +run-shell ~/.config/tmux/plugins/tmux-current-pane-hostname/current_pane_hostname.tmux diff --git a/terminal/.local/bin/urlhandler b/terminal/.local/bin/urlhandler new file mode 100755 index 0000000..021c487 --- /dev/null +++ b/terminal/.local/bin/urlhandler @@ -0,0 +1,25 @@ +#!/bin/sh + +urlregex="(((http|https|gopher|gemini|ftp|ftps|git)://|www\\.)[a-zA-Z0-9.]*[:;a-zA-Z0-9./+@$&%?$\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)" + +urls="$(sed 's/.*│//g' | tr -d '\n' | # First remove linebreaks and mutt sidebars: + grep -aEo "$urlregex" | # grep only urls as defined above. + uniq | # Ignore neighboring duplicates. + sed "s/\(\.\|,\|;\|\!\\|\?\)$//; + s/^www./http:\/\/www\./")" # xdg-open will not detect url without http + +[ -z "$urls" ] && exit 1 + +if [ $(echo "$urls" | wc -l) = "1" ]; then + chosen_url="$urls" +else + chosen_url="$(echo "$urls" | rofi -dmenu -i -p "" -l 10)" +fi + +case "$chosen_url" in + http://*suckless.org*|https://*suckless.org*) command="surf" ;; + https://*.reliant.io*|https://acumera.*) command="/usr/bin/librewolf -P work" ;; + *) command="xdg-open" ;; +esac + +setsid $command "$chosen_url" >/dev/null 2>&1 diff --git a/terminal/dot-zimrc b/terminal/dot-zimrc new file mode 100644 index 0000000..341b0f3 --- /dev/null +++ b/terminal/dot-zimrc @@ -0,0 +1,16 @@ +zmodule input +zmodule termtitle + +zmodule prompt-pwd +zmodule duration-info +zmodule git-info + +zmodule zsh-users/zsh-completions --fpath src +zmodule completion + +# Modules that must be initialized last + +zmodule zsh-users/zsh-syntax-highlighting +zmodule zsh-users/zsh-history-substring-search +zmodule zsh-users/zsh-autosuggestions +zmodule fzf diff --git a/terminal/dot-zshrc b/terminal/dot-zshrc new file mode 100644 index 0000000..3258454 --- /dev/null +++ b/terminal/dot-zshrc @@ -0,0 +1,142 @@ +export LANG=en_US.UTF-8 +export EDITOR=nvim + +# Set editor default keymap to emacs (`-e`) or vi (`-v`) +bindkey -e + +export HISTFILE=~/.zsh_history +export HISTSIZE=268435456 +export SAVEHIST="$HISTSIZE" + +setopt APPEND_HISTORY +setopt SHARE_HISTORY +setopt HIST_EXPIRE_DUPS_FIRST +setopt HIST_IGNORE_DUPS +setopt HIST_IGNORE_ALL_DUPS +setopt HIST_FIND_NO_DUPS +setopt HIST_SAVE_NO_DUPS +setopt HIST_VERIFY +setopt HIST_IGNORE_SPACE +setopt HIST_REDUCE_BLANKS +setopt NO_NOMATCH + +# Remove path separator from WORDCHARS. +WORDCHARS=${WORDCHARS//[\/]} + +# ----------------- +# Zim configuration +# ----------------- + +setopt nopromptbang prompt{cr,percent,sp,subst} + +zstyle ':zim:git-info' verbose yes +zstyle ':zim:git-info:branch' format '%b' +zstyle ':zim:git-info:commit' format '%c' +zstyle ':zim:git-info:stashed' format '%F{#40995A}%S%f' +zstyle ':zim:git-info:dirty' format '%F{red}⚡%f' +zstyle ':zim:git-info:clean' format '%F{green}✓%f' +zstyle ':zim:git-info:indexed' format '%F{#F88C15}✚%f' +zstyle ':zim:git-info:untracked' format '%F{red}✹%f' +zstyle ':zim:git-info:keys' format 'prompt' ' %b%c %D%S%C%i%u ' + +zstyle ':zim:prompt-pwd' git-root no +zstyle ':zim:prompt-pwd:tail' length 2 + +autoload -Uz add-zsh-hook && add-zsh-hook precmd git-info + +# PS1='%K{#5F87AF}%F{yellow} $(prompt-pwd) %f%k%F{blue}%K{yellow}${(e)git_info[prompt]}%k%f %B%(?:%F{green}:%F{red})%{%G➤%}%b ' +PS1='%F{#F88C15}@${(%):-%m} %F{yellow} $(prompt-pwd) %f%F{#AACCFF}${(e)git_info[prompt]}%f %B%(?:%F{green}:%F{red})%{%G➤%}%b ' + +# termtitle + +# Set a custom terminal title format using prompt expansion escape sequences. +# See http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Simple-Prompt-Escapes +# If none is provided, the default '%n@%m: %~' is used. +# zstyle ':zim:termtitle' format '%1~' + +# zsh-autosuggestions + +# Disable automatic widget re-binding on each precmd. This can be set when +# zsh-users/zsh-autosuggestions is the last module in your ~/.zimrc. +ZSH_AUTOSUGGEST_MANUAL_REBIND=1 + +# Customize the style that the suggestions are shown with. +# See https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md#suggestion-highlight-style +# ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=242' + +# zsh-syntax-highlighting + +# Set what highlighters will be used. +# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md +ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets) + +# Customize the main highlighter styles. +# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/main.md#how-to-tweak-it +# typeset -A ZSH_HIGHLIGHT_STYLES +# ZSH_HIGHLIGHT_STYLES[comment]='fg=242' + +# ------------------ +# Initialize modules +# ------------------ + +ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim +# Download zimfw plugin manager if missing. +if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then + if (( ${+commands[curl]} )); then + curl -fsSL --create-dirs -o ${ZIM_HOME}/zimfw.zsh \ + https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh + else + mkdir -p ${ZIM_HOME} && wget -nv -O ${ZIM_HOME}/zimfw.zsh \ + https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh + fi +fi +# Install missing modules, and update ${ZIM_HOME}/init.zsh if missing or outdated. +if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZDOTDIR:-${HOME}}/.zimrc ]]; then + source ${ZIM_HOME}/zimfw.zsh init -q +fi +# Initialize modules. +source ${ZIM_HOME}/init.zsh + +# ------------------------------ +# Post-init module configuration +# ------------------------------ + +# zsh-history-substring-search + +zmodload -F zsh/terminfo +p:terminfo +# Bind ^[[A/^[[B manually so up/down works both before and after zle-line-init +for key ('^[[A' '^P' ${terminfo[kcuu1]}) bindkey ${key} history-substring-search-up +for key ('^[[B' '^N' ${terminfo[kcud1]}) bindkey ${key} history-substring-search-down +for key ('k') bindkey -M vicmd ${key} history-substring-search-up +for key ('j') bindkey -M vicmd ${key} history-substring-search-down +unset key + +# ------------------------------ +# My Stuff +alias grep='grep --color=auto' +alias ip='ip -color=auto' +alias xproxy='ssh -N -D 9090 illyria' +alias gk='gitk --all &' +alias ls='exa --icons' +alias tree='exa --icons --tree' +alias undercurl='echo -e "\e[4:3mUNDERCURL!"' + +alias mpd-start='systemctl start --user mpd' + +alias nocontrol="rm ~/.ssh/control:*" +alias mute_notifications="dunstify 'Muting notifications' && sleep 2 && dunstctl set-paused true" +alias unmute_notifications="dunstctl close-all && dunstctl set-paused false && dunstify 'Notifications unmutted'" + +eval "$(zoxide init zsh --cmd cd)" + +# Add RVM to PATH for scripting. Make sure this is the last PATH variable change. +# Source: https://github.com/rvm/rvm/issues/3212#issuecomment-274912875 +# Squelch the warning by appending ' > /dev/null 2>&1' here +[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" > /dev/null 2>&1 + +# RVM fixes whatever it considers the problem to be, on its own, in `rvm use`. +# It also prints some junk we don't care about, so we squelch its output in the same way. +rvm use default > /dev/null 2>&1 + +export ZK_NOTEBOOK_DIR="$HOME/Documents/zk" +fpath+=${ZDOTDIR:-~}/.zsh_functions |
