Compare commits
34 Commits
309a8833c8
...
generic-gi
| Author | SHA1 | Date | |
|---|---|---|---|
| 9618713542 | |||
| 5a33d2b5ac | |||
| c691d335c0 | |||
| 715014ed3d | |||
| efcea9e8a5 | |||
| ea61bde858 | |||
| a96aa50fbe | |||
| c61c86e979 | |||
| 8790bc0c4e | |||
| b349befbf4 | |||
| 74f2dd7dae | |||
| a362ab0e04 | |||
| a422ab1125 | |||
| 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 -->
|
<!-- 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
|
```console
|
||||||
[conduit][conduit] as defined in the [`.conduit.yaml`](.conduit.yaml) file. This
|
$ ansible-playbook main.yaml --ask-become-pass
|
||||||
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`.
|
|
||||||
|
|
||||||
## Prompt
|
## Prompt
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ _autoenv() {
|
|||||||
edit:'edit .enter and .exit scripts in current directory'
|
edit:'edit .enter and .exit scripts in current directory'
|
||||||
deinit:'remove .enter and .exit scripts in current directory'
|
deinit:'remove .enter and .exit scripts in current directory'
|
||||||
reload:'reload the current environment'
|
reload:'reload the current environment'
|
||||||
|
add=local:'add .local/bin to PATH'
|
||||||
add=py:'add Python virtualenv to the autoenv'
|
add=py:'add Python virtualenv to the autoenv'
|
||||||
)
|
)
|
||||||
_describe -t commands command commands && ret=0 ;;
|
_describe -t commands command commands && ret=0 ;;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ commands:
|
|||||||
edit edit .enter and .exit scripts in current directory
|
edit edit .enter and .exit scripts in current directory
|
||||||
deinit remove .enter and .exit scripts in current directory
|
deinit remove .enter and .exit scripts in current directory
|
||||||
reload reload the current environment
|
reload reload the current environment
|
||||||
|
add=local add .local/bin to PATH
|
||||||
add=py add Python virtualenv to the autoenv"
|
add=py add Python virtualenv to the autoenv"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ commands:
|
|||||||
if which vim &> /dev/null; then
|
if which vim &> /dev/null; then
|
||||||
# Exit the autoenv before editing.
|
# Exit the autoenv before editing.
|
||||||
_autoenv_exit $PWD
|
_autoenv_exit $PWD
|
||||||
if vim -p $PWD/.enter $PWD/.exit; then
|
if $EDITOR -p $PWD/.enter $PWD/.exit; then
|
||||||
# If enter script exists, authorize it.
|
# If enter script exists, authorize it.
|
||||||
[ -f $PWD/.enter ] && _autoenv_authorized $PWD/.enter yes
|
[ -f $PWD/.enter ] && _autoenv_authorized $PWD/.enter yes
|
||||||
# If exit script exists, authorize it.
|
# If exit script exists, authorize it.
|
||||||
@@ -92,17 +93,39 @@ commands:
|
|||||||
_autoenv_enter $PWD
|
_autoenv_enter $PWD
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
add=local) # Add .local/bin to PATH
|
||||||
|
if ! [ -f $PWD/.enter ] || ! [ -f $PWD/.exit ]; then
|
||||||
|
echo '.enter or .exit not found'; return 1
|
||||||
|
fi
|
||||||
|
_autoenv_exit $PWD
|
||||||
|
# Create .local/bin if not present
|
||||||
|
if ! [ -d $PWD/.local/bin ]; then
|
||||||
|
mkdir -p $PWD/.local/bin
|
||||||
|
fi
|
||||||
|
# On enter: store PATH and insert .local/bin
|
||||||
|
echo 'OLDPATH=$PATH' >> .enter
|
||||||
|
echo 'PATH=$PWD/.local/bin:$PATH' >> .enter
|
||||||
|
# On exit: reset PATH
|
||||||
|
echo 'PATH=$OLDPATH' >> .exit
|
||||||
|
echo 'unset OLDPATH' >> .exit
|
||||||
|
# Authorize modified autoenv
|
||||||
|
_autoenv_authorized $PWD/.enter yes
|
||||||
|
_autoenv_authorized $PWD/.exit yes
|
||||||
|
_autoenv_enter $PWD
|
||||||
|
;;
|
||||||
|
|
||||||
add=py) # Add Python virtualenv to the sandbox
|
add=py) # Add Python virtualenv to the sandbox
|
||||||
if ! [ -f $PWD/.enter ] || ! [ -f $PWD/.exit ]; then
|
if ! [ -f $PWD/.enter ] || ! [ -f $PWD/.exit ]; then
|
||||||
echo '.enter or .exit not found'; return 1
|
echo '.enter or .exit not found'; return 1
|
||||||
fi
|
fi
|
||||||
_autoenv_exit $PWD
|
_autoenv_exit $PWD
|
||||||
virtualenv .local
|
virtualenv -p `command -v python` .local
|
||||||
echo 'source .local/bin/activate' >> .enter
|
echo 'source ${0:a:h}/.local/bin/activate' >> .enter
|
||||||
echo 'deactivate' >> .exit
|
echo 'deactivate' >> .exit
|
||||||
_autoenv_authorized $PWD/.enter yes
|
_autoenv_authorized $PWD/.enter yes
|
||||||
_autoenv_authorized $PWD/.exit yes
|
_autoenv_authorized $PWD/.exit yes
|
||||||
_autoenv_enter $PWD
|
_autoenv_enter $PWD
|
||||||
|
pip install pynvim
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*) # Invalid arguments, show help then error.
|
*) # Invalid arguments, show help then error.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#compdef build-dir
|
#compdef build-dir
|
||||||
|
|
||||||
_arguments \
|
_arguments \
|
||||||
'(-h --help)'{-h,--help}'[]' \
|
'(-h --help)'{-h,--help}'[show this help message and exit]' \
|
||||||
|
'(-s --show)'{-s,--show}'[show the current build directory]' \
|
||||||
'--build[invoke a build after selection]' \
|
'--build[invoke a build after selection]' \
|
||||||
'1:directory:_files'
|
'1:directory:_files'
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ fi
|
|||||||
# Interactively choose a `~build` directory for `build` to build.
|
# Interactively choose a `~build` directory for `build` to build.
|
||||||
build-dir() {
|
build-dir() {
|
||||||
local usage='usage: build-dir [-h] [--build] [<directory>]'
|
local usage='usage: build-dir [-h] [--build] [<directory>]'
|
||||||
local -a help do_build
|
local -a help show do_build
|
||||||
zparseopts -D h=help -help=help -build=do_build
|
zparseopts -D h=help -help=help s=show -show=show -build=do_build
|
||||||
if [[ -n $help ]]; then
|
if [[ -n $help ]]; then
|
||||||
cat << EOF
|
cat << EOF
|
||||||
$usage
|
$usage
|
||||||
@@ -45,12 +45,22 @@ positional arguments:
|
|||||||
|
|
||||||
optional arguments:
|
optional arguments:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
|
-s, --show show the current build directory
|
||||||
--build invoke a build after selection
|
--build invoke a build after selection
|
||||||
EOF
|
EOF
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
error() { echo "\e[31merror:\e[0m $1" }
|
error() { echo "\e[31merror:\e[0m $1" }
|
||||||
warning() { echo "\e[33mwarning:\e[0m $1" }
|
warning() { echo "\e[33mwarning:\e[0m $1" }
|
||||||
|
if [[ -n $show ]]; then
|
||||||
|
if [[ ! -n $build_dir ]]; then
|
||||||
|
error "build directory not set"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
echo "$build_dir"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
local local_build_dir
|
local local_build_dir
|
||||||
if [[ ${#*} -gt 1 ]]; then
|
if [[ ${#*} -gt 1 ]]; then
|
||||||
echo $usage
|
echo $usage
|
||||||
|
|||||||
19
git-prompt.c
19
git-prompt.c
@@ -21,6 +21,11 @@
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define color8(CODE) "\e[3" #CODE "m"
|
||||||
|
#define color256(CODE) "\e[38;5;" #CODE "m"
|
||||||
|
#define bold "\e[1m"
|
||||||
|
#define reset "\e[0m"
|
||||||
|
|
||||||
typedef struct process {
|
typedef struct process {
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
FILE* out;
|
FILE* out;
|
||||||
@@ -104,7 +109,7 @@ int main() {
|
|||||||
}
|
}
|
||||||
char* branch = trim(branch_buf);
|
char* branch = trim(branch_buf);
|
||||||
char prompt[1024] = {};
|
char prompt[1024] = {};
|
||||||
append(prompt, 3, " %{%F{66}%}", branch, "%{%f%}");
|
append(prompt, 3, " " color256(66), branch, reset);
|
||||||
|
|
||||||
// get the upstream remote if one exists
|
// get the upstream remote if one exists
|
||||||
char command[1024] = {};
|
char command[1024] = {};
|
||||||
@@ -178,22 +183,22 @@ int main() {
|
|||||||
if (indexed || modified || deleted || unmerged || untracked) { // modified
|
if (indexed || modified || deleted || unmerged || untracked) { // modified
|
||||||
char int_buf[32];
|
char int_buf[32];
|
||||||
if (indexed) {
|
if (indexed) {
|
||||||
append(prompt, 3, "%{%F{2}%}*", inttostr(int_buf, indexed), "%{%f%}");
|
append(prompt, 3, color8(2) "*", inttostr(int_buf, indexed), reset);
|
||||||
}
|
}
|
||||||
if (modified) {
|
if (modified) {
|
||||||
append(prompt, 3, "%{%F{1}%}+", inttostr(int_buf, modified), "%{%f%}");
|
append(prompt, 3, color8(1) "+", inttostr(int_buf, modified), reset);
|
||||||
}
|
}
|
||||||
if (deleted) {
|
if (deleted) {
|
||||||
append(prompt, 3, "%{%F{1}%}-", inttostr(int_buf, deleted), "%{%f%}");
|
append(prompt, 3, color8(1) "-", inttostr(int_buf, deleted), reset);
|
||||||
}
|
}
|
||||||
if (unmerged) {
|
if (unmerged) {
|
||||||
append(prompt, 3, "%{%B%F{1}%}×", inttostr(int_buf, unmerged), "%{%f%b%}");
|
append(prompt, 3, bold color8(1) "×", inttostr(int_buf, unmerged), reset);
|
||||||
}
|
}
|
||||||
if (untracked) {
|
if (untracked) {
|
||||||
append(prompt, 1, "%{%F{1}%}…%{%f%}");
|
append(prompt, 1, color8(1) "…" reset);
|
||||||
}
|
}
|
||||||
} else { // clean
|
} else { // clean
|
||||||
append(prompt, 1, "%{%B%F{2}%}✓%{%f%b%}");
|
append(prompt, 1, bold color8(2) "✓" reset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// print the prompt
|
// print the prompt
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -64,7 +66,7 @@ fresh_line_one() {
|
|||||||
# Construct the time and directory portions of the prompt
|
# Construct the time and directory portions of the prompt
|
||||||
local time_stamp="%{%F{244}%}%D{%H:%M:%S}%{%f%}"
|
local time_stamp="%{%F{244}%}%D{%H:%M:%S}%{%f%}"
|
||||||
[[ -n $SANDBOX_HOME ]] && \
|
[[ -n $SANDBOX_HOME ]] && \
|
||||||
local directory="%{%F{3}%}$SANDBOX_NAME${PWD#$SANDBOX_HOME}%{%f%}" || \
|
local directory="%{%F{220}%}$SANDBOX_NAME${PWD#$SANDBOX_HOME}%{%f%}" || \
|
||||||
local directory="%{%F{37}%}%~%{%f%}"
|
local directory="%{%F{37}%}%~%{%f%}"
|
||||||
|
|
||||||
# Check we are in a git repository
|
# Check we are in a git repository
|
||||||
@@ -128,10 +130,43 @@ 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.
|
||||||
clear
|
fresh_almostontop_precmd() {
|
||||||
fresh_line_one
|
# CSI ESC[6n gets the cursor position in the form ESC[<row>;<column>R
|
||||||
print -P "$PROMPT"'$1'
|
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() {
|
fresh_compile_git_prompt() {
|
||||||
|
|||||||
99
tasks.yaml
Normal file
99
tasks.yaml
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
---
|
||||||
|
- 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:
|
||||||
|
- pinentry-curses
|
||||||
|
- silversearcher-ag
|
||||||
|
- unzip
|
||||||
|
- zsh-doc
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: zsh install macOS packages
|
||||||
|
when: ansible_os_family == "Darwin"
|
||||||
|
become: false
|
||||||
|
homebrew:
|
||||||
|
name: the_silver_searcher
|
||||||
|
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
|
||||||
@@ -11,7 +11,7 @@ for completion in $zsh_completions/src/_*; do
|
|||||||
# Remove existing completion file if it exists.
|
# Remove existing completion file if it exists.
|
||||||
[ -f $symlink ] && rm $symlink
|
[ -f $symlink ] && rm $symlink
|
||||||
# Check if the command exists on the PATH.
|
# Check if the command exists on the PATH.
|
||||||
if which ${name:1} &> /dev/null; then
|
if command -v ${name:1} &> /dev/null; then
|
||||||
# Symlink the completion for the existing command.
|
# Symlink the completion for the existing command.
|
||||||
[ `uname` = Darwin ] && \
|
[ `uname` = Darwin ] && \
|
||||||
ln -s $completion $symlink || ln -sr $completion $symlink
|
ln -s $completion $symlink || ln -sr $completion $symlink
|
||||||
|
|||||||
@@ -2,13 +2,49 @@
|
|||||||
|
|
||||||
autoload colors && colors
|
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 [ "`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.
|
# Detect the type and extract an archive file.
|
||||||
extract() {
|
extract() {
|
||||||
if [ -f $1 ]; then
|
if [ -f $1 ]; then
|
||||||
case $1 in
|
case $1 in
|
||||||
*.tar.bz2) tar xvjf $1 ;;
|
*.tar.bz2) tar xvjf $1 ;;
|
||||||
*.tar.gz) tar xvzf $1 ;;
|
*.tar.gz) tar xvzf $1 ;;
|
||||||
*.tar.xz) gunzip $1 ;;
|
*.tar.xz) [ `"uname"` = "Darwin" ] && tar xvJf $1 || tar xf $1 ;;
|
||||||
*.bz2) bunzip2 $1 ;;
|
*.bz2) bunzip2 $1 ;;
|
||||||
*.rar) unrar x $1 ;;
|
*.rar) unrar x $1 ;;
|
||||||
*.gz) gunzip $1 ;;
|
*.gz) gunzip $1 ;;
|
||||||
@@ -25,6 +61,19 @@ extract() {
|
|||||||
fi
|
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
|
if which docker-machine &> /dev/null; then
|
||||||
# Wrap the docker command to print a message if a docker-machine is not
|
# 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.
|
# running, rather than just stating it can not find it's socket.
|
||||||
|
|||||||
28
zshenv
28
zshenv
@@ -37,7 +37,7 @@ export CCACHE_CONFIGPATH=$HOME/.config/ccache
|
|||||||
export CCACHE_DIR=$HOME/.cache/ccache
|
export CCACHE_DIR=$HOME/.cache/ccache
|
||||||
|
|
||||||
# Add default CMake generator
|
# Add default CMake generator
|
||||||
which ninja &> /dev/null && \
|
command -v ninja &> /dev/null && \
|
||||||
export CMAKE_GENERATOR=Ninja
|
export CMAKE_GENERATOR=Ninja
|
||||||
|
|
||||||
# Remove duplicates from environment variables
|
# Remove duplicates from environment variables
|
||||||
@@ -47,8 +47,12 @@ typeset -U MANPATH; export MANPATH
|
|||||||
typeset -U INFOPATH; export INFOPATH
|
typeset -U INFOPATH; export INFOPATH
|
||||||
|
|
||||||
# Set default editor.
|
# Set default editor.
|
||||||
which vim &> /dev/null && \
|
if command -v nvim &> /dev/null; then
|
||||||
export EDITOR=`which vim`
|
export EDITOR=`command -v nvim`
|
||||||
|
elif command -v vim &> /dev/null; then
|
||||||
|
export EDITOR=`command -v vim`
|
||||||
|
fi
|
||||||
|
export GIT_EDITOR=$EDITOR
|
||||||
|
|
||||||
# Use ~/.local for pip installs on macOS
|
# Use ~/.local for pip installs on macOS
|
||||||
[ "`uname`" = "Darwin" ] && export PYTHONUSERBASE=$HOME/.local
|
[ "`uname`" = "Darwin" ] && export PYTHONUSERBASE=$HOME/.local
|
||||||
@@ -77,25 +81,25 @@ export PYLINTHOME=~/.local/share/pylint
|
|||||||
export VIRTUAL_ENV_DISABLE_PROMPT=1
|
export VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||||
|
|
||||||
# If pinentry-curses exists, use it for lastpass-cli
|
# If pinentry-curses exists, use it for lastpass-cli
|
||||||
which pinentry-curses &> /dev/null && \
|
command -v pinentry-curses &> /dev/null && \
|
||||||
export LPASS_PINENTRY=pinentry-curses
|
export LPASS_PINENTRY=pinentry-curses
|
||||||
|
|
||||||
# Teach these some XDG Base Directory Spec manners
|
# Teach these some XDG Base Directory Spec manners
|
||||||
which cargo &> /dev/null && \
|
export IPYTHONDIR=$HOME/.config/ipython
|
||||||
|
command -v cargo &> /dev/null && \
|
||||||
export CARGO_HOME=$HOME/.local/share/cargo
|
export CARGO_HOME=$HOME/.local/share/cargo
|
||||||
if which ccache &> /dev/null; then
|
if command -v ccache &> /dev/null; then
|
||||||
export CCACHE_CONFIGPATH=$HOME/.config/ccache.conf
|
export CCACHE_CONFIGPATH=$HOME/.config/ccache.conf
|
||||||
export CCACHE_DIR=$HOME/.cache/ccache
|
export CCACHE_DIR=$HOME/.cache/ccache
|
||||||
fi
|
fi
|
||||||
which conan &> /dev/null && \
|
command -v conan &> /dev/null && \
|
||||||
export CONAN_USER_HOME=$HOME/.local/share/conan
|
export CONAN_USER_HOME=$HOME/.local/share/conan
|
||||||
which docker &> /dev/null && \
|
command -v docker &> /dev/null && \
|
||||||
export DOCKER_CONFIG=$HOME/.local/share/docker
|
export DOCKER_CONFIG=$HOME/.local/share/docker
|
||||||
export GTK_RC_FILES=$HOME/.config/gtk/gtkrc
|
export GTK_RC_FILES=$HOME/.config/gtk/gtkrc
|
||||||
export GTK2_RC_FILES=$HOME/.config/gtk-2.0/gtkrc
|
export GTK2_RC_FILES=$HOME/.config/gtk-2.0/gtkrc
|
||||||
which rustup &> /dev/null && \
|
|
||||||
export RUSTUP_HOME=$HOME/.local/share/rustup
|
|
||||||
export PYLINTHOME=$HOME/.cache/pylint
|
export PYLINTHOME=$HOME/.cache/pylint
|
||||||
|
command -v rustup &> /dev/null && \
|
||||||
|
export RUSTUP_HOME=$HOME/.local/share/rustup
|
||||||
|
export WGETRC=$HOME/.config/wget/rc
|
||||||
# TODO: terminfo
|
# TODO: terminfo
|
||||||
which wget &> /dev/null && \
|
|
||||||
export WGETRC=$HOME/.config/wgetrc
|
|
||||||
|
|||||||
25
zshrc
25
zshrc
@@ -17,6 +17,8 @@ ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(end-of-line vi-end-of-line)
|
|||||||
|
|
||||||
# Search history with a command substring
|
# Search history with a command substring
|
||||||
source-plugin zsh-history-substring-search
|
source-plugin zsh-history-substring-search
|
||||||
|
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND=
|
||||||
|
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND=
|
||||||
|
|
||||||
# Command syntax highlighting
|
# Command syntax highlighting
|
||||||
source-plugin zsh-syntax-highlighting
|
source-plugin zsh-syntax-highlighting
|
||||||
@@ -65,10 +67,10 @@ setopt completeinword
|
|||||||
|
|
||||||
# Initialize completions
|
# Initialize completions
|
||||||
autoload -U compinit
|
autoload -U compinit
|
||||||
compinit
|
compinit -d ~/.cache/zsh/compdump
|
||||||
|
|
||||||
# Add pip to the old completion engine if present
|
# Add pip to the old completion engine if present
|
||||||
if which pip &> /dev/null; then
|
if command -v pip &> /dev/null; then
|
||||||
function _pip_completion {
|
function _pip_completion {
|
||||||
local words cword
|
local words cword
|
||||||
read -Ac words
|
read -Ac words
|
||||||
@@ -138,17 +140,13 @@ if [[ `uname` = Linux ]]; then
|
|||||||
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
|
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
|
||||||
fi
|
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
|
# Enable changing cursor shape based on vi mode
|
||||||
if [ "$ITERM_PROFILE" != "" ] && [ "$TMUX" = "" ]; then
|
if [ "$ITERM_PROFILE" != "" ] && [ "$TMUX" = "" ]; then
|
||||||
# iTerm2 cursor shape escape sequences outside tmux
|
# iTerm2 cursor shape escape sequences outside tmux
|
||||||
cursor_block="\e]50;CursorShape=0\C-G"
|
cursor_block="\e]50;CursorShape=0\C-G"
|
||||||
cursor_line="\e]50;CursorShape=1\C-G"
|
cursor_line="\e]50;CursorShape=1\C-G"
|
||||||
elif [ "$(ppid_name)" != "python2" ]; then
|
else
|
||||||
# iTerm2 inside tmux or VTE compatible cursor shape escape sequences,
|
# iTerm2 inside tmux or VTE compatible cursor shape escape sequences.
|
||||||
# exclude Guake even though it's VTE based it doesn't like these
|
|
||||||
cursor_block="\e[2 q"
|
cursor_block="\e[2 q"
|
||||||
cursor_line="\e[6 q"
|
cursor_line="\e[6 q"
|
||||||
fi
|
fi
|
||||||
@@ -176,15 +174,16 @@ fi
|
|||||||
# Frequntly used directories
|
# Frequntly used directories
|
||||||
function frequent-directory() { export $1; hash -d $1 }
|
function frequent-directory() { export $1; hash -d $1 }
|
||||||
frequent-directory Projects="$HOME/Projects"
|
frequent-directory Projects="$HOME/Projects"
|
||||||
|
frequent-directory Sandbox="$HOME/Sandbox"
|
||||||
|
|
||||||
# Load work related config
|
# Load work related config
|
||||||
[ -f ~/.config/work/zshrc ] && source ~/.config/work/zshrc
|
[ -f ~/.config/work/zshrc ] && source ~/.config/work/zshrc
|
||||||
|
|
||||||
# Aliases
|
# Aliases
|
||||||
alias grep='grep --color=always'
|
alias grep='grep --color=always'
|
||||||
which cmake &> /dev/null && \
|
command -v cmake &> /dev/null && \
|
||||||
alias cninja='cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON'
|
alias cninja='cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON'
|
||||||
which ssh &> /dev/null && \
|
command -v ssh &> /dev/null && \
|
||||||
alias ssh='TERM=xterm-256color ssh'
|
alias ssh='TERM=xterm-256color ssh'
|
||||||
alias weather="curl wttr.in"
|
alias weather="curl wttr.in"
|
||||||
alias cls="clear && printf '\e[3J'"
|
alias cls="clear && printf '\e[3J'"
|
||||||
@@ -192,15 +191,15 @@ alias cls="clear && printf '\e[3J'"
|
|||||||
case `uname` in
|
case `uname` in
|
||||||
Linux)
|
Linux)
|
||||||
alias ls='ls -F --color=auto'
|
alias ls='ls -F --color=auto'
|
||||||
if which cgdb &> /dev/null; then
|
if command -v cgdb &> /dev/null; then
|
||||||
alias debug='cgdb --args'
|
alias debug='cgdb --args'
|
||||||
elif which gdb &> /dev/null; then
|
elif command -v gdb &> /dev/null; then
|
||||||
alias debug='gdb --args'
|
alias debug='gdb --args'
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
Darwin)
|
Darwin)
|
||||||
alias ls='ls -GFh'
|
alias ls='ls -GFh'
|
||||||
which lldb &> /dev/null && \
|
command -v lldb &> /dev/null && \
|
||||||
alias debug='lldb --'
|
alias debug='lldb --'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user