added bash and tmux configs

This commit is contained in:
Rudis Muiznieks 2022-04-07 19:41:00 -05:00
parent 1f1c31d1f2
commit d0b856c64b
9 changed files with 6834 additions and 62 deletions

View File

@ -8,68 +8,8 @@ hc() {
hc emit_hook reload
if hc silent new_attr bool my_picom_is_running; then
picom -b
fi
xsetroot -solid "#080808" -cursor_name left_ptr &
feh --bg-fill ~/.config/herbstluftwm/wallpaper.jpg
# remove all existing keybindings
hc keyunbind --all
hc set default_frame_layout max
hc set_layout max
# keybindings
Mod=Mod4 # Use the super key as the main modifier
hc keybind $Mod-Shift-q quit
hc keybind $Mod-Control-r reload
hc keybind $Mod-Shift-c close
hc keybind $Mod-Return spawn st
hc keybind $Mod-Control-Return spawn qutebrowser
hc keybind Print spawn flameshot gui
hc keybind XF86AudioRaiseVolume spawn sh -c "pamixer -i 5; pamixer --get-volume >> \"$xobpipe\"; $refresh_panel"
hc keybind XF86AudioLowerVolume spawn sh -c "pamixer -d 5; pamixer --get-volume >> \"$xobpipe\"; $refresh_panel"
hc keybind XF86AudioMute spawn sh -c "pamixer -t; pamixer --get-volume-human | sed 's/muted/0/' >> \"$xobpipe\"; $refresh_panel"
hc keybind XF86Launch7 spawn sh -c "sleep 0.15 && xdotool keydown ctrl key w keyup ctrl"
# basic movement in tiling and floating mode
# focusing clients
hc keybind $Mod-Left focus left
hc keybind $Mod-Down focus down
hc keybind $Mod-Up focus up
hc keybind $Mod-Right focus right
# moving clients in tiling and floating mode
hc keybind $Mod-Shift-Left shift left
hc keybind $Mod-Shift-Down shift down
hc keybind $Mod-Shift-Up shift up
hc keybind $Mod-Shift-Right shift right
# layouting
hc keybind $Mod-f fullscreen toggle
hc keybind $Mod-Shift-f set_attr clients.focus.floating toggle
# The following cycles through the available layouts within a frame, but skips
# layouts, if the layout change wouldn't affect the actual window positions.
# I.e. if there are two windows within a frame, the grid layout is skipped.
hc keybind $Mod-space or , and . compare tags.focus.curframe_wcount = 2 . cycle_layout +1 vertical horizontal max vertical grid , cycle_layout +1
# mouse
hc mouseunbind --all
hc set focus_follows_mouse true
hc set focus_follows_monitor_boundaries true
hc mousebind $Mod-Button1 move
hc mousebind $Mod-Button3 resize
# focus
hc keybind $Mod-BackSpace cycle_monitor
hc keybind $Mod-Tab cycle_all +1
hc keybind $Mod-Shift-Tab cycle_all -1
hc keybind $Mod-Alt-Tab jumpto urgent
# theme
hc lock
hc attr theme.tiling.reset 1
hc attr theme.floating.reset 1
hc set always_show_frame on
@ -95,6 +35,38 @@ hc set frame_normal_opacity 1
hc set frame_bg_active_color '#0000000000'
hc set snap_distance 0
hc set snap_gap 0
hc unlock
if hc silent new_attr bool my_picom_is_running; then
picom -b
fi
xsetroot -solid "#080808" -cursor_name left_ptr &
feh --bg-fill ~/.config/herbstluftwm/wallpaper.jpg
# remove all existing keybindings
hc keyunbind --all
hc set default_frame_layout max
hc set_layout max
# keybindings
Mod=Mod4 # Use the super key as the main modifier
hc keybind $Mod-Alt-q quit
hc keybind $Mod-Alt-r reload
hc keybind $Mod-Alt-Tab cycle_all +1
hc keybind $Mod-Control-c close
hc keybind XF86AudioRaiseVolume spawn sh -c "pamixer -i 5; pamixer --get-volume >> \"$xobpipe\"; $refresh_panel"
hc keybind XF86AudioLowerVolume spawn sh -c "pamixer -d 5; pamixer --get-volume >> \"$xobpipe\"; $refresh_panel"
hc keybind XF86AudioMute spawn sh -c "pamixer -t; pamixer --get-volume-human | sed 's/muted/0/' >> \"$xobpipe\"; $refresh_panel"
# mouse
hc mouseunbind --all
hc set focus_follows_mouse true
hc set focus_follows_monitor_boundaries true
#hc mousebind $Mod-Button1 move
#hc mousebind $Mod-Button3 resize
# rules
hc unrule -F
@ -107,7 +79,6 @@ hc rule floatplacement=smart
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' floating=on
hc rule windowtype='_NET_WM_WINDOW_TYPE_DIALOG' focus=on
hc rule windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)' manage=off
hc rule class='nvim-zen' fullscreen=on
hc set tree_style '╾│ ├└╼─┐'

