d33fa3f5dc
* vim as git difftool * don't use ale completion (we use deoplete) * normal Iosevka font * fix a var name collision * rename home directory to `.home` to hide better * fix warning with `c` function for going to $NICE_HOME * improve fsw command
96 lines
2 KiB
Bash
96 lines
2 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
calc() {
|
|
tp="$*"
|
|
python -c "print(${tp})"
|
|
}
|
|
export -f calc
|
|
|
|
stopbar() {
|
|
# TODO: get the proper monitor!
|
|
BAR_MONITOR="$(polybar --list-monitors | tail -n 1 | sed -n 's/^\s*\(.*\):.*$/\1/p')"
|
|
bspc config -m "${BAR_MONITOR}" bottom_padding "0"
|
|
bspc config -m "${BAR_MONITOR}" top_padding "0"
|
|
killall -q polybar
|
|
while pgrep -x polybar >/dev/null; do sleep 1; done
|
|
}
|
|
export -f stopbar
|
|
|
|
# wm aliases
|
|
startbar() {
|
|
bash "${DOTFILES_PATH}/de/bar/bar.bash" &
|
|
bg
|
|
disown
|
|
}
|
|
export -f startbar
|
|
|
|
restartbar() {
|
|
stopbar
|
|
startbar
|
|
}
|
|
export -f restartbar
|
|
|
|
screenshot() {
|
|
SCROT_DIR="$NICE_HOME/img/scrots/"
|
|
mkdir -p "$SCROT_DIR"
|
|
FILENAME="$NICE_HOME/img/scrots/%Y-%m-%d_%H-%M-%S_\$wx\$h.png"
|
|
scrot "$@" "${FILENAME}" >/dev/null && echo "Saved screenshot to: ${FILENAME}"
|
|
}
|
|
export -f screenshot
|
|
|
|
editscrot() {
|
|
SCROT_DIR="$NICE_HOME/img/scrots/"
|
|
LATEST_SCROT="$(\ls -Art "${SCROT_DIR}" | tail -n 1)"
|
|
krita "${SCROT_DIR}${LATEST_SCROT}"
|
|
}
|
|
|
|
n() {
|
|
SUBDIR="${2:-}"
|
|
mkdir -p "$NICE_HOME/doc/notes/$SUBDIR"
|
|
"$EDITOR" "$NICE_HOME/doc/notes/$SUBDIR/$(date +%Y-%m-%d)_$1.md"
|
|
}
|
|
export -f n
|
|
|
|
# save the current directory for later retrieval
|
|
scwd() {
|
|
addon=""
|
|
if [[ -n $1 ]]; then
|
|
addon="-${1}"
|
|
fi
|
|
echo "${PWD}" > "${DOTFILES_PATH}/.cwd${addon}.tmp"
|
|
}
|
|
export -f scwd
|
|
# bind '"\C-s"':"\"scwd\C-m\""
|
|
|
|
# go to the saved current directory
|
|
gcwd() {
|
|
addon=""
|
|
if [[ -n $1 ]]; then
|
|
addon="-${1}"
|
|
fi
|
|
cd "$(cat "${DOTFILES_PATH}/.cwd${addon}.tmp")" || return
|
|
}
|
|
export -f gcwd
|
|
# bind '"\C-g"':"\"gcwd\C-m\""
|
|
|
|
fsw() {
|
|
SHELL_COMMAND="${1}"
|
|
shift
|
|
inotifywait -q -m -e close_write -r "${@}" | while read -r _ _; do
|
|
eval "${SHELL_COMMAND}"
|
|
done
|
|
}
|
|
export -f fsw
|
|
|
|
# tmux session switcher with fzf from https://github.com/junegunn/fzf/issues/997
|
|
tmuxswitcher() {
|
|
local -r fmt='#{session_id}:|#S|(#{session_attached} attached)'
|
|
{ tmux display-message -p -F "$fmt" && tmux list-sessions -F "$fmt"; } \
|
|
| awk '!seen[$1]++' \
|
|
| column -t -s'|' \
|
|
| fzf -q '$' --reverse --prompt 'switch session: ' -1 \
|
|
| cut -d':' -f1 \
|
|
| xargs tmux switch-client -t
|
|
}
|
|
export -f tmuxswitcher
|