Compare commits
1 Commits
generic-gi
...
osc-52-pas
| Author | SHA1 | Date | |
|---|---|---|---|
| 44ae82b5d6 |
@@ -17,7 +17,6 @@ _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,7 +22,6 @@ 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"
|
||||
;;
|
||||
|
||||
@@ -50,7 +49,7 @@ commands:
|
||||
if which vim &> /dev/null; then
|
||||
# Exit the autoenv before editing.
|
||||
_autoenv_exit $PWD
|
||||
if $EDITOR -p $PWD/.enter $PWD/.exit; then
|
||||
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.
|
||||
@@ -93,34 +92,13 @@ 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 -p `command -v python` .local
|
||||
echo 'source ${0:a:h}/.local/bin/activate' >> .enter
|
||||
virtualenv .local
|
||||
echo 'source .local/bin/activate' >> .enter
|
||||
echo 'deactivate' >> .exit
|
||||
_autoenv_authorized $PWD/.enter yes
|
||||
_autoenv_authorized $PWD/.exit yes
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#compdef build-dir
|
||||
|
||||
_arguments \
|
||||
'(-h --help)'{-h,--help}'[show this help message and exit]' \
|
||||
'(-s --show)'{-s,--show}'[show the current build directory]' \
|
||||
'(-h --help)'{-h,--help}'[]' \
|
||||
'--build[invoke a build after selection]' \
|
||||
'1:directory:_files'
|
||||
|
||||
@@ -32,8 +32,8 @@ fi
|
||||
# Interactively choose a `~build` directory for `build` to build.
|
||||
build-dir() {
|
||||
local usage='usage: build-dir [-h] [--build] [<directory>]'
|
||||
local -a help show do_build
|
||||
zparseopts -D h=help -help=help s=show -show=show -build=do_build
|
||||
local -a help do_build
|
||||
zparseopts -D h=help -help=help -build=do_build
|
||||
if [[ -n $help ]]; then
|
||||
cat << EOF
|
||||
$usage
|
||||
@@ -45,22 +45,12 @@ 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
|
||||
|
||||
19
git-prompt.c
19
git-prompt.c
@@ -21,11 +21,6 @@
|
||||
}
|
||||
#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 {
|
||||
pid_t pid;
|
||||
FILE* out;
|
||||
@@ -109,7 +104,7 @@ int main() {
|
||||
}
|
||||
char* branch = trim(branch_buf);
|
||||
char prompt[1024] = {};
|
||||
append(prompt, 3, " " color256(66), branch, reset);
|
||||
append(prompt, 3, " %{%F{66}%}", branch, "%{%f%}");
|
||||
|
||||
// get the upstream remote if one exists
|
||||
char command[1024] = {};
|
||||
@@ -183,22 +178,22 @@ int main() {
|
||||
if (indexed || modified || deleted || unmerged || untracked) { // modified
|
||||
char int_buf[32];
|
||||
if (indexed) {
|
||||
append(prompt, 3, color8(2) "*", inttostr(int_buf, indexed), reset);
|
||||
append(prompt, 3, "%{%F{2}%}*", inttostr(int_buf, indexed), "%{%f%}");
|
||||
}
|
||||
if (modified) {
|
||||
append(prompt, 3, color8(1) "+", inttostr(int_buf, modified), reset);
|
||||
append(prompt, 3, "%{%F{1}%}+", inttostr(int_buf, modified), "%{%f%}");
|
||||
}
|
||||
if (deleted) {
|
||||
append(prompt, 3, color8(1) "-", inttostr(int_buf, deleted), reset);
|
||||
append(prompt, 3, "%{%F{1}%}-", inttostr(int_buf, deleted), "%{%f%}");
|
||||
}
|
||||
if (unmerged) {
|
||||
append(prompt, 3, bold color8(1) "×", inttostr(int_buf, unmerged), reset);
|
||||
append(prompt, 3, "%{%B%F{1}%}×", inttostr(int_buf, unmerged), "%{%f%b%}");
|
||||
}
|
||||
if (untracked) {
|
||||
append(prompt, 1, color8(1) "…" reset);
|
||||
append(prompt, 1, "%{%F{1}%}…%{%f%}");
|
||||
}
|
||||
} else { // clean
|
||||
append(prompt, 1, bold color8(2) "✓" reset);
|
||||
append(prompt, 1, "%{%B%F{2}%}✓%{%f%b%}");
|
||||
}
|
||||
|
||||
// print the prompt
|
||||
|
||||
@@ -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{220}%}$SANDBOX_NAME${PWD#$SANDBOX_HOME}%{%f%}" || \
|
||||
local directory="%{%F{3}%}$SANDBOX_NAME${PWD#$SANDBOX_HOME}%{%f%}" || \
|
||||
local directory="%{%F{37}%}%~%{%f%}"
|
||||
|
||||
# Check we are in a git repository
|
||||
|
||||
12
tasks.yaml
12
tasks.yaml
@@ -10,17 +10,9 @@
|
||||
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
|
||||
- pinentry-curses
|
||||
- unzip
|
||||
state: present
|
||||
|
||||
- name: zsh clone plugin repos
|
||||
|
||||
@@ -11,7 +11,7 @@ for completion in $zsh_completions/src/_*; do
|
||||
# Remove existing completion file if it exists.
|
||||
[ -f $symlink ] && rm $symlink
|
||||
# Check if the command exists on the PATH.
|
||||
if command -v ${name:1} &> /dev/null; then
|
||||
if which ${name:1} &> /dev/null; then
|
||||
# Symlink the completion for the existing command.
|
||||
[ `uname` = Darwin ] && \
|
||||
ln -s $completion $symlink || ln -sr $completion $symlink
|
||||
|
||||
@@ -16,7 +16,10 @@ 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
|
||||
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
|
||||
|
||||
27
zshenv
27
zshenv
@@ -37,7 +37,7 @@ export CCACHE_CONFIGPATH=$HOME/.config/ccache
|
||||
export CCACHE_DIR=$HOME/.cache/ccache
|
||||
|
||||
# Add default CMake generator
|
||||
command -v ninja &> /dev/null && \
|
||||
which ninja &> /dev/null && \
|
||||
export CMAKE_GENERATOR=Ninja
|
||||
|
||||
# Remove duplicates from environment variables
|
||||
@@ -47,12 +47,8 @@ typeset -U MANPATH; export MANPATH
|
||||
typeset -U INFOPATH; export INFOPATH
|
||||
|
||||
# Set default editor.
|
||||
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
|
||||
which vim &> /dev/null && \
|
||||
export EDITOR=`which vim`
|
||||
|
||||
# Use ~/.local for pip installs on macOS
|
||||
[ "`uname`" = "Darwin" ] && export PYTHONUSERBASE=$HOME/.local
|
||||
@@ -81,25 +77,26 @@ export PYLINTHOME=~/.local/share/pylint
|
||||
export VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||
|
||||
# If pinentry-curses exists, use it for lastpass-cli
|
||||
command -v pinentry-curses &> /dev/null && \
|
||||
which pinentry-curses &> /dev/null && \
|
||||
export LPASS_PINENTRY=pinentry-curses
|
||||
|
||||
# Teach these some XDG Base Directory Spec manners
|
||||
export IPYTHONDIR=$HOME/.config/ipython
|
||||
command -v cargo &> /dev/null && \
|
||||
which cargo &> /dev/null && \
|
||||
export CARGO_HOME=$HOME/.local/share/cargo
|
||||
if command -v ccache &> /dev/null; then
|
||||
if which ccache &> /dev/null; then
|
||||
export CCACHE_CONFIGPATH=$HOME/.config/ccache.conf
|
||||
export CCACHE_DIR=$HOME/.cache/ccache
|
||||
fi
|
||||
command -v conan &> /dev/null && \
|
||||
which conan &> /dev/null && \
|
||||
export CONAN_USER_HOME=$HOME/.local/share/conan
|
||||
command -v docker &> /dev/null && \
|
||||
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
|
||||
export PYLINTHOME=$HOME/.cache/pylint
|
||||
command -v rustup &> /dev/null && \
|
||||
which rustup &> /dev/null && \
|
||||
export RUSTUP_HOME=$HOME/.local/share/rustup
|
||||
export WGETRC=$HOME/.config/wget/rc
|
||||
export PYLINTHOME=$HOME/.cache/pylint
|
||||
# TODO: terminfo
|
||||
[ -f $HOME/.config/wgetrc ] &&
|
||||
export WGETRC=$HOME/.config/wgetrc
|
||||
|
||||
17
zshrc
17
zshrc
@@ -17,8 +17,6 @@ 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
|
||||
@@ -67,10 +65,10 @@ setopt completeinword
|
||||
|
||||
# Initialize completions
|
||||
autoload -U compinit
|
||||
compinit -d ~/.cache/zsh/compdump
|
||||
compinit
|
||||
|
||||
# Add pip to the old completion engine if present
|
||||
if command -v pip &> /dev/null; then
|
||||
if which pip &> /dev/null; then
|
||||
function _pip_completion {
|
||||
local words cword
|
||||
read -Ac words
|
||||
@@ -174,16 +172,15 @@ fi
|
||||
# Frequntly used directories
|
||||
function frequent-directory() { export $1; 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
|
||||
|
||||
# Aliases
|
||||
alias grep='grep --color=always'
|
||||
command -v cmake &> /dev/null && \
|
||||
which cmake &> /dev/null && \
|
||||
alias cninja='cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON'
|
||||
command -v ssh &> /dev/null && \
|
||||
which ssh &> /dev/null && \
|
||||
alias ssh='TERM=xterm-256color ssh'
|
||||
alias weather="curl wttr.in"
|
||||
alias cls="clear && printf '\e[3J'"
|
||||
@@ -191,15 +188,15 @@ alias cls="clear && printf '\e[3J'"
|
||||
case `uname` in
|
||||
Linux)
|
||||
alias ls='ls -F --color=auto'
|
||||
if command -v cgdb &> /dev/null; then
|
||||
if which cgdb &> /dev/null; then
|
||||
alias debug='cgdb --args'
|
||||
elif command -v gdb &> /dev/null; then
|
||||
elif which gdb &> /dev/null; then
|
||||
alias debug='gdb --args'
|
||||
fi
|
||||
;;
|
||||
Darwin)
|
||||
alias ls='ls -GFh'
|
||||
command -v lldb &> /dev/null && \
|
||||
which lldb &> /dev/null && \
|
||||
alias debug='lldb --'
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user