1 Commits

Author SHA1 Message Date
fff22c22d7 Fix bug in almostontop that truncated long prompts
Add collection of cursor line immediately after the previous command
completes and use this when calculating the number of lines required to
move the screen in order to display only the latest prompt.
2021-12-07 16:56:08 +00:00
3 changed files with 16 additions and 28 deletions

View File

@@ -44,7 +44,7 @@ prompt_fresh_setup() {
fi fi
local userhost=$USER local userhost=$USER
if [ "$SSH_CONNECTION" != "" ] || [ "$DISTROBOX_ENTER_PATH" != "" ]; then if [ "$SSH_CONNECTION" != "" ]; then
local user="$user@%{%F{244}%}%M%{%f%}" local user="$user@%{%F{244}%}%M%{%f%}"
local userhost="$userhost@`hostname`" local userhost="$userhost@`hostname`"
fi fi
@@ -132,14 +132,16 @@ fresh_line_one() {
# Executed before each prompt. # Executed before each prompt.
fresh_almostontop_precmd() { fresh_almostontop_precmd() {
# TODO: store the cursor position for use in fresh_almostontop_preexec
# CSI ESC[6n gets the cursor position in the form ESC[<row>;<column>R # CSI ESC[6n gets the cursor position in the form ESC[<row>;<column>R
printf "\033[6n" printf "\033[6n"
# Discard prefix delimited by [ # Discard prefix delimited by [
read -s -d [ read -s -d [
# Store the <row> delimited by ; in row_before # Store the <row> delimited by ; in fresh_precmd_row
read -s -d \; row_before read -s -d \; fresh_precmd_row
# Discard suffix delimted by R otherwise it is output to the tty # Discard suffix delimted by R otherwise it is output to the tty
read -s -d R read -s -d R
# printf "$fresh_precmd_row\n"
} }
# Executed just after a command has been read and is about to be executed. # Executed just after a command has been read and is about to be executed.
@@ -157,7 +159,7 @@ fresh_almostontop_preexec() {
let "down = $LINES - $row" let "down = $LINES - $row"
printf "\033[${down}B" printf "\033[${down}B"
# Calculate the number of lines in the prompt # Calculate the number of lines in the prompt
let "prompt_lines = ($row - $row_before) + 2" let "prompt_lines = ($row - $fresh_precmd_row) + 2"
# Print new lines to push the old command out of view # Print new lines to push the old command out of view
let "new = $row - $prompt_lines" let "new = $row - $prompt_lines"
for (( i = 0; i < $new; i++ )); do for (( i = 0; i < $new; i++ )); do

View File

@@ -1,19 +1,19 @@
--- ---
- name: zsh install packages - name: zsh install packages
become: '{{package_become}}'
package: package:
name: zsh name: zsh
state: present state: present
- name: zsh install Debian packages - name: zsh install Debian packages
when: ansible_os_family == "Debian" when: ansible_os_family == "Debian"
become: true
apt: apt:
name: name: '{{item}}'
state: present
become: true
with_items:
- zsh-doc - zsh-doc
- pinentry-curses - pinentry-curses
- unzip - unzip
state: present
- name: zsh clone plugin repos - name: zsh clone plugin repos
git: git:
@@ -36,14 +36,6 @@
cmd: ~/.config/zsh/fzf/install --bin cmd: ~/.config/zsh/fzf/install --bin
creates: ~/.config/zsh/fzf/bin/fzf creates: ~/.config/zsh/fzf/bin/fzf
- name: zsh create directories
file:
state: directory
dest: '{{item}}'
with_items:
- ~/.local/bin
- ~/.local/share/zsh/site-functions
- name: zsh create symbolic links - name: zsh create symbolic links
file: file:
state: link state: link
@@ -80,7 +72,7 @@
dest: ~/.local/bin/$ dest: ~/.local/bin/$
- name: zsh get absolute path - name: zsh get absolute path
shell: command -v zsh shell: which zsh
register: zsh register: zsh
changed_when: false changed_when: false

View File

@@ -16,10 +16,7 @@ fi
# Abstract different ways to paste from the clipboard. # Abstract different ways to paste from the clipboard.
# TODO: Use OSC-52 to get the clipboard, not widely supported though # TODO: Use OSC-52 to get the clipboard, not widely supported though
if [ -n "$SSH_CONNECTION" ]; then if [ "`uname`" = "Darwin" ]; then
# Use OSC-52 to get the clipboard
alias paste='printf "\033]52;c;?\a"'
elif [ "`uname`" = "Darwin" ]; then
# Use pbpaste to get the clipboard # Use pbpaste to get the clipboard
alias paste='pbpaste' alias paste='pbpaste'
elif which xclip &> /dev/null; then elif which xclip &> /dev/null; then
@@ -69,11 +66,8 @@ if which bat &> /dev/null; then
# Both --theme and --color can be specified multiple times and will override # Both --theme and --color can be specified multiple times and will override
# these defaults. # these defaults.
bat() { bat() {
command bat --theme='TwoDark' --color always --paging auto "$@" command bat --theme='TwoDark' --color always \
} --paging always --pager 'less -R' "$@"
elif which batcat &> /dev/null; then
bat() {
command batcat --theme='TwoDark' --color always --paging auto "$@"
} }
fi fi