Compare commits

...

63 commits

Author SHA1 Message Date
1b91432bdc Merge branch 'master' of ssh://git.0l.de:2222/stv0g/dotfiles 2019-12-03 21:42:10 +01:00
e82d2f7b19 iterm: update config 2019-12-03 21:11:04 +01:00
ba4ea52d99 env: fix missing PATH for homebrew GNU utils 2019-12-03 21:07:38 +01:00
58410995ad remove anyconnect config 2019-12-03 21:06:57 +01:00
53caf2c911 ssh: switch from aliases to DNS names 2019-12-03 21:05:51 +01:00
e5b5586e1c k8s: use kubelogin installed via krew 2019-12-03 21:05:02 +01:00
aeffacd1c8 Merge branch 'master' of github.com:stv0g/dotfiles 2019-11-21 11:21:50 +01:00
98f8731afd add oath script 2019-11-21 11:16:41 +01:00
8b46554e3f Merge branch 'master' of github.com:stv0g/dotfiles 2019-11-21 11:07:50 +01:00
3a757c5d93 add env vars for {ssh,gpg}-agent 2019-11-21 11:07:46 +01:00
470f609979 add kubectl config 2019-11-21 11:05:55 +01:00
dde077f63c add missing repo to bootstrap script 2019-11-21 10:52:13 +01:00
eaf261946d simplify brew env setup 2019-11-21 10:50:05 +01:00
1cf6b4b7f8 add minio completion 2019-11-21 10:44:08 +01:00
a94ca71c73 update iterm2 shell integration 2019-11-21 10:44:08 +01:00
476dfca2f6 use tilde expansion 2019-11-21 10:44:08 +01:00
fed1c8dd42 update SSH config 2019-11-21 10:44:08 +01:00
85efaba3fa update iterm2 config 2019-11-21 10:44:08 +01:00
aab59c1e66 add calicoctl env vars 2019-11-21 10:44:08 +01:00
138123b44f update git-lfs config 2019-11-21 10:42:54 +01:00
1ee71bd3a8 update SSH config 2019-11-21 10:42:54 +01:00
6c8cd9ab2b add QMK config 2019-11-21 10:42:54 +01:00
abe49cf6f8 update aliases 2019-11-21 10:42:54 +01:00
a667ce65ff add better completions for homebrew 2019-11-21 10:42:54 +01:00
3a8905c59b update git url in bootstrap.sh 2019-11-21 10:38:50 +01:00
882e8e5ed9 activate brew completions only if brew is available 2019-11-21 10:38:50 +01:00
108be77525 update README 2019-11-21 10:37:48 +01:00
e55dcd2500 do not use ssh proxyjump by default 2019-11-21 10:37:48 +01:00
e1cdd92c3f add acs-fedora-svg-2 ssh host 2019-11-21 10:37:48 +01:00
fd4d243396 add nrg5 ssh host 2019-11-21 10:37:48 +01:00
ba120919cc add rck ssh host 2019-11-21 10:37:48 +01:00
98018bf756 update bash env for Homebrew 2019-11-21 10:37:48 +01:00
7f51677f85 add villas-hub ssh host 2019-11-21 10:32:03 +01:00
52f0210b2d update buildbot ssh hosts 2019-11-21 10:32:03 +01:00
dbacfa1bdf update restic password 2019-11-21 10:32:03 +01:00
7d616c5d67 update package script 2019-11-21 10:32:03 +01:00
09e6335a67 use vscode as diff/merge tool for stree 2019-11-21 10:32:03 +01:00
14fcfa95cf update iTerm2 config 2019-11-21 10:32:03 +01:00
d044f09f64 update EDITOR variable 2019-11-21 10:32:03 +01:00
a2434cf319 remove duplicated homeshick include 2019-11-21 10:32:03 +01:00
775ac38b27 remote ntfy support 2019-11-21 10:32:03 +01:00
d4d97ebe1e update bash aliases 2019-11-21 10:32:03 +01:00
f5d08a87f9 use homebrew bash completions 2019-11-21 10:32:03 +01:00
6245ab4323 add tmux config 2019-11-21 10:30:53 +01:00
491b2b336e add ERIGrid ssh hosts 2019-11-21 10:30:53 +01:00
2eb2d0c140 remove obsolete ssh hosts 2019-11-21 10:30:53 +01:00
c926234c29 added acs-k8s to ssh config 2019-11-21 10:30:53 +01:00
bde6ad2b26 env: fix location of Restic repo 2019-11-21 10:30:53 +01:00
df5b771fa5 env: fix merge conflict 2019-11-21 10:30:53 +01:00
9d06233c56 alias: add alias for requesting invite token for ssb pub 2019-11-21 10:28:51 +01:00
8438575a80 alias: add alias for vscodium 2019-11-21 10:28:51 +01:00
7938f710e6 ssh: add acs-buildbot-2 2019-11-21 10:28:51 +01:00
b7e3e9518b ssh: fix hostname of nag 2019-11-21 10:28:51 +01:00
24a6c20c04 ssh: enable port forwarding for rcode 2019-11-21 10:28:51 +01:00
7982ca8361 ssh: use root instead of acs-admin for acs-hyperX 2019-11-21 10:28:51 +01:00
ea33452398 ssh: add new hosts 2019-11-21 10:28:51 +01:00
3ab1c940c2 completion: avoid long running commands in shell startup 2019-11-21 10:28:51 +01:00
d74d02cf34 add krew to PATH 2019-11-19 18:19:48 +01:00
f784c4a697 update GTK bookmarks 2019-11-19 18:18:55 +01:00
8fda32ec7d fix broken path to kubectl 2019-11-19 18:18:55 +01:00
7d087ad164 use default pinentry tool 2019-11-19 16:40:27 +01:00
3f46b8779f add snap binaries to PATH 2019-11-19 16:40:01 +01:00
ef93d18e86 fix merge issue 2019-11-19 16:39:30 +01:00
15 changed files with 2738 additions and 271 deletions

