Compare commits
7 Commits
fff22c22d7
...
osc-52-pas
| Author | SHA1 | Date | |
|---|---|---|---|
| 44ae82b5d6 | |||
| 5d1f53e6b1 | |||
| 8628448d5d | |||
| b1129a164d | |||
| 5e6ad90a98 | |||
| 3e743d6757 | |||
| 63b7170ccb |
@@ -27,9 +27,11 @@ prompt_fresh_setup() {
|
|||||||
if [ $almostontop -eq 1 ]; then
|
if [ $almostontop -eq 1 ]; then
|
||||||
# Hook to clear the screen then prints the prompt with previous command at
|
# Hook to clear the screen then prints the prompt with previous command at
|
||||||
# the top of the screen.
|
# the top of the screen.
|
||||||
add-zsh-hook preexec fresh_almostontop
|
add-zsh-hook precmd fresh_almostontop_precmd
|
||||||
|
add-zsh-hook preexec fresh_almostontop_preexec
|
||||||
else
|
else
|
||||||
add-zsh-hook -d preexec fresh_almostontop
|
add-zsh-hook -d preexec fresh_almostontop_preexec
|
||||||
|
add-zsh-hook -d precmd fresh_almostontop_precmd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ $recompile -eq 1 ] && prompt_cleanup
|
[ $recompile -eq 1 ] && prompt_cleanup
|
||||||
@@ -42,7 +44,7 @@ prompt_fresh_setup() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local userhost=$USER
|
local userhost=$USER
|
||||||
if [ "$SSH_CONNECTION" != "" ]; then
|
if [ "$SSH_CONNECTION" != "" ] || [ "$DISTROBOX_ENTER_PATH" != "" ]; 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
|
||||||
@@ -128,7 +130,20 @@ fresh_line_one() {
|
|||||||
print -P "$time_stamp $directory$git$py$docker$result"
|
print -P "$time_stamp $directory$git$py$docker$result"
|
||||||
}
|
}
|
||||||
|
|
||||||
fresh_almostontop() {
|
# Executed before each prompt.
|
||||||
|
fresh_almostontop_precmd() {
|
||||||
|
# CSI ESC[6n gets the cursor position in the form ESC[<row>;<column>R
|
||||||
|
printf "\033[6n"
|
||||||
|
# Discard prefix delimited by [
|
||||||
|
read -s -d [
|
||||||
|
# Store the <row> delimited by ; in row_before
|
||||||
|
read -s -d \; row_before
|
||||||
|
# Discard suffix delimted by R otherwise it is output to the tty
|
||||||
|
read -s -d R
|
||||||
|
}
|
||||||
|
|
||||||
|
# Executed just after a command has been read and is about to be executed.
|
||||||
|
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 [
|
||||||
@@ -141,14 +156,16 @@ fresh_almostontop() {
|
|||||||
# CSI ESC[<num>B moves the cursor down <num> lines
|
# CSI ESC[<num>B moves the cursor down <num> lines
|
||||||
let "down = $LINES - $row"
|
let "down = $LINES - $row"
|
||||||
printf "\033[${down}B"
|
printf "\033[${down}B"
|
||||||
|
# Calculate the number of lines in the prompt
|
||||||
|
let "prompt_lines = ($row - $row_before) + 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 - 3"
|
let "new = $row - $prompt_lines"
|
||||||
for (( i = 0; i < $new; i++ )); do
|
for (( i = 0; i < $new; i++ )); do
|
||||||
printf "\n"
|
printf "\n"
|
||||||
done
|
done
|
||||||
# Move the cursor to the line below the prompt
|
# Move the cursor to the line below the prompt
|
||||||
# CSI ESC[<num>A moves the cursor up <num> lines
|
# CSI ESC[<num>A moves the cursor up <num> lines
|
||||||
let "up = $LINES - 3"
|
let "up = $LINES - $prompt_lines"
|
||||||
printf "\033[${up}A"
|
printf "\033[${up}A"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
24
tasks.yaml
24
tasks.yaml
@@ -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"
|
||||||
apt:
|
|
||||||
name: '{{item}}'
|
|
||||||
state: present
|
|
||||||
become: true
|
become: true
|
||||||
with_items:
|
apt:
|
||||||
- zsh-doc
|
name:
|
||||||
- pinentry-curses
|
- zsh-doc
|
||||||
- unzip
|
- pinentry-curses
|
||||||
|
- unzip
|
||||||
|
state: present
|
||||||
|
|
||||||
- name: zsh clone plugin repos
|
- name: zsh clone plugin repos
|
||||||
git:
|
git:
|
||||||
@@ -36,6 +36,14 @@
|
|||||||
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
|
||||||
@@ -72,7 +80,7 @@
|
|||||||
dest: ~/.local/bin/$
|
dest: ~/.local/bin/$
|
||||||
|
|
||||||
- name: zsh get absolute path
|
- name: zsh get absolute path
|
||||||
shell: which zsh
|
shell: command -v zsh
|
||||||
register: zsh
|
register: zsh
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,10 @@ 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 [ "`uname`" = "Darwin" ]; then
|
if [ -n "$SSH_CONNECTION" ]; 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
|
||||||
@@ -66,8 +69,11 @@ 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 \
|
command bat --theme='TwoDark' --color always --paging auto "$@"
|
||||||
--paging always --pager 'less -R' "$@"
|
}
|
||||||
|
elif which batcat &> /dev/null; then
|
||||||
|
bat() {
|
||||||
|
command batcat --theme='TwoDark' --color always --paging auto "$@"
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user