Compare commits
1 Commits
osc-52-pas
...
3d27565ddb
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d27565ddb |
6
$
6
$
@@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env zsh
|
||||
read -p "Are you sure? [y/N]: " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
exec "$@"
|
||||
fi
|
||||
3
.conduit.yaml
Normal file
3
.conduit.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- location: ~/.config/zsh
|
||||
- command: ansible-playbook main.yaml --ask-become-pass
|
||||
83
main.yaml
Normal file
83
main.yaml
Normal file
@@ -0,0 +1,83 @@
|
||||
# yaml-language-server: $schema=https://json.schemastore.org/ansible-playbook.json
|
||||
---
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Install Zsh packages
|
||||
package:
|
||||
name: zsh
|
||||
state: present
|
||||
|
||||
- name: Install Zsh Debian packages
|
||||
when: ansible_os_family == "Debian"
|
||||
apt:
|
||||
name: '{{item}}'
|
||||
state: present
|
||||
become: true
|
||||
with_items:
|
||||
- zsh-doc
|
||||
- pinentry-curses
|
||||
|
||||
- name: Clone Zsh Git Repositories
|
||||
git:
|
||||
repo: '{{item.repo}}'
|
||||
dest: '{{item.dest}}'
|
||||
with_items:
|
||||
- repo: https://github.com/zsh-users/zsh-autosuggestions.git
|
||||
dest: ~/.config/zsh/zsh-autosuggestions
|
||||
- repo: https://github.com/zsh-users/zsh-history-substring-search.git
|
||||
dest: ~/.config/zsh/zsh-history-substring-search
|
||||
- repo: https://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||
dest: ~/.config/zsh/zsh-syntax-highlighting
|
||||
- repo: https://github.com/zsh-users/zsh-completions.git
|
||||
dest: ~/.config/zsh/zsh-completions
|
||||
- repo: https://github.com/junegunn/fzf.git
|
||||
dest: ~/.config/zsh/fzf
|
||||
|
||||
- name: Install fzf
|
||||
command:
|
||||
cmd: ~/.config/zsh/fzf/install --bin
|
||||
creates: ~/.config/zsh/fzf/bin/fzf
|
||||
|
||||
- name: Create Zsh symboic links
|
||||
file:
|
||||
state: link
|
||||
src: '{{item.src}}'
|
||||
dest: '{{item.dest}}'
|
||||
with_items:
|
||||
- src: ~/.config/zsh/zlogin
|
||||
dest: ~/.zlogin
|
||||
- src: ~/.config/zsh/zlogout
|
||||
dest: ~/.zlogout
|
||||
- src: ~/.config/zsh/zprofile
|
||||
dest: ~/.zprofile
|
||||
- src: ~/.config/zsh/zshenv
|
||||
dest: ~/.zshenv
|
||||
- src: ~/.config/zsh/zshrc
|
||||
dest: ~/.zshrc
|
||||
- src: ~/.config/zsh/prompt_fresh_setup
|
||||
dest: ~/.local/share/zsh/site-functions/prompt_fresh_setup
|
||||
- src: ~/.config/zsh/build/_build-dir
|
||||
dest: ~/.local/share/zsh/site-functions/_build-dir
|
||||
- src: ~/.config/zsh/sandbox/_sandbox
|
||||
dest: ~/.local/share/zsh/site-functions/_sandbox
|
||||
- src: ~/.config/zsh/layout/_layout
|
||||
dest: ~/.local/share/zsh/site-functions/_layout
|
||||
- src: ~/.config/zsh/notes/_note
|
||||
dest: ~/.local/share/zsh/site-functions/_note
|
||||
- src: ~/.config/zsh/fzf/bin/fzf
|
||||
dest: ~/.local/bin/fzf
|
||||
- src: ~/.config/zsh/fzf/bin/fzf-tmux
|
||||
dest: ~/.local/bin/fzf-tmux
|
||||
- src: ~/.config/zsh/cmake-uninstall
|
||||
dest: ~/.local/bin/cmake-uninstall
|
||||
|
||||
- name: Get absolute path to Zsh
|
||||
shell: which zsh
|
||||
register: zsh
|
||||
changed_when: false
|
||||
|
||||
- name: Set default shell to Zsh
|
||||
user:
|
||||
name: '{{lookup("env", "USER")}}'
|
||||
shell: '{{zsh.stdout}}'
|
||||
become: true
|
||||
@@ -27,11 +27,9 @@ prompt_fresh_setup() {
|
||||
if [ $almostontop -eq 1 ]; then
|
||||
# Hook to clear the screen then prints the prompt with previous command at
|
||||
# the top of the screen.
|
||||
add-zsh-hook precmd fresh_almostontop_precmd
|
||||
add-zsh-hook preexec fresh_almostontop_preexec
|
||||
add-zsh-hook preexec fresh_almostontop
|
||||
else
|
||||
add-zsh-hook -d preexec fresh_almostontop_preexec
|
||||
add-zsh-hook -d precmd fresh_almostontop_precmd
|
||||
add-zsh-hook -d preexec fresh_almostontop
|
||||
fi
|
||||
|
||||
[ $recompile -eq 1 ] && prompt_cleanup
|
||||
@@ -44,7 +42,7 @@ prompt_fresh_setup() {
|
||||
fi
|
||||
|
||||
local userhost=$USER
|
||||
if [ "$SSH_CONNECTION" != "" ] || [ "$DISTROBOX_ENTER_PATH" != "" ]; then
|
||||
if [ "$SSH_CONNECTION" != "" ]; then
|
||||
local user="$user@%{%F{244}%}%M%{%f%}"
|
||||
local userhost="$userhost@`hostname`"
|
||||
fi
|
||||
@@ -130,20 +128,7 @@ fresh_line_one() {
|
||||
print -P "$time_stamp $directory$git$py$docker$result"
|
||||
}
|
||||
|
||||
# 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() {
|
||||
fresh_almostontop() {
|
||||
# CSI ESC[6n gets the cursor position in the form ESC[<row>;<column>R
|
||||
printf "\033[6n"
|
||||
# Discard prefix delimited by [
|
||||
@@ -156,16 +141,14 @@ fresh_almostontop_preexec() {
|
||||
# CSI ESC[<num>B moves the cursor down <num> lines
|
||||
let "down = $LINES - $row"
|
||||
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
|
||||
let "new = $row - $prompt_lines"
|
||||
let "new = $row - 3"
|
||||
for (( i = 0; i < $new; i++ )); do
|
||||
printf "\n"
|
||||
done
|
||||
# Move the cursor to the line below the prompt
|
||||
# CSI ESC[<num>A moves the cursor up <num> lines
|
||||
let "up = $LINES - $prompt_lines"
|
||||
let "up = $LINES - 3"
|
||||
printf "\033[${up}A"
|
||||
}
|
||||
|
||||
|
||||
91
tasks.yaml
91
tasks.yaml
@@ -1,91 +0,0 @@
|
||||
---
|
||||
- name: zsh install packages
|
||||
become: '{{package_become}}'
|
||||
package:
|
||||
name: zsh
|
||||
state: present
|
||||
|
||||
- name: zsh install Debian packages
|
||||
when: ansible_os_family == "Debian"
|
||||
become: true
|
||||
apt:
|
||||
name:
|
||||
- zsh-doc
|
||||
- pinentry-curses
|
||||
- unzip
|
||||
state: present
|
||||
|
||||
- name: zsh clone plugin repos
|
||||
git:
|
||||
repo: '{{item.repo}}'
|
||||
dest: '{{item.dest}}'
|
||||
with_items:
|
||||
- repo: https://github.com/zsh-users/zsh-autosuggestions.git
|
||||
dest: ~/.config/zsh/zsh-autosuggestions
|
||||
- repo: https://github.com/zsh-users/zsh-history-substring-search.git
|
||||
dest: ~/.config/zsh/zsh-history-substring-search
|
||||
- repo: https://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||
dest: ~/.config/zsh/zsh-syntax-highlighting
|
||||
- repo: https://github.com/zsh-users/zsh-completions.git
|
||||
dest: ~/.config/zsh/zsh-completions
|
||||
- repo: https://github.com/junegunn/fzf.git
|
||||
dest: ~/.config/zsh/fzf
|
||||
|
||||
- name: zsh install fzf binaries
|
||||
command:
|
||||
cmd: ~/.config/zsh/fzf/install --bin
|
||||
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
|
||||
file:
|
||||
state: link
|
||||
src: '{{item.src}}'
|
||||
dest: '{{item.dest}}'
|
||||
with_items:
|
||||
- src: ~/.config/zsh/zlogin
|
||||
dest: ~/.zlogin
|
||||
- src: ~/.config/zsh/zlogout
|
||||
dest: ~/.zlogout
|
||||
- src: ~/.config/zsh/zprofile
|
||||
dest: ~/.zprofile
|
||||
- src: ~/.config/zsh/zshenv
|
||||
dest: ~/.zshenv
|
||||
- src: ~/.config/zsh/zshrc
|
||||
dest: ~/.zshrc
|
||||
- src: ~/.config/zsh/prompt_fresh_setup
|
||||
dest: ~/.local/share/zsh/site-functions/prompt_fresh_setup
|
||||
- src: ~/.config/zsh/build/_build-dir
|
||||
dest: ~/.local/share/zsh/site-functions/_build-dir
|
||||
- src: ~/.config/zsh/sandbox/_sandbox
|
||||
dest: ~/.local/share/zsh/site-functions/_sandbox
|
||||
- src: ~/.config/zsh/layout/_layout
|
||||
dest: ~/.local/share/zsh/site-functions/_layout
|
||||
- src: ~/.config/zsh/notes/_note
|
||||
dest: ~/.local/share/zsh/site-functions/_note
|
||||
- src: ~/.config/zsh/fzf/bin/fzf
|
||||
dest: ~/.local/bin/fzf
|
||||
- src: ~/.config/zsh/fzf/bin/fzf-tmux
|
||||
dest: ~/.local/bin/fzf-tmux
|
||||
- src: ~/.config/zsh/cmake-uninstall
|
||||
dest: ~/.local/bin/cmake-uninstall
|
||||
- src: ~/.config/zsh/$
|
||||
dest: ~/.local/bin/$
|
||||
|
||||
- name: zsh get absolute path
|
||||
shell: command -v zsh
|
||||
register: zsh
|
||||
changed_when: false
|
||||
|
||||
- name: zsh set default shell
|
||||
user:
|
||||
name: '{{lookup("env", "USER")}}'
|
||||
shell: '{{zsh.stdout}}'
|
||||
become: true
|
||||
@@ -16,10 +16,7 @@ fi
|
||||
|
||||
# Abstract different ways to paste from the clipboard.
|
||||
# TODO: Use OSC-52 to get the clipboard, not widely supported though
|
||||
if [ -n "$SSH_CONNECTION" ]; then
|
||||
# Use OSC-52 to get the clipboard
|
||||
alias paste='printf "\033]52;c;?\a"'
|
||||
elif [ "`uname`" = "Darwin" ]; then
|
||||
if [ "`uname`" = "Darwin" ]; then
|
||||
# Use pbpaste to get the clipboard
|
||||
alias paste='pbpaste'
|
||||
elif which xclip &> /dev/null; then
|
||||
@@ -47,7 +44,7 @@ extract() {
|
||||
case $1 in
|
||||
*.tar.bz2) tar xvjf $1 ;;
|
||||
*.tar.gz) tar xvzf $1 ;;
|
||||
*.tar.xz) [ `"uname"` = "Darwin" ] && tar xvJf $1 || tar xf $1 ;;
|
||||
*.tar.xz) [ `"uname"` = "Darwin" ] && tar xvJf $1 || gunzip $1 ;;
|
||||
*.bz2) bunzip2 $1 ;;
|
||||
*.rar) unrar x $1 ;;
|
||||
*.gz) gunzip $1 ;;
|
||||
@@ -69,11 +66,8 @@ if which bat &> /dev/null; then
|
||||
# Both --theme and --color can be specified multiple times and will override
|
||||
# these defaults.
|
||||
bat() {
|
||||
command bat --theme='TwoDark' --color always --paging auto "$@"
|
||||
}
|
||||
elif which batcat &> /dev/null; then
|
||||
bat() {
|
||||
command batcat --theme='TwoDark' --color always --paging auto "$@"
|
||||
command bat --theme='Solarized (dark)' --color always \
|
||||
--paging always --pager 'less -R' "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user