View file

@ -25,6 +25,7 @@ gc https://github.com/chriskempson/base16-xresources base16-xresources
gc https://github.com/chriskempson/base16-vim base16-vim
gc https://github.com/chriskempson/base16-iterm2 base16-iterm2
gc https://github.com/longld/peda peda
gc https://github.com/cykerway/complete-alias complete-alias
gc https://git.0l.de/stv0g/dotfiles.git dotfiles
if [[ "$OSTYPE" == "darwin"* ]]; then

View file

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<AnyConnectPreferences>
<DefaultUser>sv111090</DefaultUser>
<DefaultSecondUser></DefaultSecondUser>
<ClientCertificateThumbprint>5F7D72CDCCF79986395359B36228F9569FB0369F</ClientCertificateThumbprint>
<MultipleClientCertificateThumbprints></MultipleClientCertificateThumbprints>
<ServerCertificateThumbprint></ServerCertificateThumbprint>
<DefaultHostName>vpn.rwth-aachen.de</DefaultHostName>
<DefaultHostAddress></DefaultHostAddress>
<DefaultGroup>webvpn</DefaultGroup>
<ProxyHost></ProxyHost>
<ProxyPort></ProxyPort>
<SDITokenType></SDITokenType>
<ControllablePreferences>
<LocalLanAccess>true</LocalLanAccess></ControllablePreferences>
</AnyConnectPreferences>

View file

@ -18,7 +18,7 @@ alias ka=killall
alias g=git
alias k=kubectl
alias a=ansible
alias c=code-insiders
alias c=code
alias e=$EDITOR
# Completion for aliases
@ -111,6 +111,8 @@ function restic() {
$RESTIC $@
}
alias acs-pass='PASSWORD_STORE_DIR=~/workspace/rwth/acs/Passwords pass'
alias acs-pass='PASSWORD_STORE_DIR=~/workspace/rwth/acs/lab/passwords pass'
alias chaos-family-invite='ssh -t root@chaos.family /root/sbot invite.create 1 | jq -r . | pbcopy'
alias chaos-family-invite='ssh -t ssb.vm.0l.de sudo /root/sbot invite.create 1 | jq -r . | pbcopy'
alias new-mac=$'openssl rand -hex 6 | sed \'s/\(..\)/\1:/g; s/.$//\' | xargs sudo ifconfig en0 ether'

View file

