1
0
Fork 0

switch to st, improve terminal titlestring handling

This commit is contained in:
Luca Bilke 2023-06-14 18:12:13 +02:00
parent 9290561caa
commit bbf36d159b
10 changed files with 50 additions and 39 deletions

View File

@ -134,9 +134,9 @@ cmd link %{{
cmd setbg "$1"
cmd bulkrename $vidir
cmd on-cd &{{
cmd on-cd ${{
DIR=$(echo $PWD | sed "s|$HOME|~|")
printf "\033]0; $DIR\007" > /dev/tty
printf "\033]0;$TERMINAL [$DIR] \007" > /dev/tty
}}
on-cd

@ -1 +1 @@
Subproject commit 2aa0b54089eb9fa0fca6a48b824642515b6bae8e
Subproject commit 10e84671329a4c4423835934080aa9b1d11b7020

View File

@ -5,7 +5,7 @@
# echo 'export ZDOTDIR="$HOME/.config/zsh"' | sudo tee -a /etc/zsh/zshenv
export EDITOR="nvim"
export TERMINAL="kitty"
export TERMINAL="st"
export BROWSER="firefox"
# Settings

View File

@ -30,8 +30,7 @@ alias \
alias \
ka="killall" \
e="$EDITOR" \
z="zathura" \
kssh="kitty +kitten ssh"
z="zathura"
if command -v pacman 1>/dev/null 2>&1; then
alias p="pacman"

View File

@ -16,13 +16,19 @@ _comp_options+=(globdots)
zle_highlight+=(paste:none)
function write_info(){
echo -n "${VIRTUAL_ENV}" > "/tmp/current_venv-$$"
function write_venv(){
echo -n "${VIRTUAL_ENV}" > "/tmp/current_venv-$$"
}
add-zsh-hook precmd write_info
add-zsh-hook precmd write_venv
echo -ne '\e[5 q' # Use beam shape cursor on startup.
preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
# Set the titlestring
function write_title_cmd() { echo -ne "\033]0;$(print -P "$TERMINAL [%3~] » ${1[(w)1]}")\007" }
add-zsh-hook preexec write_title_cmd
function write_title_wd() { echo -ne "\033]0;$(print -P "$TERMINAL [%3~]")\007" }
add-zsh-hook precmd write_title_wd
reset_beam() { echo -ne '\e[5 q' } # Use beam shape cursor for each new prompt.
# add-zsh-hook preexec reset_beam
whed() {
$EDITOR "$(which "$1")"

View File

@ -71,27 +71,30 @@ bindkey -M vicmd '^T' fzf-file-widget
bindkey -M viins '^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="builtin 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 -M emacs '\ec' fzf-cd-widget
bindkey -M vicmd '\ec' fzf-cd-widget
bindkey -M viins '\ec' fzf-cd-widget
# WARN: Disabled because the vim-browse patch for st uses this key combo already
# LF is better for this anyways
# 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="builtin 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 -M emacs '\ec' fzf-cd-widget
# bindkey -M vicmd '\ec' fzf-cd-widget
# bindkey -M viins '\ec' fzf-cd-widget
# CTRL-R - Paste the selected command from history into the command line
fzf-history-widget() {

View File

@ -10,21 +10,23 @@ zsh_named_dirs="$ZDOTDIR/configs/autogenerated/hashes"
lf_files="$XDG_DATA_HOME/lf/shortcut-files"
lf_dirs="$XDG_DATA_HOME/lf/shortcut-dirs"
lf_shortcuts="$XDG_CONFIG_HOME/lf/shortcutrc"
nvim_dirs="$XDG_CONFIG_HOME/nvim/lua/config/dirs.lua"
# Remove, prepare files
rm -f "$shell_shortcuts" "$lf_files" "$lf_dirs" "$lf_shortcuts" "$zsh_named_dirs" 2>/dev/null
rm -f "$shell_shortcuts" "$lf_files" "$lf_dirs" "$lf_shortcuts" "$zsh_named_dirs" "$nvim_dirs" 2>/dev/null
printf "# vim: filetype=sh\\nalias " >"$shell_shortcuts"
printf "return {\n" >> "$nvim_dirs"
# Format the `directories` file in the correct syntax and sent it to all three configs.
eval "echo \"$(cat "$bmdirs")\"" | awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
printf(\"%s=\42cd %s\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
printf(\"map g%s cd \42%s\42 \n\",\$1,\$2) >> \"$lf_shortcuts\" ;
printf(\"%s\n\",\$2) >> \"$lf_dirs\" }"
printf(\"%s\n\",\$2) >> \"$lf_dirs\" ;
printf(\" %s = '%s',\n\",\$1,\$2) >> \"$nvim_dirs\" }"
# Format the `files` file in the correct syntax and sent it to both configs.
eval "echo \"$(cat "$bmfiles")\"" | awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
printf(\"%s=\42\$EDITOR %s\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
printf(\"%s\n\",\$2) >> \"$lf_files\" ;
printf(\"map E%s \$\$EDITOR \42%s\42 \n\",\$1,\$2) >> \"$lf_shortcuts\" }"
printf "}" >> "$nvim_dirs"

@ -1 +1 @@
Subproject commit 504a8d0199a93ef05e3211ff7ddab86c48acd3f0
Subproject commit 3dd2239cc5b67f4d7f3a536b8895af402cf22cb9

@ -1 +1 @@
Subproject commit 7c84da62e7f7729cf1e84694008137e8e7e3480c
Subproject commit e3303e5e47026b9b088e955688a442315a4afc38

View File

@ -4,6 +4,7 @@
- [ ] add a messaging function to dotsync to warn for breaking changes
- [ ] create tmux config
- [ ] autostart tmux for scrollback buffer in st
- [ ] use hashes in lf titlestring
# FIX
- [ ] sb-playerctl trailing dash when no artist