16
shell/bashrc Normal file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# If x is available and we're not in it, start it
if [ -z "$DISPLAY" ] && [ -x "$(command -v startx)" ]; then
startx
else
# source shared config
for shared in ~/skynet/shell/bashrc.d/*.sh; do
source "$shared"
done
fi

View File

@ -0,0 +1,43 @@
set -o vi
shopt -s histappend
shopt -s cmdhist
HISTSIZE=1000000
HISTFILESIZE=1000000
HISTCONTROL=ignoreboth
HISTIGNORE='ls:history'
HISTTIMEFORMAT='%F %T '
export TERM_ITALICS=true
eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
export PATH=$PATH:~/skynet/bin:~/node/node_modules/.bin:~/.local/bin:~/go/bin:~/.dotnet:~/.dotnet/tools:~/.cargo/bin:~/.luarocks/bin
export EDITOR=vim
export PAGER=bat
export BROWSER=qutebrowser
export BAT_THEME='Wombat'
export DOTNET_ROOT=~/.dotnet
export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1
alias ls='exa --icons'
alias cat='bat'
alias flatpak='flatpak --user'
alias cd..='cd ..'
alias j='goto'
alias jqize="jq -R -r '. as \$line | try fromjson catch \$line'"
alias jcurl="curl -H 'Content-Type: application/json' -H 'Accept: application/json'"
alias gitlog='git log --oneline --graph'
alias gitpush='git push origin $(git rev-parse --abbrev-ref HEAD)'
alias watchsync='watch grep -e Dirty: -e Writeback: /proc/meminfo'
alias psgrep='ps -ef | grep -v grep | grep'
alias serve='python -m http.server'
alias dockerrm='docker stop $(docker ps -aq); docker rm -v $(docker ps -aq); docker volume prune -f; docker rmi $(docker images -q --filter "dangling=true")'
alias cls='clear && echo -en "\e[3J"'
alias removebom="sed -i \$'1s/^\uFEFF//'"
alias duskh="du -hka --max-depth=1 | sort -h"
alias 8bitdo="xboxdrv --evdev /dev/btjoy --config ~/.config/xboxdrv/8bitdo.conf"
alias ddev="export COMPOSE_FILE=docker-compose.dev.yaml"
alias penscreen="xsetwacom set 'Wacom Intuos PT S Pen stylus' MapToOutput HEAD-1; xsetwacom set 'Wacom Intuos PT S Pen eraser' MapToOutput HEAD-1"
test -e ~/.bash_aliases && source ~/.bash_aliases

View File

@ -0,0 +1,21 @@
# fzf config
[ -f /usr/share/fzf/completion.bash ] && source /usr/share/fzf/completion.bash
[ -f /usr/share/fzf/key-bindings.bash ] && source /usr/share/fzf/key-bindings.bash
# goto
[ -f ~/skynet/scripts/goto.sh ] && source ~/skynet/scripts/goto.sh
# bash completion
test -e /usr/share/bash-completion/bash_completion && source /usr/share/bash-completion/bash_completion
# colorizer
GRC_ALIASES=true
test -e /etc/profile.d/grc.sh && source /etc/profile.d/grc.sh
# git bash completions
test -e ~/skynet/scripts/git-completion.bash && source ~/skynet/scripts/git-completion.bash
# nvm
test -e ~/.nvm/nvm.sh && source ~/.nvm/nvm.sh
test -e ~/.cargo/env && source ~/.cargo/env

View File

@ -0,0 +1,29 @@
# dictionary
define(){
dict -d gcide "$1" | bat
}
# thesaurus
synonym(){
dict -d moby-thesaurus "$1" | bat
}
# mount with user permissions
mmount(){
sudo mount -o uid=`whoami`,gid=`whoami` "/dev/$1" "/mnt/$2"
}
# easy ssh-agent persistence
function ssha() {
test=`ps -ef | grep '\sssh-agent$' | grep -v grep | awk '{print $2}' | xargs`
if [ "$test" = "" ]; then
if [ -e "~/.ssh-agent.sh" ]; then
rm -f ~/.ssh-agent.sh
fi
ssh-agent | grep -v echo >&~/.ssh-agent.sh
fi
test -e ~/.ssh-agent.sh && source ~/.ssh-agent.sh
ssh-add -l > /dev/null || ssh-add
}
test -e ~/.ssh-agent.sh && source ~/.ssh-agent.sh

View File

@ -0,0 +1,69 @@
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
BLUE=$(tput setaf 4)
MAGENTA=$(tput setaf 5)
ITALIC=$(tput sitm)
RESET=$(tput sgr0)
format_command_time() {
local x="$1"
local ms="$((x % 1000))"
x="$((x / 1000))"
local sec="$((x % 60))"
x="$((x / 60))"
local min="$((x % 60))"
x="$((x / 60))"
local hour="$((x % 24))"
local day="$((x / 24))"
local timestr
if [ "$day" -gt 0 ]; then
timestr="${day}d "
fi
if [ "$hour" -gt 0 ]; then
timestr="$timestr${hour}h "
fi
if [ "$min" -gt 0 ]; then
timestr="$timestr${min}m "
fi
if [ "$sec" -gt 0 ]; then
timestr="$timestr${sec}s "
fi
timestr="$timestr${ms}ms"
printf '%s' "$timestr"
}
last_command_timer() {
last_command_start=${last_command_start:-$(date +%s%3N)}
}
set_prompt() {
if [ $? -eq 0 ]; then
prompt_color="$GREEN"
else
prompt_color="$RED"
fi
if [ -n "$last_command_start" ]; then
last_command_length=$(format_command_time "$(($(date +%s%3N) - last_command_start))")
unset last_command_start
last_command_stats="$ITALIC${MAGENTA}Completed in $last_command_length.$RESET\n"
else
last_command_stats=
fi
git_branch=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
if [ -n "$git_branch" ]; then
local git_status
git_status=$(git status --porcelain)
if [ -n "$git_status" ]; then
git_symbol=" $RED"
else
git_symbol=" $GREEN"
fi
else
git_symbol=
fi
PS1="\n$last_command_stats\[$BLUE\]\w\[$RESET\]$git_symbol\[$YELLOW\]$git_branch\[$RESET\]\n\[$prompt_color\]\[$RESET\] "
}
trap 'last_command_timer' DEBUG
PROMPT_COMMAND=set_prompt

View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
if command -v tmux &> /dev/null && [ -n "$PS1" ] && [[ ! "$TERM" =~ screen ]] && [[ ! "$TERM" =~ linux ]] && [ -z "$TMUX" ]; then
exec tmux
fi
# robot quote
if [ -x "$(command -v botsay)" ]; then
len=1642 #$(jq '. | length' ~/skynet/quotes.json)
idx=$(( RANDOM % len))
quote=()
while read -r value; do
quote+=("$value")
done < <(jq -r ".[$idx] | .quoteText, .quoteAuthor" ~/skynet/shell/quotes.json)
quoteText="${quote[0]}"
if [ -n "${quote[1]}" ]; then
quoteText="$quoteText --${quote[1]}"
fi
echo "$quoteText" | botsay -c -
fi

6570
shell/quotes.json Normal file

File diff suppressed because it is too large Load Diff

33
shell/tmux.conf Normal file
View File

@ -0,0 +1,33 @@
set-option -sa terminal-overrides ',rxvt-unicode-256color:RGB'
set-option -g history-limit 100000
set-option -g status off
set-option -g focus-events on
set -g default-terminal "st-256color"
set -g mouse on
setw -g aggressive-resize on
setw -g mode-keys vi
setw -g automatic-rename on
bind m \
set -g mouse on \;\
display 'Mouse: ON'
bind M \
set -g mouse off \;\
display 'Mouse: OFF'
set -s copy-command 'xsel -b -i'
bind ] run "tmux set-buffer -- \"$(xsel -b -o)\"; tmux paste-buffer"
bind-key -n MouseDown2Pane run "tmux set-buffer -- \"$(xsel -b -o)\"; tmux paste-buffer"
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
bind r source-file ~/.tmux.conf \; display "tmux config reloaded :)"
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
set -s escape-time 0