@ -30,6 +30,14 @@ if type ykman > /dev/null 2>&1; then
_ykman_completionetup;
fi
if type kubectl > /dev/null 2>&1; then
source <(kubectl completion bash)
fi
if type doctl > /dev/null 2>&1; then
source <(doctl completion bash)
fi
# Homebrew completions
if command -v brew > /dev/null; then
HOMEBREW_PREFIX=$(brew --prefix)
@ -43,6 +51,16 @@ if command -v brew > /dev/null; then
fi
fi
if type brew > /dev/null 2>&1; then
HOMEBREW_PREFIX=$(brew --prefix)
for COMPLETION in "$HOMEBREW_PREFIX"/etc/bash_completion.d/*; do
[[ -f $COMPLETION ]] && source "$COMPLETION"
done
if [[ -f ${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh ]]; then
source "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh"
fi
fi
# Docker completions
for COMPLETION in /Applications/Docker.app/Contents/Resources/etc/*.bash-completion; do
[ -f ${COMPLETION} ] && source ${COMPLETION}
@ -51,3 +69,7 @@ done
# Add completion to aliases
# See: https://github.com/cykerway/complete-alias
source ~/.homesick/repos/complete-alias/bash_completion.sh
if type mc > /dev/null 2>&1; then
complete -C mc mc
fi

View file

@ -1,9 +1,27 @@
export GPG_TTY=$(tty)
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
fi
export GOPATH=~/build/go
export PATH=~/bin/scripts:~/bin:/usr/local/bin:${PATH}
source ${HOME}/.cargo/env
if [ -d /var/lib/snapd/snap/bin/code ]; then
export PATH="/var/lib/snapd/snap/bin/code:${PATH}"
fi
if [ -d ~/bin ]; then
export PATH=${PATH}:~/bin/scripts:~/bin
if [ -d ${KREW_ROOT:-$HOME/.krew}/bin ]; then
PATH="${KREW_ROOT:-${HOME}/.krew}/bin:${PATH}"
fi
if [ "$(id -u)" -eq "0" ]; then
if [ -d /opt/local/sbin ]; then
export PATH=/opt/local/sbin:${PATH}
fi
export PATH=/usr/local/sbin:${PATH}
fi
if [ -d ~/.npm-global/bin ]; then
@ -14,51 +32,51 @@ if [ -d ${GOPATH}/bin ]; then
export PATH=${GOPATH}/bin:${PATH}
fi
source ${HOME}/.cargo/env
if type brew > /dev/null 2>&1; then
eval $(brew shellenv)
export PATH="$(brew --prefix coreutils)/libexec/gnubin:${PATH}"
fi
# OS X stuff if availabe
if [[ "${OSTYPE}" == "darwin"* ]]; then
# MacGPG2
if [ -d /usr/local/MacGPG2/bin/ ]; then
export PATH=/usr/local/MacGPG2/bin/:${PATH}
fi
# Homebrew man-pages
if [ -d /usr/local/share/man ]; then
export MANPATH=/usr/local/share/man:${MANPATH}
export MANPATH=$(brew --prefix coreutils)/opt/coreutils/libexec/gnuman:${MANPATH}
fi
# Linux man-pages
if [ -d /opt/man-pages ]; then
export MANPATH=/opt/man-pages:${MANPATH}
fi
PATH=$(brew --prefix coreutils)/libexec/gnubin:/usr/local/bin:$PATH
# MacGPG2
if [ -d /usr/local/MacGPG2/bin/ ]; then
export PATH=/usr/local/MacGPG2/bin/:$PATH
fi
if [ -r ~/.gpg-agent-info ]; then
source ~/.gpg-agent-info
export GPG_AGENT_INFO
export SSH_AUTH_SOCK
export SSH_AGENT_PID
# Linux man-pages
if [ -d /opt/man-pages ]; then
export MANPATH=/opt/man-pages:${MANPATH}
fi
if [ -x /usr/local/bin/code-insiders ]; then
export EDITOR="/usr/local/bin/code-insiders -w"
if [ type code > /dev/null 2>&1 ]; then
export EDITOR="code -w"
else
export EDITOR=vim
fi
export RESTIC_REPOSITORY="sftp://172.23.157.2//srv/Data/Backup/Restic/Macbook"
#export RESTIC_REPOSITORY="sftp://172.23.157.2//srv/Data/Backup/Restic/Macbook"
export RESTIC_REPOSITORY="s3:http://172.23.157.2:9000/restic"
export AWS_ACCESS_KEY_ID=stv0g
export AWS_SECRET_ACCESS_KEY=m1n10Password
export GCC_COLORS="error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01"
export DEBEMAIL="post@steffenvogel.de"
export DEBFULLNAME="Steffen Vogel"
export DROPBOX=/Volumes/Extern/Sync/Dropbox
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export GRC_BLOCKS_PATH=/usr/local/share/gnuradio/grc/blocks/
export CALICO_DATASTORE_TYPE=kubernetes
export CALICO_KUBECONFIG=~/.kube/config
function join_by { local IFS="$1"; shift; echo "$*"; }
export KUBECONFIG=$(join_by : $(ls ~/.kube/config{.d/*,}))

View file

@ -29,7 +29,7 @@
[core]
# Exclude everything this file. Used for general exclusions.
excludesfile = /Users/stv0g/.gitignore
excludesfile = ~/.gitignore_global
# Set attributes on files. Used for general diff improvements.
attributesfile = ~/.gitattributes
autocrlf = input
@ -41,7 +41,6 @@
[difftool "sourcetree"]
cmd = code-insiders --diff --wait \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = code-insiders -n --wait \"$MERGED\"
trustExitCode = true
@ -73,6 +72,7 @@
smtpUser = stv0g
smtpServerPort = 587
[filter "lfs"]
clean = git-lfs clean %f
smudge = git-lfs smudge %f
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
required = true
process = git-lfs filter-process

View file

@ -1,4 +1,3 @@
pinentry-program /home/stv0g/.homesick/repos/dotfiles/pinentry.sh
write-env-file
enable-ssh-support
default-cache-ttl 30

View file

@ -5,3 +5,4 @@ file:///home/stv0g/Musik
file:///home/stv0g/Bilder
file:///home/stv0g/Videos
file:///home/stv0g/Downloads
file:///home/stv0g/Sync/sciebo.de

3
home/.kube/config Normal file
View file

@ -0,0 +1,3 @@
apiVersion: v1
kind: Config
current-context: eonerc

View file

@ -0,0 +1,34 @@
apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: true
server: https://api.k8s.fein-aachen.org/
name: eonerc-cluster
- cluster:
insecure-skip-tls-verify: true
server: https://137.226.248.165:6443/
name: eonerc-cluster-intern
contexts:
- context:
cluster: eonerc-cluster-intern
namespace: villas-demo
user: keycloak
name: eonerc
kind: Config
preferences: {}
users:
- name: keycloak
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
args:
- get-token
- --oidc-issuer-url=https://sso.fein-aachen.org/auth/realms/master
- --oidc-client-id=kubernetes
- --oidc-client-secret=69ba0d6f-1563-4988-b6c3-e9af64f7f6f2
command: kubectl-oidc_login
env: null
- name: svg
user:
client-certificate: ~/workspace/rwth/acs/k8s/svg.crt
client-key: ~/workspace/rwth/acs/k8s/svg.key

View file

@ -1,117 +1,63 @@
Host *
# ServerAliveInterval 60
# ServerAliveCountMax 0
# ControlMaster auto
# ControlPath ~/.ssh/master-%r@%h:%p
CanonicalizeHostname yes
CanonicalDomains 0l.de rwth-aachen.de eonerc.rwth-aachen.de acs-lab.eonerc.rwth-aachen.de
Host bad
ForwardAgent yes
RemoteForward 52698 127.0.0.1:52698
HostName 10.211.55.6
# PKCS11Provider /usr/lib/ssh-keychain.dylib
# Uni
Host *.itc.rwth-aachen.de *.rz.rwth-aachen.de
Host *.rwth-aachen.de
ForwardAgent yes
User sv111090
# Home
Host 192.168.0.*
ForwardAgent yes
# ACS
Host acs-zerberus
User vogel
HostName zerberus.eonerc.rwth-aachen.de
# Autocompletion
Host zerberus.acs-lab.eonerc.rwth-aachen.de
Host zebra.acs-lab.eonerc.rwth-aachen.de
Host reserver.acs-lab.eonerc.rwth-aachen.de
Host stargate.acs-lab.eonerc.rwth-aachen.de
Host ernie.acs-lab.eonerc.rwth-aachen.de
Host buildbot.acs-lab.eonerc.rwth-aachen.de
Host acs-stargate
HostName stargate.eonerc.rwth-aachen.de
ForwardAgent yes
Host *.acs-lab.eonerc.rwth-aachen.de
User vogel
Host opal-*.acs-lab.eonerc.rwth-aachen.de
User root
Host fedora-svg-2.acs-lab.eonerc.rwth-aachen.de
User svg
Host acs-vm-ubuntu-xilinx
HostName 137.226.133.215
User stv0g
ForwardAgent yes
# ProxyJump acs-stargate
Host acs-*
ForwardAgent yes
# ProxyJump acs-stargate
Host *.os-cloud.eonerc.rwth-aachen.de
ForwardAgent yes
# ProxyJump acs-stargate
# Load Balancer
Host lb-*.os-cloud.eonerc.rwth-aachen.de
User ubuntu
# Kubernetes
Host acs-k8s-master
User ubuntu
HostName 137.226.248.165
Host acs-k8s-node*
ProxyJump acs-k8s-master
Host acs-k8s-node1
User ubuntu
HostName kubernetes-1
Host acs-k8s-node2
User ubuntu
HostName kubernetes-2
Host acs-k8s-node3
User ubuntu
HostName kubernetes-3
Host acs-k8s-node4
User ubuntu
HostName kubernetes-4
Host acs-k8s-master-old
HostName 137.226.248.72
Host kubernetes-*.os-cloud.eonerc.rwth-aachen.de
User ubuntu
Host acs-k8s-traefik
User ubuntu
HostName 137.226.248.149
Host kubernetes-worker-*.os-cloud.eonerc.rwth-aachen.de
ProxyJump kubernetes-master.os-cloud.eonerc.rwth-aachen.de
Host acs-reserver
User svg
HostName 137.226.133.195
Host acs-villas-old
HostName 134.130.169.10
Host acs-villas
User svg
HostName acs-villas.eonerc.rwth-aachen.de
Host acs-mac-buildbot
Host mac-buildbot
User acs-admin
HostName 137.226.133.207
Host acs-buildbot
User svg
HostName 137.226.133.208
Host acs-hyper1
Host hyper*.acs-lab.eonerc.rwth-aachen.de
User root
HostName 137.226.133.191
Host acs-hyper2
User root
HostName 137.226.133.192
Host villas-demo.os-cloud.eonerc.rwth-aachen.de
Host acs-hyper3
User root
HostName 137.226.133.193
Host acs-os-villas
User svg
HostName 137.226.248.91
Host acs-os-fein-website
User fedora
HostName 137.226.248.111
Host keycloak.os-cloud.eonerc.rwth-aachen.de
User ubuntu
Host acs-fedora-svg-2
User svg
@ -123,23 +69,14 @@ Host inl-villas
ProxyJump acs-villas
Host *.fein-aachen.org
User svg
ForwardAgent yes
Host os.fein-aachen.org
User ubuntu
ForwardAgent yes
ProxyJump acs-villas
Host villas-test
HostName 142.93.233.220
User root
ForwardAgent yes
Host tud-villas
HostName 10.10.12.20
# HostName 10.10.12.21
User iepg
ForwardAgent yes
ProxyJump villas-hub
Host dtu-villas
User thangu
@ -166,28 +103,22 @@ Host villas-hub
# Private
#
Host *.0l.dn42
ForwardAgent yes
Host *.0l.de
User stv0g
ForwardAgent yes
RemoteForward 52698 127.0.0.1:52698
GSSAPIAuthentication yes
GSSAPIDelegateCredentials yes
Host vog
User pi
ForwardAgent yes
HostName 172.23.156.9
Host kub*.0l.de
User root
Host rck
Host rck.home.0l.de
User rock64
ForwardAgent yes
HostName 172.23.157.3
Host lian
User stv0g
HostName 172.23.156.2
Host vog.int.0l.de
User pi
Host nag.0l.de
User stv0g
ForwardAgent yes
HostName nag.0l.de
Host hex.0l.de
User root
VerifyHostKeyDNS yes

20
home/bin/oath Executable file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env expect -f
set query [lindex $argv 0]
spawn ykman oath code $query
expect "Enter your password:"
stty -echo
expect_user -re "(.*)\n"
stty echo
set pin $expect_out(1,string)
send "$pin\r\r"
expect "Touch your YubiKey..."
expect -re {(\d{6})}
set code $expect_out(1,string)
system printf $code | pbcopy

File diff suppressed because it is too large Load diff

View file

@ -1,15 +1,39 @@
#!/bin/bash
# The iTerm2 customizations fall under the following license:
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# -- BEGIN ITERM2 CUSTOMIZATIONS --
if [[ "$TERM" != screen && "$ITERM_SHELL_INTEGRATION_INSTALLED" = "" && "$-" == *i* ]]; then
if [[ "$ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX""$TERM" != screen && "$ITERM_SHELL_INTEGRATION_INSTALLED" = "" && "$-" == *i* && "$TERM" != linux && "$TERM" != dumb ]]; then
if shopt extdebug | grep on > /dev/null; then
echo "iTerm2 Shell Integration not installed."
echo ""
echo "Your shell has 'extdebug' turned on."
echo "This is incompatible with shell integration."
echo "Find 'shopt -s extdebug' in bash's rc scripts and remove it."
return 0
fi
ITERM_SHELL_INTEGRATION_INSTALLED=Yes
# Saved copy of your PS1. This is used to detect if the user changes PS1
# directly. ITERM_PREV_PS1 will hold the last value that this script set PS1 to
# (including various custom escape sequences).
ITERM_PREV_PS1="$PS1"
# -- END ITERM2 CUSTOMIZATIONS --
# The following chunk of code, bash-preexec.sh, is licensed like this:
# The MIT License
#
@ -33,6 +57,9 @@ ITERM_PREV_PS1="$PS1"
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Wrap bash-preexec.sh in a function so that, if it exits early due to having
# been sourced elsewhere, it doesn't exit our entire script.
_install_bash_preexec () {
# -- BEGIN BASH-PREEXEC.SH --
#!/bin/bash
#
@ -47,7 +74,22 @@ ITERM_PREV_PS1="$PS1"
# Author: Ryan Caloras (ryan@bashhub.com)
# Forked from Original Author: Glyph Lefkowitz
#
# V0.3.3
# V0.3.7
#
# -- END ITERM2 CUSTOMIZATIONS --
# bash-preexec.sh -- Bash support for ZSH-like 'preexec' and 'precmd' functions.
# https://github.com/rcaloras/bash-preexec
#
#
# 'preexec' functions are executed before each interactive command is
# executed, with the interactive command as its argument. The 'precmd'
# function is executed before each prompt is displayed.
#
# Author: Ryan Caloras (ryan@bashhub.com)
# Forked from Original Author: Glyph Lefkowitz
#
# V0.3.7
#
# General Usage:
@ -62,28 +104,43 @@ ITERM_PREV_PS1="$PS1"
#
# preexec_functions+=(my_preexec_function)
#
# 3. If you have anything that's using the Debug Trap, change it to use
# preexec. (Optional) change anything using PROMPT_COMMAND to now use
# precmd instead.
# 3. Consider changing anything using the DEBUG trap or PROMPT_COMMAND
# to use preexec and precmd instead. Preexisting usages will be
# preserved, but doing so manually may be less surprising.
#
# Note: This module requires two bash features which you must not otherwise be
# using: the "DEBUG" trap, and the "PROMPT_COMMAND" variable. prexec_and_precmd_install
# will override these and if you override one or the other this will most likely break.
# Note: This module requires two Bash features which you must not otherwise be
# using: the "DEBUG" trap, and the "PROMPT_COMMAND" variable. If you override
# either of these after bash-preexec has been installed it will most likely break.
# Avoid duplicate inclusion
if [[ "$__bp_imported" == "defined" ]]; then
if [[ "${__bp_imported:-}" == "defined" ]]; then
return 0
fi
__bp_imported="defined"
# Should be available to each precmd and preexec
# functions, should they want it.
# functions, should they want it. $? and $_ are available as $? and $_, but
# $PIPESTATUS is available only in a copy, $BP_PIPESTATUS.
# TODO: Figure out how to restore PIPESTATUS before each precmd or preexec
# function.
__bp_last_ret_value="$?"
BP_PIPESTATUS=("${PIPESTATUS[@]}")
__bp_last_argument_prev_command="$_"
# Command to set our preexec trap. It's invoked once via
# PROMPT_COMMAND and then removed.
__bp_trap_install_string="trap '__bp_preexec_invoke_exec \"\$_\"' DEBUG;"
__bp_inside_precmd=0
__bp_inside_preexec=0
# Fails if any of the given variables are readonly
# Reference https://stackoverflow.com/a/4441178
__bp_require_not_readonly() {
local var
for var; do
if ! ( unset "$var" 2> /dev/null ); then
echo "iTerm2 Shell Integration:bash-preexec requires write access to ${var}" >&2
return 1
fi
done
}
# Remove ignorespace and or replace ignoreboth from HISTCONTROL
# so we can accurately invoke preexec with a command from our
@ -123,11 +180,19 @@ __bp_interactive_mode() {
# This function is installed as part of the PROMPT_COMMAND.
# It will invoke any functions defined in the precmd_functions array.
__bp_precmd_invoke_cmd() {
# Save the returned value from our last command, and from each process in
# its pipeline. Note: this MUST be the first thing done in this function.
__bp_last_ret_value="$?" BP_PIPESTATUS=("${PIPESTATUS[@]}")
# Save the returned value from our last command
__bp_last_ret_value="$?"
# Don't invoke precmds if we are inside an execution of an "original
# prompt command" by another precmd execution loop. This avoids infinite
# recursion.
if (( __bp_inside_precmd > 0 )); then
return
fi
local __bp_inside_precmd=1
# For every function defined in our function array. Invoke it.
# Invoke every function defined in our function array.
local precmd_function
for precmd_function in "${precmd_functions[@]}"; do
@ -135,7 +200,8 @@ __bp_precmd_invoke_cmd() {
# Test existence of functions with: declare -[Ff]
if type -t "$precmd_function" 1>/dev/null; then
__bp_set_ret_value "$__bp_last_ret_value" "$__bp_last_argument_prev_command"
$precmd_function
# Quote our function invocation to prevent issues with IFS
"$precmd_function"
fi
done
}
@ -144,7 +210,7 @@ __bp_precmd_invoke_cmd() {
# precmd functions. This is available for instance in zsh. We can simulate it in bash
# by setting the value here.
__bp_set_ret_value() {
return $1
return ${1:-}
}
__bp_in_prompt_command() {
@ -153,10 +219,10 @@ __bp_in_prompt_command() {
IFS=';' read -ra prompt_command_array <<< "$PROMPT_COMMAND"
local trimmed_arg
trimmed_arg=$(__bp_trim_whitespace "$1")
trimmed_arg=$(__bp_trim_whitespace "${1:-}")
local command
for command in "${prompt_command_array[@]}"; do
for command in "${prompt_command_array[@]:-}"; do
local trimmed_command
trimmed_command=$(__bp_trim_whitespace "$command")
# Only execute each function if it actually exists.
@ -173,25 +239,28 @@ __bp_in_prompt_command() {
# environment to attempt to detect if the current command is being invoked
# interactively, and invoke 'preexec' if so.
__bp_preexec_invoke_exec() {
# Save the contents of $_ so that it can be restored later on.
# https://stackoverflow.com/questions/40944532/bash-preserve-in-a-debug-trap#40944702
__bp_last_argument_prev_command="$1"
__bp_last_argument_prev_command="${1:-}"
# Don't invoke preexecs if we are inside of another preexec.
if (( __bp_inside_preexec > 0 )); then
return
fi
local __bp_inside_preexec=1
# Checks if the file descriptor is not standard out (i.e. '1')
# __bp_delay_install checks if we're in test. Needed for bats to run.
# Prevents preexec from being invoked for functions in PS1
if [[ ! -t 1 && -z "$__bp_delay_install" ]]; then
if [[ ! -t 1 && -z "${__bp_delay_install:-}" ]]; then
return
fi
if [[ -n "$COMP_LINE" ]]; then
if [[ -n "${COMP_LINE:-}" ]]; then
# We're in the middle of a completer. This obviously can't be
# an interactively issued command.
return
fi
if [[ -z "$__bp_preexec_interactive_mode" ]]; then
if [[ -z "${__bp_preexec_interactive_mode:-}" ]]; then
# We're doing something related to displaying the prompt. Let the
# prompt set the title instead of me.
return
@ -201,12 +270,12 @@ __bp_preexec_invoke_exec() {
# In other words, if you have a subshell like
# (sleep 1; sleep 2)
# You want to see the 'sleep 2' as a set_command_title as well.
if [[ 0 -eq "$BASH_SUBSHELL" ]]; then
if [[ 0 -eq "${BASH_SUBSHELL:-}" ]]; then
__bp_preexec_interactive_mode=""
fi
fi
if __bp_in_prompt_command "$BASH_COMMAND"; then
if __bp_in_prompt_command "${BASH_COMMAND:-}"; then
# If we're executing something inside our prompt_command then we don't
# want to call preexec. Bash prior to 3.1 can't detect this at all :/
__bp_preexec_interactive_mode=""
@ -214,7 +283,10 @@ __bp_preexec_invoke_exec() {
fi
local this_command
this_command=$(HISTTIMEFORMAT= builtin history 1 | { read -r _ this_command; echo "$this_command"; })
this_command=$(
export LC_ALL=C
HISTTIMEFORMAT= builtin history 1 | sed '1 s/^ *[0-9][0-9]*[* ] //'
)
# Sanity check to make sure we have something to invoke our function with.
if [[ -z "$this_command" ]]; then
@ -225,61 +297,50 @@ __bp_preexec_invoke_exec() {
# the command is in fact interactive and we should invoke the user's
# preexec functions.
# For every function defined in our function array. Invoke it.
# Invoke every function defined in our function array.
local preexec_function
local preexec_function_ret_value
local preexec_ret_value=0
for preexec_function in "${preexec_functions[@]}"; do
for preexec_function in "${preexec_functions[@]:-}"; do
# Only execute each function if it actually exists.
# Test existence of function with: declare -[fF]
if type -t "$preexec_function" 1>/dev/null; then
__bp_set_ret_value $__bp_last_ret_value
$preexec_function "$this_command"
preexec_ret_value="$?"
__bp_set_ret_value ${__bp_last_ret_value:-}
# Quote our function invocation to prevent issues with IFS
"$preexec_function" "$this_command"
preexec_function_ret_value="$?"
if [[ "$preexec_function_ret_value" != 0 ]]; then
preexec_ret_value="$preexec_function_ret_value"
fi
fi
done
# Restore the last argument of the last executed command
# Also preserves the return value of the last function executed in preexec
# If `extdebug` is enabled a non-zero return value from the last function
# in prexec causes the command not to execute
# Restore the last argument of the last executed command, and set the return
# value of the DEBUG trap to be the return code of the last preexec function
# to return an error.
# If `extdebug` is enabled a non-zero return value from any preexec function
# will cause the user's command not to execute.
# Run `shopt -s extdebug` to enable
__bp_set_ret_value "$preexec_ret_value" "$__bp_last_argument_prev_command"
}
# Returns PROMPT_COMMAND with a semicolon appended
# if it doesn't already have one.
__bp_prompt_command_with_semi_colon() {
# Trim our existing PROMPT_COMMAND
local trimmed
trimmed=$(__bp_trim_whitespace "$PROMPT_COMMAND")
# Take our existing prompt command and append a semicolon to it
# if it doesn't already have one.
local existing_prompt_command
if [[ -n "$trimmed" ]]; then
existing_prompt_command=${trimmed%${trimmed##*[![:space:]]}}
existing_prompt_command=${existing_prompt_command%;}
existing_prompt_command=${existing_prompt_command/%/;}
else
existing_prompt_command=""
__bp_install() {
# Exit if we already have this installed.
if [[ "${PROMPT_COMMAND:-}" == *"__bp_precmd_invoke_cmd"* ]]; then
return 1;
fi
echo -n "$existing_prompt_command"
}
trap '__bp_preexec_invoke_exec "$_"' DEBUG
__bp_install() {
# Remove setting our trap from PROMPT_COMMAND
PROMPT_COMMAND="${PROMPT_COMMAND//$__bp_trap_install_string}"
# Remove this function from our PROMPT_COMMAND
PROMPT_COMMAND="${PROMPT_COMMAND//__bp_install;}"
# Exit if we already have this installed.
if [[ "$PROMPT_COMMAND" == *"__bp_precmd_invoke_cmd"* ]]; then
return 1;
# Preserve any prior DEBUG trap as a preexec function
local prior_trap=$(sed "s/[^']*'\(.*\)'[^']*/\1/" <<<"${__bp_trap_string:-}")
unset __bp_trap_string
if [[ -n "$prior_trap" ]]; then
eval '__bp_original_debug_trap() {
'"$prior_trap"'
}'
preexec_functions+=(__bp_original_debug_trap)
fi
# Adjust our HISTCONTROL Variable if needed.
@ -290,59 +351,67 @@ __bp_install() {
# backgrounded subshell commands (e.g. (pwd)& ). Believe this is a bug in Bash.
#
# Disabling this by default. It can be enabled by setting this variable.
if [[ -n "$__bp_enable_subshells" ]]; then
if [[ -n "${__bp_enable_subshells:-}" ]]; then
# Set so debug trap will work be invoked in subshells.
set -o functrace > /dev/null 2>&1
shopt -s extdebug > /dev/null 2>&1
fi;
local existing_prompt_command
existing_prompt_command=$(__bp_prompt_command_with_semi_colon)
# Install our hooks in PROMPT_COMMAND to allow our trap to know when we've
# actually entered something.
PROMPT_COMMAND="__bp_precmd_invoke_cmd; ${existing_prompt_command} __bp_interactive_mode"
eval "$__bp_trap_install_string"
PROMPT_COMMAND="__bp_precmd_invoke_cmd; __bp_interactive_mode"
# Add two functions to our arrays for convenience
# of definition.
precmd_functions+=(precmd)
preexec_functions+=(preexec)
# Since this is in PROMPT_COMMAND, invoke any precmd functions we have defined.
__bp_precmd_invoke_cmd
# Put us in interactive mode for our first command.
__bp_interactive_mode
# Since this function is invoked via PROMPT_COMMAND, re-execute PC now that it's properly set
eval "$PROMPT_COMMAND"
}
# Sets our trap and __bp_install as part of our PROMPT_COMMAND to install
# after our session has started. This allows bash-preexec to be inlucded
# after our session has started. This allows bash-preexec to be included
# at any point in our bash profile. Ideally we could set our trap inside
# __bp_install, but if a trap already exists it'll only set locally to
# the function.
__bp_install_after_session_init() {
# Make sure this is bash that's running this and return otherwise.
if [[ -z "$BASH_VERSION" ]]; then
if [[ -z "${BASH_VERSION:-}" ]]; then
return 1;
fi
local existing_prompt_command
existing_prompt_command=$(__bp_prompt_command_with_semi_colon)
# bash-preexec needs to modify these variables in order to work correctly
# if it can't, just stop the installation
__bp_require_not_readonly PROMPT_COMMAND HISTCONTROL HISTTIMEFORMAT || return
# Add our installation to be done last via our PROMPT_COMMAND. These are
# removed by __bp_install when it's invoked so it only runs once.
PROMPT_COMMAND="${existing_prompt_command} $__bp_trap_install_string __bp_install;"
# If there's an existing PROMPT_COMMAND capture it and convert it into a function
# So it is preserved and invoked during precmd.
if [[ -n "$PROMPT_COMMAND" ]]; then
eval '__bp_original_prompt_command() {
'"$PROMPT_COMMAND"'
}'
precmd_functions+=(__bp_original_prompt_command)
fi
# Installation is finalized in PROMPT_COMMAND, which allows us to override the DEBUG
# trap. __bp_install sets PROMPT_COMMAND to its final value, so these are only
# invoked once.
# It's necessary to clear any existing DEBUG trap in order to set it from the install function.
# Using \n as it's the most universal delimiter of bash commands
PROMPT_COMMAND=$'\n__bp_trap_string="$(trap -p DEBUG)"\ntrap DEBUG\n__bp_install\n'
}
# Run our install so long as we're not delaying it.
if [[ -z "$__bp_delay_install" ]]; then
__bp_install_after_session_init
fi;
# -- BEGIN BASH-PREEXEC.SH --
# -- END BASH-PREEXEC.SH --
}
_install_bash_preexec
unset -f _install_bash_preexec
# -- BEGIN ITERM2 CUSTOMIZATIONS --
@ -410,7 +479,7 @@ function iterm2_prompt_suffix() {
function iterm2_print_version_number() {
iterm2_begin_osc
printf "1337;ShellIntegrationVersion=9;shell=bash"
printf "1337;ShellIntegrationVersion=14;shell=bash"
iterm2_end_osc
}
@ -490,6 +559,15 @@ function __iterm2_precmd () {
export ITERM_ORIG_PS1="$PS1"
fi
# If you want to generate PS1 dynamically from PROMPT_COMMAND, the best way
# to do it is to define a function named iterm2_generate_ps1 that sets PS1.
# Issue 5964. Other shells don't have this issue because they don't need
# such extremes to get precmd and preexec.
if [ -n "$(type -t iterm2_generate_ps1)" ] && [ "$(type -t iterm2_generate_ps1)" = function ]; then
iterm2_generate_ps1
fi
if [[ "$PS1" != "$ITERM_PREV_PS1" ]]
then
export ITERM_ORIG_PS1="$PS1"
@ -499,7 +577,7 @@ function __iterm2_precmd () {
\local iterm2_prompt_prefix_value="$(iterm2_prompt_prefix)"
# Add the mark unless the prompt includes '$(iterm2_prompt_mark)' as a substring.
if [[ $ITERM_ORIG_PS1 != *'$(iterm2_prompt_mark)'* ]]
if [[ $ITERM_ORIG_PS1 != *'$(iterm2_prompt_mark)'* && x$ITERM2_SQUELCH_MARK = x ]]
then
iterm2_prompt_prefix_value="$iterm2_prompt_prefix_value$(iterm2_prompt_mark)"
fi
@ -522,6 +600,8 @@ function __iterm2_precmd () {
preexec_functions+=(__iterm2_preexec)
precmd_functions+=(__iterm2_precmd)
iterm2_print_state_data
iterm2_print_version_number
fi
# -- END ITERM2 CUSTOMIZATIONS --

1
qmk-keymap.json Normal file
View file

@ -0,0 +1 @@
{"keyboard":"dztech/dz60rgb","keymap":"stv0g","layout":"LAYOUT_ANSI","layers":[["KC_GESC","KC_1","KC_2","KC_3","KC_4","KC_5","KC_6","KC_7","KC_8","KC_9","KC_0","KC_MINS","KC_EQL","KC_BSPC","KC_TAB","KC_Q","KC_W","KC_E","KC_R","KC_T","KC_Y","KC_U","KC_I","KC_O","KC_P","KC_LBRC","KC_RBRC","KC_BSLS","KC_CAPS","KC_A","KC_S","KC_D","KC_F","KC_G","KC_H","KC_J","KC_K","KC_L","KC_SCLN","KC_QUOT","KC_ENT","KC_LSFT","KC_Z","KC_X","KC_C","KC_V","KC_B","KC_N","KC_M","KC_COMM","KC_DOT","KC_SLSH","KC_RSFT","KC_LCTL","KC_LGUI","KC_LALT","KC_SPC","KC_RALT","LT(2,KC_RGUI)","LT(1,KC_APP)","KC_RCTL"],["KC_FIND","KC_F1","KC_F2","KC_F3","KC_F4","KC_F5","KC_F6","KC_F7","KC_F8","KC_F9","KC_F10","KC_F11","KC_F12","KC_DEL","KC_LGUI","KC_NO","KC_UP","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","RGB_SPI","RGB_VAI","RGB_SAD","RGB_HUI","RGB_MOD","KC_NO","KC_WBAK","KC_LEFT","KC_DOWN","KC_RGHT","KC_NO","KC_NO","KC_NO","KC_NO","RGB_SPD","RGB_VAD","RGB_SAD","RGB_HUD","KC_PGUP","KC_WFWD","KC_F13","KC_F14","KC_F15","KC_F16","KC_F17","KC_F18","KC_F19","KC_F20","KC_F21","KC_F22","KC_PGDN","KC_MUTE","KC_VOLD","KC__VOLUP","KC_MPLY","KC_MPRV","KC_MNXT","KC_NO","KC_PWR"],["RESET","RGB_M_P","RGB_M_B","RGB_M_R","RGB_M_SW","RGB_M_SN","RGB_M_K","RGB_M_X","RGB_M_G","KC_NO","KC_NO","KC_NO","KC_NO","LALT(KC_BSPC)","KC_NO","KC_NO","LALT(KC_UP)","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","LALT(KC_LEFT)","LALT(KC_DOWN)","LALT(KC_RGHT)","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO","KC_NO"]],"author":"","notes":""}