Skip to content

Commit

Permalink
chore: cleaning stuff up
Browse files Browse the repository at this point in the history
Former-commit-id: a8e63ee
  • Loading branch information
silveiralexf committed Mar 16, 2024
1 parent fdbcf36 commit 2c66af4
Show file tree
Hide file tree
Showing 30 changed files with 241 additions and 420 deletions.
2 changes: 1 addition & 1 deletion .aliases.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ed45a9fd35cacb03c4abc7f5a97fa96deee0071a
20f12f84e9ab30ca06f8995befc13c10f8f9af18
8 changes: 4 additions & 4 deletions .custom
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash
#!/bin/zsh

# append to the history file, don't overwrite it
shopt -s histappend
#shopt -s histappend

# Enable cdspell for spell-checking
shopt -s cdspell
#shopt -s cdspell

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
#shopt -s checkwinsize

# Fix keyboard US International layout for supporting multiple languages
# use this only when using Brazilian-Portuguese should be used along with English
Expand Down
2 changes: 1 addition & 1 deletion .exports.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
336a2e501948754d6a0cce5593cbb789af321177
69e49e2abeb347347b533d8d09e727d9cb910362
2 changes: 1 addition & 1 deletion .functions.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
acdf1645d5886acf81aa6b4068b64c19527977c9
c7a0c3c1ca5b2ce159b0e906e700793de43ba481
Empty file modified files/bashrc
100755 → 100644
Empty file.
91 changes: 47 additions & 44 deletions files/dmenu-i3-window-jumper.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -10,74 +10,77 @@ progname="$(expr "${0}" : '.*/\([^/]*\)')"
#variables are impractical to save complex cmds because of shell expantion
#therefore functions are required: http://mywiki.wooledge.org/BashFAQ/050
DMENU() { dmenu -p 'Jump to' -l 20 -i \
-fn "Dejavu Sans Mono:medium:size=18" \
-nb \#191919 -nf \#ff0000 -sb \#ff9318 -sf \#191919; }
-fn "Dejavu Sans Mono:medium:size=18" \
-nb \#191919 -nf \#ff0000 -sb \#ff9318 -sf \#191919; }
#looks better on xft powered dmenu:
#https://bugs.launchpad.net/ubuntu/+source/suckless-tools/+bug/1093745

_usage() {
printf "%s\\n" "Usage: ${progname} [app|title]"
printf "%s\\n" "Dmenu window selector for i3-wm."
printf "%s\\n"
printf "%s\\n" " -h, --help show this message and exit"
printf "%s\\n" "Usage: ${progname} [app|title]"
printf "%s\\n" "Dmenu window selector for i3-wm."
printf "%s\\n"
printf "%s\\n" " -h, --help show this message and exit"
}


_die() {
[ -n "${1}" ] && _die_msg="${1}" || exit 1
printf "%b%b\\n" "${_die_msg}" ", press <Enter> to exit" | DMENU
exit 1
[ -n "${1}" ] && _die_msg="${1}" || exit 1
printf "%b%b\\n" "${_die_msg}" ", press <Enter> to exit" | DMENU
exit 1
}

_i3_get_app_tree() {
i3-msg -t get_tree | \
egrep -o "(class\":\".[^\"]+\"|title\":\"[^\"]+)" | \
egrep -vi 'Polybar' | \
sed 's/"//g;s/class://g;s/title://g' | \
while read -r line; read -r line2; do \
printf "%s\\n" "${line} :: ${line2}"; \
done | sed '/i3bar for/d'
#alternative
#i3-msg -t get_tree | python -mjson.tool | \
#sed -n -e 's/^ \{35\}[ ]\+\"name\": \"\(.*\)\", $/\1/p' | \
#sed '/^#[a-F0-9]\{6\}$/d'
i3-msg -t get_tree |
egrep -o "(class\":\".[^\"]+\"|title\":\"[^\"]+)" |
egrep -vi 'Polybar' |
sed 's/"//g;s/class://g;s/title://g' |
while
read -r line
read -r line2
do
printf "%s\\n" "${line} :: ${line2}"
done | sed '/i3bar for/d'
#alternative
#i3-msg -t get_tree | python -mjson.tool | \
#sed -n -e 's/^ \{35\}[ ]\+\"name\": \"\(.*\)\", $/\1/p' | \
#sed '/^#[a-F0-9]\{6\}$/d'
}

if [ ! -t 0 ]; then
#add input comming from pipe or file to $@
set -- "${@}" $(cat)
#add input comming from pipe or file to $@
set -- "${@}" $(cat)
fi

for arg in "${@}"; do #parse options
case "${arg}" in
-h|--help) _usage && exit ;;
esac
case "${arg}" in
-h | --help) _usage && exit ;;
esac
done

