Compare commits
22 Commits
309a8833c8
...
osc-52-pas
| Author | SHA1 | Date | |
|---|---|---|---|
| 44ae82b5d6 | |||
| 5d1f53e6b1 | |||
| 8628448d5d | |||
| b1129a164d | |||
| 5e6ad90a98 | |||
| 3e743d6757 | |||
| 63b7170ccb | |||
| 3978f2b1c2 | |||
| 709c65ce7b | |||
| 782589ff81 | |||
| cc5840fd20 | |||
| 014dadecb2 | |||
| b89428cd32 | |||
| 85b531e773 | |||
| acfd0cdee4 | |||
| 4561adf530 | |||
| a7a8d7da8f | |||
| 20a3911ab7 | |||
| ff87027cf7 | |||
| b4d22fc49f | |||
| b694e9cdf5 | |||
| d91d6b3534 |
6
$
Executable file
6
$
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env zsh
|
||||
read -p "Are you sure? [y/N]: " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
exec "$@"
|
||||
fi
|
||||
@@ -1,47 +0,0 @@
|
||||
---
|
||||
- location: ~/.config/zsh
|
||||
- apt:
|
||||
- zsh
|
||||
- zsh-doc
|
||||
- pinentry-curses
|
||||
- brew:
|
||||
- zsh
|
||||
- pacman:
|
||||
- zsh
|
||||
- dnf:
|
||||
- util-linux-user
|
||||
- zsh
|
||||
- command:
|
||||
- install: sudo chsh -s `which zsh` $USER
|
||||
remove: sudo chsh -s `which bash` $USER
|
||||
- symlink:
|
||||
- {src: zlogin, dst: ~/.zlogin}
|
||||
- {src: zlogout, dst: ~/.zlogout}
|
||||
- {src: zprofile, dst: ~/.zprofile}
|
||||
- {src: zshenv, dst: ~/.zshenv}
|
||||
- {src: zshrc, dst: ~/.zshrc}
|
||||
- src: prompt_fresh_setup
|
||||
dst: ~/.local/share/zsh/site-functions/prompt_fresh_setup
|
||||
- src: build/_build-dir
|
||||
dst: ~/.local/share/zsh/site-functions/_build-dir
|
||||
- src: sandbox/_sandbox
|
||||
dst: ~/.local/share/zsh/site-functions/_sandbox
|
||||
- src: layout/_layout
|
||||
dst: ~/.local/share/zsh/site-functions/_layout
|
||||
- src: notes/_note
|
||||
dst: ~/.local/share/zsh/site-functions/_note
|
||||
- repo:
|
||||
- https://github.com/zsh-users/zsh-autosuggestions.git
|
||||
- https://github.com/zsh-users/zsh-history-substring-search.git
|
||||
- https://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||
- https://github.com/zsh-users/zsh-completions.git
|
||||
- https://github.com/junegunn/fzf.git
|
||||
- command:
|
||||
- fzf/install --bin
|
||||
- symlink:
|
||||
- {src: fzf/bin/fzf, dst: ~/.local/bin/fzf}
|
||||
- {src: fzf/bin/fzf-tmux, dst: ~/.local/bin/fzf-tmux}
|
||||
- {src: cmake-uninstall, dst: ~/.local/bin/cmake-uninstall}
|
||||
- command:
|
||||
- zsh update-completion-links.zsh
|
||||
- message: zsh will be the default prompt after next login
|
||||
12
README.md
12
README.md
@@ -2,15 +2,13 @@
|
||||
|
||||
<!-- TODO: GIF -->
|
||||
|
||||
## [conduit][conduit]
|
||||
## Ansible
|
||||
|
||||
Simple, local, configuration manager.
|
||||
To install this Zsh configuration:
|
||||
|
||||
Installation of the configuration files in this repository is orchestrated by
|
||||
[conduit][conduit] as defined in the [`.conduit.yaml`](.conduit.yaml) file. This
|
||||
includes [Zsh][zsh] package installs, setting [Zsh][zsh] as the users default
|
||||
shell, and symbolic linking file such as [`zshrc`](zshrc) to `~/.zshrc`, and
|
||||
cloning plugin repositories. The repository is cloned to `~/.config/zsh`.
|
||||
```console
|
||||
$ ansible-playbook main.yaml --ask-become-pass
|
||||
```
|
||||
|
||||
## Prompt
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ commands:
|
||||
_autoenv_authorized $PWD/.enter yes
|
||||
_autoenv_authorized $PWD/.exit yes
|
||||
_autoenv_enter $PWD
|
||||
pip install pynvim
|
||||
;;
|
||||
|
||||
*) # Invalid arguments, show help then error.
|
||||
|
||||
@@ -27,9 +27,11 @@ 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 preexec fresh_almostontop
|
||||
add-zsh-hook precmd fresh_almostontop_precmd
|
||||
add-zsh-hook preexec fresh_almostontop_preexec
|
||||
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
|
||||
|
||||
[ $recompile -eq 1 ] && prompt_cleanup
|
||||
@@ -42,7 +44,7 @@ prompt_fresh_setup() {
|
||||
fi
|
||||
|
||||
local userhost=$USER
|
||||
if [ "$SSH_CONNECTION" != "" ]; then
|
||||
if [ "$SSH_CONNECTION" != "" ] || [ "$DISTROBOX_ENTER_PATH" != "" ]; then
|
||||
local user="$user@%{%F{244}%}%M%{%f%}"
|
||||
local userhost="$userhost@`hostname`"
|
||||
fi
|
||||
@@ -128,10 +130,43 @@ fresh_line_one() {
|
||||
print -P "$time_stamp $directory$git$py$docker$result"
|
||||
}
|
||||
|
||||
fresh_almostontop() {
|
||||
clear
|
||||
fresh_line_one
|
||||
print -P "$PROMPT"'$1'
|
||||
# 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
|
||||
printf "\033[6n"
|
||||
# Discard prefix delimited by [
|
||||
read -s -d [
|
||||
# Store the <row> delimited by ; in row
|
||||
read -s -d \; row
|
||||
# Discard suffix delimted by R otherwise it is output to the tty
|
||||
read -s -d R
|
||||
# Move the cursor to the bottom of the terminal
|
||||
# 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"
|
||||
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"
|
||||
printf "\033[${up}A"
|
||||
}
|
||||
|
||||
fresh_compile_git_prompt() {
|
||||
|
||||
91
tasks.yaml
Normal file
91
tasks.yaml
Normal file
@@ -0,0 +1,91 @@
|
||||
---
|
||||
- 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
|
||||
@@ -2,13 +2,52 @@
|
||||
|
||||
autoload colors && colors
|
||||
|
||||
# Abstract different ways to copy to the clipboard.
|
||||
if [ -n "$SSH_CONNECTION" ] ; then
|
||||
# Use OSC-52 to set the clipboard
|
||||
alias copy='base64 | xargs -0 printf "\033]52;c;%s\a"'
|
||||
elif [ "`uname`" = "Darwin" ]; then
|
||||
# Use pbcopy to set the clipboard
|
||||
alias copy='pbcopy'
|
||||
elif which xclip &> /dev/null; then
|
||||
# Use xclip to set the clipboard
|
||||
alias copy='xclip -selection c'
|
||||
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
|
||||
# Use pbpaste to get the clipboard
|
||||
alias paste='pbpaste'
|
||||
elif which xclip &> /dev/null; then
|
||||
# Use xclip to get the clipboard
|
||||
alias paste='xclip -selection c -o'
|
||||
fi
|
||||
|
||||
# Passthrough an escape sequences tmux doesn't know about.
|
||||
tmux-dcs-passthrough() {
|
||||
if [ -n "$TMUX" ]; then
|
||||
printf "\x1bPtmux;\x1b$1\x1b\\"
|
||||
else
|
||||
printf "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# OSC 9 - Post a notification - supported by iTerm2, maybe others?
|
||||
notify() {
|
||||
tmux-dcs-passthrough "\x1b]9;$*\x7"
|
||||
}
|
||||
|
||||
# Detect the type and extract an archive file.
|
||||
extract() {
|
||||
if [ -f $1 ]; then
|
||||
case $1 in
|
||||
*.tar.bz2) tar xvjf $1 ;;
|
||||
*.tar.gz) tar xvzf $1 ;;
|
||||
*.tar.xz) gunzip $1 ;;
|
||||
*.tar.xz) [ `"uname"` = "Darwin" ] && tar xvJf $1 || tar xf $1 ;;
|
||||
*.bz2) bunzip2 $1 ;;
|
||||
*.rar) unrar x $1 ;;
|
||||
*.gz) gunzip $1 ;;
|
||||
@@ -25,6 +64,19 @@ extract() {
|
||||
fi
|
||||
}
|
||||
|
||||
if which bat &> /dev/null; then
|
||||
# Wrap bat to specify a theme, always enable color, pipe the output to less.
|
||||
# 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 "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
if which docker-machine &> /dev/null; then
|
||||
# Wrap the docker command to print a message if a docker-machine is not
|
||||
# running, rather than just stating it can not find it's socket.
|
||||
|
||||
3
zshenv
3
zshenv
@@ -81,6 +81,7 @@ which pinentry-curses &> /dev/null && \
|
||||
export LPASS_PINENTRY=pinentry-curses
|
||||
|
||||
# Teach these some XDG Base Directory Spec manners
|
||||
export IPYTHONDIR=$HOME/.config/ipython
|
||||
which cargo &> /dev/null && \
|
||||
export CARGO_HOME=$HOME/.local/share/cargo
|
||||
if which ccache &> /dev/null; then
|
||||
@@ -97,5 +98,5 @@ which rustup &> /dev/null && \
|
||||
export RUSTUP_HOME=$HOME/.local/share/rustup
|
||||
export PYLINTHOME=$HOME/.cache/pylint
|
||||
# TODO: terminfo
|
||||
which wget &> /dev/null && \
|
||||
[ -f $HOME/.config/wgetrc ] &&
|
||||
export WGETRC=$HOME/.config/wgetrc
|
||||
|
||||
8
zshrc
8
zshrc
@@ -138,17 +138,13 @@ if [[ `uname` = Linux ]]; then
|
||||
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
|
||||
fi
|
||||
|
||||
# Get the shells parent process name.
|
||||
ppid_name() { echo $(ps -p $(ps -p $(echo $$) -o ppid=) -o comm=) }
|
||||
|
||||
# Enable changing cursor shape based on vi mode
|
||||
if [ "$ITERM_PROFILE" != "" ] && [ "$TMUX" = "" ]; then
|
||||
# iTerm2 cursor shape escape sequences outside tmux
|
||||
cursor_block="\e]50;CursorShape=0\C-G"
|
||||
cursor_line="\e]50;CursorShape=1\C-G"
|
||||
elif [ "$(ppid_name)" != "python2" ]; then
|
||||
# iTerm2 inside tmux or VTE compatible cursor shape escape sequences,
|
||||
# exclude Guake even though it's VTE based it doesn't like these
|
||||
else
|
||||
# iTerm2 inside tmux or VTE compatible cursor shape escape sequences.
|
||||
cursor_block="\e[2 q"
|
||||
cursor_line="\e[6 q"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user