Compare commits
25 Commits
osc-52-pas
...
2dc143a839
| Author | SHA1 | Date | |
|---|---|---|---|
| 2dc143a839 | |||
| 5c62ff219c | |||
| 1121b9a193 | |||
| 0c4cd8880b | |||
| e30f86800d | |||
| ad5dc95e4d | |||
| d226ac7097 | |||
| e7750cb0a9 | |||
|
|
efbfa23241 | ||
| b95b365276 | |||
| 501353a534 | |||
| 02abb0960c | |||
| a81465daad | |||
| 5a33d2b5ac | |||
| c691d335c0 | |||
| 715014ed3d | |||
| efcea9e8a5 | |||
| ea61bde858 | |||
| a96aa50fbe | |||
| c61c86e979 | |||
| 8790bc0c4e | |||
| b349befbf4 | |||
| 74f2dd7dae | |||
| a362ab0e04 | |||
| a422ab1125 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
# Ignore all plugin files in subdirectories
|
||||
*/
|
||||
zsh-*/
|
||||
local
|
||||
|
||||
@@ -17,6 +17,7 @@ _autoenv() {
|
||||
edit:'edit .enter and .exit scripts in current directory'
|
||||
deinit:'remove .enter and .exit scripts in current directory'
|
||||
reload:'reload the current environment'
|
||||
add=local:'add .local/bin to PATH'
|
||||
add=py:'add Python virtualenv to the autoenv'
|
||||
)
|
||||
_describe -t commands command commands && ret=0 ;;
|
||||
|
||||
@@ -22,6 +22,7 @@ commands:
|
||||
edit edit .enter and .exit scripts in current directory
|
||||
deinit remove .enter and .exit scripts in current directory
|
||||
reload reload the current environment
|
||||
add=local add .local/bin to PATH
|
||||
add=py add Python virtualenv to the autoenv"
|
||||
;;
|
||||
|
||||
@@ -45,21 +46,16 @@ commands:
|
||||
if ! [ -f $PWD/.enter ] || ! [ -f $PWD/.exit ]; then
|
||||
echo '.enter or .exit not found'; return 1
|
||||
fi
|
||||
# If vim exists, edit enter and exit scripts.
|
||||
if which vim &> /dev/null; then
|
||||
# Exit the autoenv before editing.
|
||||
_autoenv_exit $PWD
|
||||
if vim -p $PWD/.enter $PWD/.exit; then
|
||||
# If enter script exists, authorize it.
|
||||
[ -f $PWD/.enter ] && _autoenv_authorized $PWD/.enter yes
|
||||
# If exit script exists, authorize it.
|
||||
[ -f $PWD/.exit ] && _autoenv_authorized $PWD/.exit yes
|
||||
fi
|
||||
# Enter the autoenv.
|
||||
_autoenv_enter $PWD
|
||||
else
|
||||
echo 'vim not found'; return 1
|
||||
# Exit the autoenv before editing.
|
||||
_autoenv_exit $PWD
|
||||
if $EDITOR -p $PWD/.enter $PWD/.exit; then
|
||||
# If enter script exists, authorize it.
|
||||
[ -f $PWD/.enter ] && _autoenv_authorized $PWD/.enter yes
|
||||
# If exit script exists, authorize it.
|
||||
[ -f $PWD/.exit ] && _autoenv_authorized $PWD/.exit yes
|
||||
fi
|
||||
# Enter the autoenv.
|
||||
_autoenv_enter $PWD
|
||||
;;
|
||||
|
||||
deinit) # Remove .enter and .exit scripts in current directory.
|
||||
@@ -92,13 +88,34 @@ commands:
|
||||
_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
|
||||
if ! [ -f $PWD/.enter ] || ! [ -f $PWD/.exit ]; then
|
||||
echo '.enter or .exit not found'; return 1
|
||||
fi
|
||||
_autoenv_exit $PWD
|
||||
virtualenv .local
|
||||
echo 'source .local/bin/activate' >> .enter
|
||||
virtualenv -p `command -v python` .local
|
||||
echo 'source ${0:a:h}/.local/bin/activate' >> .enter
|
||||
echo 'deactivate' >> .exit
|
||||
_autoenv_authorized $PWD/.enter yes
|
||||
_autoenv_authorized $PWD/.exit yes
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#compdef build-dir
|
||||
|
||||
_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]' \
|
||||
'1:directory:_files'
|
||||
|
||||
@@ -7,21 +7,17 @@ alias build="build-dir --build"
|
||||
# Detect installed debugger and set the `debug` alias to debug a program with
|
||||
# command line arguments.
|
||||
if [ `uname` = Linux ]; then
|
||||
if [[ "`vim --version|head -1|cut -c 19-21`" =~ "^8\.[123456789]$" ]]; then
|
||||
autoload -U regexp-replace
|
||||
function vimdebug() {
|
||||
# For each item in $* replace * and \* and then replace \ with \\
|
||||
local args=()
|
||||
for arg in "$@"; do
|
||||
regexp-replace arg '\*' '\\*'
|
||||
args+=($arg)
|
||||
done
|
||||
vim "+packadd termdebug" "+TermdebugCommand $args"
|
||||
}
|
||||
alias debug='vimdebug'
|
||||
elif which cgdb &> /dev/null; then
|
||||
alias debug='cgdb --args'
|
||||
elif which gdb &> /dev/null; then
|
||||
autoload -U regexp-replace
|
||||
function vimdebug() {
|
||||
# For each item in $* replace * and \* and then replace \ with \\
|
||||
local args=()
|
||||
for arg in "$@"; do
|
||||
regexp-replace arg '\*' '\\*'
|
||||
args+=($arg)
|
||||
done
|
||||
nvim "+packadd termdebug" "+TermdebugCommand $args"
|
||||
}
|
||||
if which gdb &> /dev/null; then
|
||||
alias debug='gdb --args'
|
||||
fi
|
||||
elif [ `uname` = Darwin ]; then
|
||||
@@ -32,8 +28,8 @@ fi
|
||||
# Interactively choose a `~build` directory for `build` to build.
|
||||
build-dir() {
|
||||
local usage='usage: build-dir [-h] [--build] [<directory>]'
|
||||
local -a help do_build
|
||||
zparseopts -D h=help -help=help -build=do_build
|
||||
local -a help show do_build
|
||||
zparseopts -D h=help -help=help s=show -show=show -build=do_build
|
||||
if [[ -n $help ]]; then
|
||||
cat << EOF
|
||||
$usage
|
||||
@@ -45,12 +41,22 @@ positional arguments:
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-s, --show show the current build directory
|
||||
--build invoke a build after selection
|
||||
EOF
|
||||
return
|
||||
fi
|
||||
error() { echo "\e[31merror:\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
|
||||
if [[ ${#*} -gt 1 ]]; then
|
||||
echo $usage
|
||||
|
||||
22
list-commands-with-available-completions.zsh
Executable file
22
list-commands-with-available-completions.zsh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
# Loop over available completions and add existing commands to array.
|
||||
local -a completions
|
||||
completions=(~/.config/zsh/zsh-completions/src/*)
|
||||
local -a command_list
|
||||
for completion in $completions; do
|
||||
local filename=$(basename $completion)
|
||||
local name=${filename:1}
|
||||
if command -v $name &> /dev/null; then
|
||||
command_list+=($name)
|
||||
fi
|
||||
done
|
||||
|
||||
# Print JSON array of commands Ansible can consume.
|
||||
echo '['
|
||||
local length=${#command_list[@]}
|
||||
for (( i = 1; i < $length; i++ )); do
|
||||
echo " \"${command_list[$i]}\","
|
||||
done
|
||||
echo " \"${command_list[-1]}\""
|
||||
echo ']'
|
||||
@@ -49,8 +49,8 @@ prompt_fresh_setup() {
|
||||
local userhost="$userhost@`hostname`"
|
||||
fi
|
||||
|
||||
PS1="«$user» "
|
||||
PS2="«${(l:${#userhost}:: :)}» "
|
||||
PS1="$user "
|
||||
PS2="${(l:${#userhost}:: :)} "
|
||||
|
||||
prompt_opts=(percent sp subst)
|
||||
}
|
||||
@@ -66,7 +66,7 @@ fresh_line_one() {
|
||||
# Construct the time and directory portions of the prompt
|
||||
local time_stamp="%{%F{244}%}%D{%H:%M:%S}%{%f%}"
|
||||
[[ -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%}"
|
||||
|
||||
# Check we are in a git repository
|
||||
|
||||
@@ -44,14 +44,11 @@ usage: sandbox [-h] {create,rename,destroy,enable,disable,list} ..
|
||||
fi
|
||||
done
|
||||
unset git
|
||||
|
||||
[[ -z "$name" ]] && \
|
||||
error "missing argument <name>\n$usage" && return 1
|
||||
|
||||
local sandbox=$SANDBOX_ROOT/$name
|
||||
[[ -d "$sandbox" ]] && \
|
||||
error "sandbox already exists $name" && return 1
|
||||
|
||||
if [[ -n "$repo" ]]; then
|
||||
mkdir -p $SANDBOX_ROOT &> /dev/null
|
||||
git clone $repo $sandbox
|
||||
@@ -61,55 +58,49 @@ usage: sandbox [-h] {create,rename,destroy,enable,disable,list} ..
|
||||
cd $sandbox
|
||||
git init &> /dev/null
|
||||
fi
|
||||
|
||||
echo "SANDBOX_HOME=\$(dirname -- "\$0:a")" >> $sandbox/.enter
|
||||
echo "SANDBOX_NAME=$name" >> $sandbox/.enter
|
||||
_autoenv_authorized $sandbox/.enter yes
|
||||
|
||||
echo "unset SANDBOX_NAME" >> $sandbox/.exit
|
||||
echo "unset SANDBOX_HOME" >> $sandbox/.exit
|
||||
_autoenv_authorized $sandbox/.exit yes
|
||||
|
||||
_autoenv_enter $sandbox
|
||||
;;
|
||||
|
||||
rename)
|
||||
local old_name=$1 new_name=$2
|
||||
[[ -z "$old_name" ]] && \
|
||||
error "missing argument <old-name>\n$usage" && return 1
|
||||
[[ -z "$new_name" ]] && \
|
||||
error "missing argument <new-name>\n$usage" && return 1
|
||||
|
||||
local old=$SANDBOX_ROOT/$old_name new=$SANDBOX_ROOT/$new_name
|
||||
[[ ! -d "$old" ]] && \
|
||||
error "sandbox does not exist $old_name" && return 1
|
||||
[[ -d "$new" ]] && \
|
||||
error "sandbox already exists $new_name" && return 1
|
||||
|
||||
[[ "$PWD" = "$old"* ]] && _autoenv_exit $PWD
|
||||
|
||||
mv $old $new
|
||||
sed -i "s/$old_name/$new_name/g" $new/.enter
|
||||
_autoenv_authorized $new/.enter yes
|
||||
_autoenv_authorized $new/.exit yes
|
||||
|
||||
[[ "$PWD" = "$old"* ]] && cd $new
|
||||
;;
|
||||
|
||||
destroy)
|
||||
local name=$1
|
||||
[[ -z "$name" ]] && \
|
||||
error "missing argument <name>\n$usage" && return 1
|
||||
|
||||
local sandbox=$SANDBOX_ROOT/$name
|
||||
[[ ! -d $sandbox ]] && \
|
||||
error "sandbox does not exist $name" && return 1
|
||||
|
||||
[[ "$PWD" = "$sandbox"* ]] && cd ~
|
||||
|
||||
rm -rf $sandbox
|
||||
;;
|
||||
|
||||
list)
|
||||
ls -1 $SANDBOX_ROOT | less -F -K -R -X
|
||||
;;
|
||||
|
||||
enable)
|
||||
local name=$1
|
||||
[[ -z "$name" ]] && \
|
||||
@@ -118,16 +109,19 @@ usage: sandbox [-h] {create,rename,destroy,enable,disable,list} ..
|
||||
local sandbox=$SANDBOX_ROOT/$name
|
||||
[[ ! -d $sandbox ]] && \
|
||||
error "sandbox does not exist $name" && return 1
|
||||
|
||||
export SANDBOX_RETURN=$PWD
|
||||
cd $sandbox
|
||||
;;
|
||||
|
||||
disable)
|
||||
[[ -z "$SANDBOX_RETURN" ]] && \
|
||||
error "sandbox is not currently active" && return 1
|
||||
|
||||
cd $SANDBOX_RETURN
|
||||
unset SANDBOX_RETURN
|
||||
;;
|
||||
|
||||
*)
|
||||
error "invalid sandbox command: $cmd" && return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
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
|
||||
@@ -1,19 +0,0 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
# Check if third party completions are present.
|
||||
local zsh_completions=~/.config/zsh/zsh-completions
|
||||
[ ! -d $zsh_completions ] && return 0
|
||||
|
||||
# Loop over all completions.
|
||||
for completion in $zsh_completions/src/_*; do
|
||||
local name=`basename $completion`
|
||||
local symlink=~/.local/share/zsh/site-functions/$name
|
||||
# Remove existing completion file if it exists.
|
||||
[ -f $symlink ] && rm $symlink
|
||||
# Check if the command exists on the PATH.
|
||||
if which ${name:1} &> /dev/null; then
|
||||
# Symlink the completion for the existing command.
|
||||
[ `uname` = Darwin ] && \
|
||||
ln -s $completion $symlink || ln -sr $completion $symlink
|
||||
fi
|
||||
done
|
||||
22
url/_url
Normal file
22
url/_url
Normal file
@@ -0,0 +1,22 @@
|
||||
#compdef url
|
||||
|
||||
_url() {
|
||||
local ret=1 context curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C -w -s \
|
||||
'(-h --help)'{-h,--help}'[show this help message and exit]' \
|
||||
'1: :->command'
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
declare -a commands
|
||||
local commands=(
|
||||
encode:'encode unencoded text'
|
||||
decode:'decode encoded text'
|
||||
)
|
||||
_describe -t commands command commands && ret=0 ;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
22
url/url
Executable file
22
url/url
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from argparse import ArgumentParser
|
||||
from urllib import parse
|
||||
|
||||
|
||||
def main():
|
||||
cli = ArgumentParser(description=__doc__)
|
||||
cli.add_argument('command', choices=['encode', 'decode'])
|
||||
cli.add_argument('text')
|
||||
args = cli.parse_args()
|
||||
print({
|
||||
'encode': parse.quote_plus,
|
||||
'decode': parse.unquote_plus,
|
||||
}[args.command](args.text))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except KeyboardInterrupt:
|
||||
exit(130)
|
||||
@@ -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
|
||||
|
||||
43
zshenv
43
zshenv
@@ -22,10 +22,17 @@ INFOPATH=$HOME/.local/share/info:$INFOPATH
|
||||
|
||||
# Add ccache compiler aliases to PATH and use XDG base dir paths
|
||||
if [ `uname` = Darwin ]; then
|
||||
[ -d /usr/local/opt/python/libexec/bin ] && \
|
||||
PATH=/usr/local/opt/python/libexec/bin:$PATH
|
||||
[ -f /usr/local/bin/ccache ] && \
|
||||
PATH=/usr/local/opt/ccache/libexec:$PATH
|
||||
if [ `uname -m` = arm64 ]; then
|
||||
homebrew_root=/opt/homebrew
|
||||
[ -d /opt/homebrew/bin ] && \
|
||||
PATH=$homebrew_root/bin:$PATH
|
||||
else
|
||||
homebrew_root=/usr/local
|
||||
fi
|
||||
[ -d $homebrew_root/opt/python/libexec/bin ] && \
|
||||
PATH=$homebrew_root/opt/python/libexec/bin:$PATH
|
||||
[ -f $homebrew_root/bin/ccache ] && \
|
||||
PATH=$homebrew_root/opt/ccache/libexec:$PATH
|
||||
elif [ -f /usr/bin/ccache ]; then
|
||||
if [ -d /usr/lib/ccache/bin ]; then
|
||||
PATH=/usr/lib/ccache/bin:$PATH
|
||||
@@ -37,7 +44,7 @@ export CCACHE_CONFIGPATH=$HOME/.config/ccache
|
||||
export CCACHE_DIR=$HOME/.cache/ccache
|
||||
|
||||
# Add default CMake generator
|
||||
which ninja &> /dev/null && \
|
||||
command -v ninja &> /dev/null && \
|
||||
export CMAKE_GENERATOR=Ninja
|
||||
|
||||
# Remove duplicates from environment variables
|
||||
@@ -47,8 +54,12 @@ typeset -U MANPATH; export MANPATH
|
||||
typeset -U INFOPATH; export INFOPATH
|
||||
|
||||
# Set default editor.
|
||||
which vim &> /dev/null && \
|
||||
export EDITOR=`which vim`
|
||||
if command -v nvim &> /dev/null; then
|
||||
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
|
||||
[ "`uname`" = "Darwin" ] && export PYTHONUSERBASE=$HOME/.local
|
||||
@@ -77,26 +88,26 @@ export PYLINTHOME=~/.local/share/pylint
|
||||
export VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||
|
||||
# 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
|
||||
|
||||
# Teach these some XDG Base Directory Spec manners
|
||||
export IPYTHONDIR=$HOME/.config/ipython
|
||||
which cargo &> /dev/null && \
|
||||
command -v cargo &> /dev/null && \
|
||||
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_DIR=$HOME/.cache/ccache
|
||||
fi
|
||||
which conan &> /dev/null && \
|
||||
command -v conan &> /dev/null && \
|
||||
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 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
|
||||
command -v rustup &> /dev/null && \
|
||||
export RUSTUP_HOME=$HOME/.local/share/rustup
|
||||
[ -f $HOME/.config/wget/rc ] && \
|
||||
export WGETRC=$HOME/.config/wget/rc
|
||||
# TODO: terminfo
|
||||
[ -f $HOME/.config/wgetrc ] &&
|
||||
export WGETRC=$HOME/.config/wgetrc
|
||||
|
||||
30
zshrc
30
zshrc
@@ -17,6 +17,8 @@ ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(end-of-line vi-end-of-line)
|
||||
|
||||
# Search history with a command substring
|
||||
source-plugin zsh-history-substring-search
|
||||
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND=
|
||||
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND=
|
||||
|
||||
# Command syntax highlighting
|
||||
source-plugin zsh-syntax-highlighting
|
||||
@@ -65,10 +67,10 @@ setopt completeinword
|
||||
|
||||
# Initialize completions
|
||||
autoload -U compinit
|
||||
compinit
|
||||
compinit -d ~/.cache/zsh/compdump
|
||||
|
||||
# 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 {
|
||||
local words cword
|
||||
read -Ac words
|
||||
@@ -170,17 +172,26 @@ if [[ ! -z "$cursor_block" && ! -z "$cursor_line" ]]; then
|
||||
fi
|
||||
|
||||
# Frequntly used directories
|
||||
function frequent-directory() { export $1; hash -d $1 }
|
||||
function frequent-directory() {
|
||||
# Replace - with _ in environment variable name.
|
||||
local name=$(echo $1 | sed 's/^\(.*\)=.*$/\1/g' | sed 's/-/_/g')
|
||||
local value=$(echo $1 | sed 's/^.*=\(.*$\)/\1/g')
|
||||
export $name=$value
|
||||
hash -d $1
|
||||
}
|
||||
frequent-directory Projects="$HOME/Projects"
|
||||
frequent-directory Sandbox="$HOME/Sandbox"
|
||||
|
||||
# Load work related config
|
||||
[ -f ~/.config/work/zshrc ] && source ~/.config/work/zshrc
|
||||
[ -f ~/.config/private/zshrc ] && source ~/.config/private/zshrc
|
||||
[ -f ~/.config/zsh/local ] && source ~/.config/zsh/local
|
||||
|
||||
# Aliases
|
||||
alias grep='grep --color=always'
|
||||
which cmake &> /dev/null && \
|
||||
command -v cmake &> /dev/null && \
|
||||
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 weather="curl wttr.in"
|
||||
alias cls="clear && printf '\e[3J'"
|
||||
@@ -188,15 +199,18 @@ alias cls="clear && printf '\e[3J'"
|
||||
case `uname` in
|
||||
Linux)
|
||||
alias ls='ls -F --color=auto'
|
||||
if which cgdb &> /dev/null; then
|
||||
if command -v cgdb &> /dev/null; then
|
||||
alias debug='cgdb --args'
|
||||
elif which gdb &> /dev/null; then
|
||||
elif command -v gdb &> /dev/null; then
|
||||
alias debug='gdb --args'
|
||||
fi
|
||||
;;
|
||||
Darwin)
|
||||
alias ls='ls -GFh'
|
||||
which lldb &> /dev/null && \
|
||||
command -v lldb &> /dev/null && \
|
||||
alias debug='lldb --'
|
||||
;;
|
||||
esac
|
||||
|
||||
command -v wol > /dev/null && \
|
||||
alias wakeonlan='wol'
|
||||
|
||||
Reference in New Issue
Block a user