if [ -z "${1}" ]; then
if ! command -v "dmenu" >/dev/null 2>&1; then
printf "%s\\n" "${progname}: install 'dmenu' to run this program" >&2
exit 1
fi
selected_entry="$(_i3_get_app_tree | DMENU)"
if ! command -v "dmenu" >/dev/null 2>&1; then
printf "%s\\n" "${progname}: install 'dmenu' to run this program" >&2
exit 1
fi
selected_entry="$(_i3_get_app_tree | DMENU)"
else
selected_entry="$(_i3_get_app_tree | grep -i "${@}" 2>/dev/null | head -1 )"
selected_entry="$(_i3_get_app_tree | grep -i "${@}" 2>/dev/null | head -1)"
fi

if [ -z "${selected_entry}" ]; then
_die
_die
else
#escape some characters to prevent i3 to interpret them as a pattern
# "(" and ")" replace them with "\(" and "\)"
#title="$(printf "%s\\n" "${windows}" | sed 's/\([()]\)/\\\1/g')"
title="$(printf "%s\\n" "${selected_entry}" | \
egrep -o "::.*" | sed 's/:: //g;s/\([()]\)/\\\1/g')"
#escape some characters to prevent i3 to interpret them as a pattern
# "(" and ")" replace them with "\(" and "\)"
#title="$(printf "%s\\n" "${windows}" | sed 's/\([()]\)/\\\1/g')"
title="$(printf "%s\\n" "${selected_entry}" |
egrep -o "::.*" | sed 's/:: //g;s/\([()]\)/\\\1/g')"

#focus window
output_msg="$(i3-msg "[title=\"${title}\"] focus" 2>&1)"
#focus window
output_msg="$(i3-msg "[title=\"${title}\"] focus" 2>&1)"

if printf "%s\\n" "${output_msg}" | tail -1 | \
grep "success" | grep "false" >/dev/null 2>&1; then
app="${title}"; i3-msg "[class=\"${app}\"] focus"
fi
if printf "%s\\n" "${output_msg}" | tail -1 |
grep "success" | grep "false" >/dev/null 2>&1; then
app="${title}"
i3-msg "[class=\"${app}\"] focus"
fi
fi
2 changes: 1 addition & 1 deletion files/dmenu-launch.py.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bd99b24e7c831723a298286fc0ab72cf444dfd90
6a9ed1c2bbdddb90a95d15d4a0c0eabed69030cb
163 changes: 81 additions & 82 deletions files/fzf.zsh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,99 +17,98 @@
# The code at the top and the bottom of this file is the same as in completion.zsh.
# Refer to that file for explanation.
if 'zmodload' 'zsh/parameter' 2>'/dev/null' && (( ${+options} )); then
__fzf_key_bindings_options="options=(${(j: :)${(kv)options[@]}})"
__fzf_key_bindings_options="options=(${(j: :)${(kv)options[@]}})"
else
() {
__fzf_key_bindings_options="setopt"
'local' '__fzf_opt'
for __fzf_opt in "${(@)${(@f)$(set -o)}%% *}"; do
if [[ -o "$__fzf_opt" ]]; then
__fzf_key_bindings_options+=" -o $__fzf_opt"
else
__fzf_key_bindings_options+=" +o $__fzf_opt"
fi
done
}
() {
__fzf_key_bindings_options="setopt"
'local' '__fzf_opt'
for __fzf_opt in "${(@)${(@f)$(set -o)}%% *}"; do
if [[ -o "$__fzf_opt" ]]; then
__fzf_key_bindings_options+=" -o $__fzf_opt"
else
__fzf_key_bindings_options+=" +o $__fzf_opt"
fi
done
}
fi

'emulate' 'zsh' '-o' 'no_aliases'

