From: Will Budic Date: Thu, 17 Jul 2025 14:27:25 +0000 (+1000) Subject: Added tmux config. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=44acb68f1778ce0b3f74fb850c161d530af4a37a;p=wb-shell-scripts.git Added tmux config. --- diff --git a/tmux-bashrc b/tmux-bashrc new file mode 100644 index 0000000..cf6cffd --- /dev/null +++ b/tmux-bashrc @@ -0,0 +1,245 @@ +# ~/.bashrc: executed by bash(1) for non-lo in shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color|*-256color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;31m\]\w\[\033[00m\]\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# colored GCC warnings and errors +#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# some more ls aliases +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + +# Add an "alert" alias for long running commands. Use like so: +# sleep 10; alert +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +#if [ -f ~/.bash_aliases ]; then +# . ~/.bash_aliases +#fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi + +[ -f ~/.fzf.bash ] && source ~/.fzf.bash + +#LS_COLORS=$LS_COLORS:'di=1;44:' ; +LS_COLORS='di=1;31:ln=36:su=1;96' + +export EDITOR=vim +export HISTCONTROL='erasedups' +export HISTIGNORE="pass:ls:ll:l" + +eval "$(fasd --init auto)" +alias ccopy="xclip -selection clipboard" +alias cpaste="xclip -selection clipboard -o" +alias calc='python3 -ic "from __future__ import division; from math import *; from random import *"' +alias v='f -e vim' +alias vimcat='f -e ~/vimcat' +alias o='f -e xdg-opn' +alias egrep='egrep --color=auto' +alias fgrep='fgrep --color=auto' +alias grep='grep --colour=auto' +alias l='ls -CF' +alias la='ls -A' +alias ll='ls --color=auto -Xlh' +alias ls='ls --color=auto' +alias ?='echo ' +alias ed_bash='vim ~/.bashrc' +alias dir="ranger" +alias dayediff="dateutils.ddiff" +alias sql="sqlite3" +alias spavaj="systemctl suspend" +alias vimenize="~/vimenize.pl" +alias vimtail='vim "+normal G$"' +alias killpid="~/selKillPID.sh" +alias uvar="~/uvar.sh" +alias tm="~/tm.sh" +alias backup="~/dev_new/wb-shell-scripts/linux-B_L_R_via_sshfs/backup.sh" +alias backup_restore="~/dev_new/wb-shell-scripts/linux-B_L_R_via_sshfs/restore.sh" +alias backup_list="~/dev_new/wb-shell-scripts/linux-B_L_R_via_sshfs/list.sh" +alias enarch="~/dev_new/wb-shell-scripts/linux-B_L_R_via_sshfs/enarch.pl" +alias timer="~/timer.pl" +alias log="cd ~/dev/LifeLog/; ./log.pl" +alias get_video="~/dev/wb-shell-scripts/get_flash_video.sh" +alias echo_line="~/dev/wb-shell-scripts/echo_line.sh" +alias xspell="~/xspell.pl" +alias xhelp="~/xhelp.sh" + +# fd, super seeds rg as both get installed, .vimrc requiresd ripgrep to be set to use for the grep plugin. +# To search within files. And fd utility is the new more effcient find utility. +export FZF_DEFAULT_COMMAND="fd -HL -E \"**/.git\" -tf" +export PYTHONWARNINGS="ignore" +powerline-daemon -q +POWERLINE_BASH_CONTINUATION=1 +POWERLINE_BASH_SELECT=1 +. /usr/share/powerline/bindings/bash/powerline.sh +function _update_ps1() { + PS1=$(powerline-shell $?) +} + +if [[ $TERM != linux && ! $PROMPT_COMMAND =~ _update_ps1 ]]; then + PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND" +fi +#. /home/will/.local/lib/python2.7/site-packages/powerline/bindings/bash/powerline.sh +#export PAGER="/bin/sh -c "unset PAGER;col -b -x | vim -R -c 'set ft=man nomod nolist' -c 'map q :q' -c 'map ' -c 'map b ' \ +# -c 'nmap K :Man =expand(\\"\\")' -"" +#xmodmap /home/will/.capless > /dev/null 2>&1 +#xmodmap -e 'clear lock' -e 'keycode 66 = Shift_L' +#fortune | cowsay +#ncal -M -b +#Shortens long path in prompt +#export PROMPT DIRTRIM=2 +#if [ $TILIX_ID ] || [ $VTE_VERSION ]; then + # source /etc/profile.d/vte.sh +#fi + + +PATH="/home/will/localperl/bin:/home/will/.cargo/bin:${PATH:+:${PATH}}"; export PATH; +#export PERL5LIB="/usr/local/share/perl/5.30.0/:/usr/local/lib/x86_64-linux-gnu/perl/5.30.0/" +#PERL5LIB="/home/will/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB; +#PERL_LOCAL_LIB_ROOT="/home/will/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT; +#PERL_MB_OPT="--install_base \"/home/will/perl5\""; export PERL_MB_OPT; +#PERL_MM_OPT="INSTALL_BASE=/home/will/perl5"; export PERL_MM_OPT; + +[ -f ~/.fzf.bash ] && source ~/.fzf.bash +csview() +{ + local file="$1" + cat "$file" | sed -e 's/,,/, ,/g' | column -s, -t | less -#5 -N -S +} + +defw() { curl dict://dict.org:/d:"$@":* | less; } +cheat() { clear && curl cheat.sh/"$1" ; } +destroy() { shred "$1" && rm "$1"; } +spellcheck(){ echo "$1 $2 $3 $4" | aspell -a | sed -n '1!p'; } +get_crtime() { + for target in "${@}"; do + inode=$(stat -c %i "${target}") + fs=$(df "${target}" | tail -1 | awk '{print $1}') + crtime=$(sudo debugfs -R 'stat <'"${inode}"'>' "${fs}" 2>/dev/null | grep -oP 'crtime.*--\s*\K.*') + printf "%s\t%s\n" "${target}" "${crtime}" + done +} + +getCPos () { + local v=() t=$(stty -g) + stty -echo + printf "\033[6n" + IFS='[;' read -ra v -d R + stty $t + CPos=(${v[@]:1}) +} + +update() { + sudo nala update + sudo nala upgrade + sudo nala autoremove + sudo flatpak update -y + yt-dlp -U +} +alias pbpaste='xclip -selection clipboard -o' +alias pbcopy='xclip -selection clipboard' +fzf --bash >> /dev/null +export PASH_TOP=/home/will/pash +export PATH=$PATH:$PASH_TOP +export FZF_DEFAULT_COMMAND="/usr/bin/fdfind -HL -E '**/.git' -E '**/.vscode' -tf" +export FZF_ALT_C_OPTS="--walker-skip .git,node_modules,target --preview 'tree -C {}'" +#export FZF_CTRL_R_OPTS='--tmux "top,60%" --height 50% --border sharp --bind "ctrl-y:execute-silent(echo -n {2..} | xclip -selection clipboard)+abort" --color header:italic --header "Press CTRL-Y to copy command into clipboard"' + +export LS_COLORS='di=1;35;04:ln=36:su=1;96:*.pl=1;36:*.pm=1;36' diff --git a/tmux.conf b/tmux.conf new file mode 100644 index 0000000..bc6da5f --- /dev/null +++ b/tmux.conf @@ -0,0 +1,78 @@ +# remap prefix to Control + a +set -g prefix C-a +# bind 'C-a C-a' to type 'C-a' +bind C-a send-prefix +unbind C-b +#set-option -g default-shell ${SHELL} +#set-option -g default-command "$SHELL --init-file .tmux-bashrc" +set-option -g default-shell '/bin/bash' +set-option -g default-command "/bin/bash --init-file .tmux-bashrc" +set -g base-index 1 +set -g escape-time 40 +set -g default-terminal "screen-256color" +#note-> mouse set can interfere with copy and paste. In copy mode bellow mouse selection set to go to system clipboard. +set -g mouse on +set -g @tmux_power_theme 'moon' +# List of plugins +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'wfxr/tmux-power' +set -g @plugin 'alberti42/tmux-fzf-links' +set -g @plugin 'tmux-plugins/tmux-sensible' +set -g @plugin 'samoshkin/tmux-plugin-sysstat' + +set -g @sysstat_mem_view_tmpl '#Used [fg=#{mem.color}]#{mem.used}#[default] out of #{mem.total}' + + +# general status bar settings +set -g status on +set -g status-interval 5 +set -g status-position bottom +set -g status-justify left +set -g status-right-length 100 + +set -s set-clipboard on +setw -g mode-keys vi +bind -T copy-mode-vi v send -X begin-selection +bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy" +bind P paste-buffer +bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "pbcopy" +set -g @yank_action 'copy-pipe' # or 'copy-pipe-and-cancel' for the default + +# Set parent terminal title to reflect current window in tmux session +set -g set-titles on +set -g set-titles-string "#I:#W" + +# Start index of window/pane with 1, because we're humans, not computers +set -g base-index 1 +setw -g pane-base-index 1 + + +set-option -g popup-border-lines rounded +set-option -g popup-style "bg=#24273a,fg=#cad3f5" +set-option -g popup-border-style "bg=#24273a,fg=#00bbff" +bind y run "tmux display-popup -E 'echo \"Text copied to clipboard!\"'" + + +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +# Run always last: +run '~/.tmux/plugins/tpm/tpm' +run-shell "~/dev/tmux-power/tmux-power.tmux" +run-shell "~/.tmux/plugins/tmux-fzf-links/fzf-links.tmux" + + +# Edit configuration and reload +bind C-e new-window -n 'tmux.conf' "sh -c '\${EDITOR:-vim} ~/.tmux.conf && tmux source ~/.tmux.conf && tmux display \"Config reloaded\"'" + +# Reload tmux configuration +bind C-r source-file ~/.tmux.conf \; display "Config reloaded" + +# ================================================== +# === Window monitoring for activity and silence === +# ================================================== +bind m setw monitor-activity \; display-message 'Monitor window activity [#{?monitor-activity,ON,OFF}]' +bind M if -F '#{monitor-silence}' \ + 'setw monitor-silence 0 ; display-message "Monitor window silence [OFF]"' \ + 'command-prompt -p "Monitor silence: interval (s)" "setw monitor-silence %%"' + +# Activity bell and whistles +set -g visual-activity on \ No newline at end of file