Compare commits
29 Commits
6be7ac0e4e
...
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 | |||
| 309a8833c8 | |||
| c4a91481db | |||
| 0b5fc5ad97 | |||
| 258baeba77 | |||
| b6c11ecdfb | |||
| 92bacb5785 | |||
| 6935281118 |
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,43 +0,0 @@
|
|||||||
---
|
|
||||||
- location: ~/.config/zsh
|
|
||||||
- apt:
|
|
||||||
- zsh
|
|
||||||
- zsh-doc
|
|
||||||
- pinentry-curses
|
|
||||||
- brew:
|
|
||||||
- zsh
|
|
||||||
- pacman:
|
|
||||||
- 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}
|
|
||||||
- command:
|
|
||||||
- zsh update-completion-links.zsh
|
|
||||||
- message: zsh will be the default prompt after next login
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,2 @@
|
|||||||
# Ignore all plugin files in subdirectories
|
# Ignore all plugin files in subdirectories
|
||||||
*/*
|
*/
|
||||||
|
|||||||
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
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ _autoenv() {
|
|||||||
init:'add .enter and .exit scripts in current directory'
|
init:'add .enter and .exit scripts in current directory'
|
||||||
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'
|
||||||
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 ;;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ autoenv() {
|
|||||||
case "$cmd" in
|
case "$cmd" in
|
||||||
-h|--help) # Display help.
|
-h|--help) # Display help.
|
||||||
echo "\
|
echo "\
|
||||||
usage: autoenv [-h] {init,edit,deinit}
|
usage: autoenv [-h] {init,edit,deinit,reload,add=py}
|
||||||
|
|
||||||
options:
|
options:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
@@ -21,6 +21,7 @@ commands:
|
|||||||
init add .enter and .exit scripts in current directory
|
init add .enter and .exit scripts in current directory
|
||||||
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
|
||||||
add=py add Python virtualenv to the autoenv"
|
add=py add Python virtualenv to the autoenv"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -81,6 +82,16 @@ commands:
|
|||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
reload) # Reload the current environment
|
||||||
|
if ! [ -f $PWD/.enter ] || ! [ -f $PWD/.exit ]; then
|
||||||
|
echo '.enter or .exit not found'; return 1
|
||||||
|
fi
|
||||||
|
# Exit the autoenv before editing.
|
||||||
|
_autoenv_exit $PWD
|
||||||
|
# Enter the autoenv.
|
||||||
|
_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
|
||||||
@@ -92,6 +103,7 @@ commands:
|
|||||||
_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.
|
||||||
|
|||||||
105
cmake-uninstall
Executable file
105
cmake-uninstall
Executable file
@@ -0,0 +1,105 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Uninstall a previously installed CMake installation.
|
||||||
|
|
||||||
|
Read the ``install_manifest.txt`` file from a CMake build directory
|
||||||
|
which has been installed then delete the files, and optionally the empty
|
||||||
|
subdirectories of the install prefix, specified within.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from argparse import ArgumentParser, RawDescriptionHelpFormatter
|
||||||
|
from os import listdir, path, remove, rmdir
|
||||||
|
from sys import stderr
|
||||||
|
|
||||||
|
|
||||||
|
def uninstall(build_dir, recursive=False):
|
||||||
|
"""Uninstall a previoulsy installed CMake installation.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
:build_dir: Path to the build directory containing the
|
||||||
|
``install_manifest.txt`` of files to uninstall.
|
||||||
|
:recursive: Boolean flag to enable recursively uninstall empty
|
||||||
|
directories up to the install prefix specified in ``CMakeCache.txt``.
|
||||||
|
"""
|
||||||
|
# Get the list of installed files from the install_manifest.txt
|
||||||
|
install_manifest_path = path.join(build_dir, 'install_manifest.txt')
|
||||||
|
with open(install_manifest_path, 'r') as install_manifest_file:
|
||||||
|
install_manifest = sorted(install_manifest_file.read().splitlines())
|
||||||
|
# Delete files from the filesystem
|
||||||
|
removed = []
|
||||||
|
directories = []
|
||||||
|
for entry in install_manifest:
|
||||||
|
directories.append(path.dirname(entry))
|
||||||
|
if path.isfile(entry):
|
||||||
|
remove(entry)
|
||||||
|
removed.append(entry)
|
||||||
|
if recursive:
|
||||||
|
# Get the install prefix from CMakeCache.txt
|
||||||
|
cmakecache_path = path.join(build_dir, 'CMakeCache.txt')
|
||||||
|
with open(cmakecache_path, 'r') as cmakecache_file:
|
||||||
|
for line in cmakecache_file.read().splitlines():
|
||||||
|
if line.startswith('CMAKE_INSTALL_PREFIX'):
|
||||||
|
prefix = path.normpath(line.split('=')[1])
|
||||||
|
break
|
||||||
|
while True:
|
||||||
|
# Remove duplicates from list
|
||||||
|
directories = list(dict.fromkeys(directories))
|
||||||
|
# Find directories in list which are not empty
|
||||||
|
not_empty = []
|
||||||
|
for index, entry in enumerate(directories):
|
||||||
|
if listdir(entry):
|
||||||
|
not_empty.append(index)
|
||||||
|
# Remove directories which are not empty from list
|
||||||
|
for index in reversed(not_empty):
|
||||||
|
del directories[index]
|
||||||
|
# Delete directories from the filesystem
|
||||||
|
to_del = []
|
||||||
|
to_append = []
|
||||||
|
for index, entry in enumerate(directories):
|
||||||
|
rmdir(entry)
|
||||||
|
removed.append(entry)
|
||||||
|
to_del.append(index)
|
||||||
|
parent = path.dirname(entry)
|
||||||
|
# Add parent directory to the list when not the install prefix
|
||||||
|
if path.normpath(parent) != prefix:
|
||||||
|
to_append.append(parent)
|
||||||
|
# Remove deleted directories from list
|
||||||
|
for index in reversed(to_del):
|
||||||
|
del directories[index]
|
||||||
|
directories += to_append
|
||||||
|
# Exit loop when no more directories in list
|
||||||
|
if not directories:
|
||||||
|
break
|
||||||
|
return removed
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""Command line entry point."""
|
||||||
|
cli = ArgumentParser(description=__doc__,
|
||||||
|
formatter_class=RawDescriptionHelpFormatter)
|
||||||
|
cli.add_argument('--version', action='version', version='%(prog)s 0.1.0')
|
||||||
|
cli.add_argument('-q',
|
||||||
|
'--quiet',
|
||||||
|
action='store_true',
|
||||||
|
help="don't print removed entries to stdout")
|
||||||
|
cli.add_argument('-r',
|
||||||
|
'--recursive',
|
||||||
|
action='store_true',
|
||||||
|
help='recursively remove empty directories')
|
||||||
|
cli.add_argument('build_dir',
|
||||||
|
help='path to the installed CMake build directory')
|
||||||
|
args = cli.parse_args()
|
||||||
|
try:
|
||||||
|
removed = uninstall(args.build_dir, recursive=args.recursive)
|
||||||
|
if not args.quiet:
|
||||||
|
for entry in removed:
|
||||||
|
print(f'-- Uninstalling: {entry}')
|
||||||
|
except FileNotFoundError as error:
|
||||||
|
print(f'error: file not found: {error.filename}', file=stderr)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
try:
|
||||||
|
main()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
exit(130)
|
||||||
@@ -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,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() {
|
||||||
|
|||||||
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
|
||||||
@@ -1,24 +1,107 @@
|
|||||||
# A collection of various shell utilities.
|
# A collection of various shell utilities.
|
||||||
|
|
||||||
|
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.
|
# 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 ;;
|
||||||
*.tar) tar xvf $1 ;;
|
*.tar) tar xvf $1 ;;
|
||||||
*.tbz2) tar xvjf $1 ;;
|
*.tbz2) tar xvjf $1 ;;
|
||||||
*.tgz) tar xvzf $1 ;;
|
*.tgz) tar xvzf $1 ;;
|
||||||
*.zip) unzip $1 ;;
|
*.zip) unzip $1 ;;
|
||||||
*.Z) uncompress $1 ;;
|
*.Z) uncompress $1 ;;
|
||||||
*.7z) 7zr x $1 ;;
|
*.7z) 7zr x $1 ;;
|
||||||
*) echo "error: unable to extract '$1'" ;;
|
*) echo "$fg[red]error:$reset_color unable to extract '$1'" ;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
echo "error: file not found '$1'"
|
echo "$fg[red]error:$reset_color file not found '$1'"
|
||||||
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
|
||||||
|
# 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.
|
||||||
|
docker() {
|
||||||
|
command docker "$@"
|
||||||
|
if ! docker-machine active &> /dev/null; then
|
||||||
|
echo "$fg[red]error:$reset_color no active host found, run:" \
|
||||||
|
"docker-machine start <machine>"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Wrap the docker-machine command to automatically update the environment.
|
||||||
|
# When a machine is started, set the environment variables provided by
|
||||||
|
# docker-machine env <machine>. When a machine is stopped, unset the same
|
||||||
|
# variables.
|
||||||
|
docker-machine() {
|
||||||
|
command docker-machine "$@"
|
||||||
|
if [ "start" = "$1" ]; then
|
||||||
|
eval `docker-machine env $2`
|
||||||
|
elif [ "stop" = "$1" ]; then
|
||||||
|
unset DOCKER_MACHINE_NAME
|
||||||
|
unset DOCKER_CERT_PATH
|
||||||
|
unset DOCKER_HOST
|
||||||
|
unset DOCKER_TLS_VERIFY
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|||||||
27
zshenv
27
zshenv
@@ -20,7 +20,7 @@ PATH=$HOME/.local/bin:$PATH
|
|||||||
MANPATH=$HOME/.local/share/man:$MANPATH
|
MANPATH=$HOME/.local/share/man:$MANPATH
|
||||||
INFOPATH=$HOME/.local/share/info:$INFOPATH
|
INFOPATH=$HOME/.local/share/info:$INFOPATH
|
||||||
|
|
||||||
# Add ccache to the PATH and use XDG base dir paths
|
# Add ccache compiler aliases to PATH and use XDG base dir paths
|
||||||
if [ `uname` = Darwin ]; then
|
if [ `uname` = Darwin ]; then
|
||||||
[ -d /usr/local/opt/python/libexec/bin ] && \
|
[ -d /usr/local/opt/python/libexec/bin ] && \
|
||||||
PATH=/usr/local/opt/python/libexec/bin:$PATH
|
PATH=/usr/local/opt/python/libexec/bin:$PATH
|
||||||
@@ -36,6 +36,10 @@ fi
|
|||||||
export CCACHE_CONFIGPATH=$HOME/.config/ccache
|
export CCACHE_CONFIGPATH=$HOME/.config/ccache
|
||||||
export CCACHE_DIR=$HOME/.cache/ccache
|
export CCACHE_DIR=$HOME/.cache/ccache
|
||||||
|
|
||||||
|
# Add default CMake generator
|
||||||
|
which ninja &> /dev/null && \
|
||||||
|
export CMAKE_GENERATOR=Ninja
|
||||||
|
|
||||||
# Remove duplicates from environment variables
|
# Remove duplicates from environment variables
|
||||||
typeset -U fpath
|
typeset -U fpath
|
||||||
typeset -U PATH; export PATH
|
typeset -U PATH; export PATH
|
||||||
@@ -75,3 +79,24 @@ 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 && \
|
which pinentry-curses &> /dev/null && \
|
||||||
export LPASS_PINENTRY=pinentry-curses
|
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
|
||||||
|
export CCACHE_CONFIGPATH=$HOME/.config/ccache.conf
|
||||||
|
export CCACHE_DIR=$HOME/.cache/ccache
|
||||||
|
fi
|
||||||
|
which conan &> /dev/null && \
|
||||||
|
export CONAN_USER_HOME=$HOME/.local/share/conan
|
||||||
|
which docker &> /dev/null && \
|
||||||
|
export DOCKER_CONFIG=$HOME/.local/share/docker
|
||||||
|
export GTK_RC_FILES=$HOME/.config/gtk/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
|
||||||
|
# TODO: terminfo
|
||||||
|
[ -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
|
[[ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user