{

[[ -o interactive ]] || return 0
[[ -o interactive ]] || return 0

# CTRL-T - Paste the selected file path(s) into the command line
__fsel() {
local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
-o -type f -print \
-o -type d -print \
-o -type l -print 2> /dev/null | cut -b3-"}"
setopt localoptions pipefail no_aliases 2> /dev/null
local item
eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" $(__fzfcmd) -m "$@" | while read item; do
echo -n "${(q)item} "
done
local ret=$?
echo
return $ret
}
# CTRL-T - Paste the selected file path(s) into the command line
__fsel() {
local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
-o -type f -print \
-o -type d -print \
-o -type l -print 2> /dev/null | cut -b3-"}"
setopt localoptions pipefail no_aliases 2> /dev/null
local item
eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" $(__fzfcmd) -m "$@" | while read item; do
echo -n "${(q)item} "
done
local ret=$?
echo
return $ret
}

__fzfcmd() {
[ -n "$TMUX_PANE" ] && { [ "${FZF_TMUX:-0}" != 0 ] || [ -n "$FZF_TMUX_OPTS" ]; } &&
echo "fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- " || echo "fzf"
}
__fzfcmd() {
[ -n "$TMUX_PANE" ] && { [ "${FZF_TMUX:-0}" != 0 ] || [ -n "$FZF_TMUX_OPTS" ]; } &&
echo "fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- " || echo "fzf"
}

fzf-file-widget() {
LBUFFER="${LBUFFER}$(__fsel)"
local ret=$?
zle reset-prompt
return $ret
}
zle -N fzf-file-widget
bindkey '^T' fzf-file-widget
fzf-file-widget() {
LBUFFER="${LBUFFER}$(__fsel)"
local ret=$?
zle reset-prompt
return $ret
}
zle -N fzf-file-widget
bindkey '^T' fzf-file-widget

# ALT-C - cd into the selected directory
fzf-cd-widget() {
local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
-o -type d -print 2> /dev/null | cut -b3-"}"
setopt localoptions pipefail no_aliases 2> /dev/null
local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m)"
if [[ -z "$dir" ]]; then
zle redisplay
return 0
fi
zle push-line # Clear buffer. Auto-restored on next prompt.
BUFFER="cd ${(q)dir}"
zle accept-line
local ret=$?
unset dir # ensure this doesn't end up appearing in prompt expansion
zle reset-prompt
return $ret
}
zle -N fzf-cd-widget
bindkey '\ec' fzf-cd-widget
# ALT-C - cd into the selected directory
fzf-cd-widget() {
local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
-o -type d -print 2> /dev/null | cut -b3-"}"
setopt localoptions pipefail no_aliases 2> /dev/null
local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m)"
if [[ -z "$dir" ]]; then
zle redisplay
return 0
fi
zle push-line # Clear buffer. Auto-restored on next prompt.
BUFFER="cd ${(q)dir}"
zle accept-line
local ret=$?
unset dir # ensure this doesn't end up appearing in prompt expansion
zle reset-prompt
return $ret
}
zle -N fzf-cd-widget
bindkey '\ec' fzf-cd-widget

# CTRL-R - Paste the selected command from history into the command line
fzf-history-widget() {
local selected num
setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null
selected=( $(fc -rl 1 | perl -ne 'print if !$seen{(/^\s*[0-9]+\**\s+(.*)/, $1)}++' |
FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort,ctrl-z:ignore $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) )
local ret=$?
if [ -n "$selected" ]; then
num=$selected[1]
if [ -n "$num" ]; then
zle vi-fetch-history -n $num
fi
fi
zle reset-prompt
return $ret
}
zle -N fzf-history-widget
bindkey '^R' fzf-history-widget
# CTRL-R - Paste the selected command from history into the command line
fzf-history-widget() {
local selected num
setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null
selected=( $(fc -rl 1 | perl -ne 'print if !$seen{(/^\s*[0-9]+\**\s+(.*)/, $1)}++' |
FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort,ctrl-z:ignore $FZF_CTRL_R_OPTS --query=${(qqq)LBUFFER} +m" $(__fzfcmd)) )
local ret=$?
if [ -n "$selected" ]; then
num=$selected[1]
if [ -n "$num" ]; then
zle vi-fetch-history -n $num
fi
fi
zle reset-prompt
return $ret
}
zle -N fzf-history-widget
bindkey '^R' fzf-history-widget

} always {
eval $__fzf_key_bindings_options
'unset' '__fzf_key_bindings_options'
} always {
eval $__fzf_key_bindings_options
'unset' '__fzf_key_bindings_options'
}

2 changes: 1 addition & 1 deletion files/i3.conf.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
89287ffd57db3a2da60e2b5851c0284fbab2a19f
40dc6c879f693d56ae099e5cc13376939f26800f
2 changes: 1 addition & 1 deletion files/rofi-pass.sh.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
edb8c1f96a27a44c30202d915216fcaf09ec9c1c
236902187301cfc89a2eba817f754c190b601a7d
16 changes: 6 additions & 10 deletions files/tmux.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# defaults
set -sg escape-time 0
set -g prefix C-Space
set -g default-terminal "xterm"
# source-file "${HOME}/.tmux/themes/default.tmux"
set -g default-terminal "alacritty"

# -----------------------------------------------------------------------------
# Turn on window renumbering
# -----------------------------------------------------------------------------
set-option -g renumber-windows on

# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -41,13 +39,11 @@ setw -g aggressive-resize on
bind p paste-buffer

# -----------------------------------------------------------------------------
# Easier for my brain to remember to split the pane with - and \
# which resemble a horizontal and vertical split respectively
# doesn't override default (prefix ") and (prefix &)
# Keep same directory from source when splitting a new pane
# -----------------------------------------------------------------------------
# bind \ split-window -h -c "#{pane_current_path}"
# bind - split-window -c "#{pane_current_path}"
# bind c new-window -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"

# -----------------------------------------------------------------------------
# visual notification of activity in other windows
Expand Down
1 change: 0 additions & 1 deletion handlers/get-helm.REMOVED.git-id

This file was deleted.

11 changes: 0 additions & 11 deletions handlers/get-kubectl

This file was deleted.

Loading

0 comments on commit 2c66af4

Please sign in to comment.