1
0
Fork 0

massive overhaul to switch to zsh

main
Mari 3 years ago
parent 2a65cc96b3
commit f793e7aaa0
  1. 1
      .gitignore
  2. 7
      .gitmodules
  3. 103
      bash/bash_aliases.sh
  4. 22
      bash/bash_tmux.sh
  5. 0
      bash/git-aware-prompt
  6. 140
      bash_aliases.sh
  7. 4
      per-host/Adversary/.bash_aliases
  8. 1
      per-host/Adversary/.bash_aliases-common
  9. 1
      per-host/Adversary/.inputrc-common
  10. 1
      per-host/Adversary/.ssh/.rc-common
  11. 1
      per-host/Adversary/.ssh/authorized_keys
  12. 1
      per-host/Adversary/.ssh/config
  13. 1
      per-host/Adversary/.ssh/known_hosts
  14. 2
      per-host/Adversary/.ssh/rc
  15. 1
      per-host/Adversary/.tmux.conf
  16. 1
      per-host/Adversary/.tmux.conf-common
  17. 1
      per-host/Adversary/.vimrc
  18. 1
      per-host/Adversary/.vimrc-common
  19. 4
      per-host/EarthDaughter/.bash_aliases
  20. 1
      per-host/EarthDaughter/.bash_aliases-common
  21. 1
      per-host/EarthDaughter/.inputrc-common
  22. 1
      per-host/EarthDaughter/.ssh/.rc-common
  23. 1
      per-host/EarthDaughter/.ssh/authorized_keys
  24. 1
      per-host/EarthDaughter/.ssh/config
  25. 1
      per-host/EarthDaughter/.ssh/known_hosts
  26. 2
      per-host/EarthDaughter/.ssh/rc
  27. 1
      per-host/EarthDaughter/.tmux.conf
  28. 1
      per-host/EarthDaughter/.tmux.conf-common
  29. 1
      per-host/EarthDaughter/.vimrc
  30. 1
      per-host/EarthDaughter/.vimrc-common
  31. 4
      per-host/MoonMother/.bash_aliases
  32. 1
      per-host/MoonMother/.bash_aliases-common
  33. 1
      per-host/MoonMother/.config/nvim
  34. 1
      per-host/MoonMother/.inputrc
  35. 1
      per-host/MoonMother/.inputrc-common
  36. 1
      per-host/MoonMother/.ssh/.rc-common
  37. 1
      per-host/MoonMother/.ssh/authorized_keys
  38. 1
      per-host/MoonMother/.ssh/config
  39. 1
      per-host/MoonMother/.ssh/known_hosts
  40. 2
      per-host/MoonMother/.ssh/rc
  41. 1
      per-host/MoonMother/.tmux.conf
  42. 1
      per-host/MoonMother/.tmux.conf-common
  43. 1
      per-host/MoonMother/.vim
  44. 1
      per-host/MoonMother/.vimrc
  45. 1
      per-host/MoonMother/.vimrc-common
  46. 11
      per-host/blocky-cafe/.bash_aliases
  47. 1
      per-host/blocky-cafe/.bash_aliases-common
  48. 1
      per-host/blocky-cafe/.config/nvim
  49. 1
      per-host/blocky-cafe/.inputrc
  50. 1
      per-host/blocky-cafe/.inputrc-common
  51. 1
      per-host/blocky-cafe/.ssh/.rc-common
  52. 1
      per-host/blocky-cafe/.ssh/authorized_keys
  53. 1
      per-host/blocky-cafe/.ssh/config
  54. 1
      per-host/blocky-cafe/.ssh/known_hosts
  55. 2
      per-host/blocky-cafe/.ssh/rc
  56. 2
      per-host/blocky-cafe/.tmux.conf
  57. 1
      per-host/blocky-cafe/.tmux.conf-common
  58. 1
      per-host/blocky-cafe/.vim
  59. 1
      per-host/blocky-cafe/.vimrc
  60. 1
      per-host/blocky-cafe/.vimrc-common
  61. 4
      per-host/costadelsol/.bash_aliases
  62. 1
      per-host/costadelsol/.bash_aliases-common
  63. 2
      per-host/costadelsol/.inputrc-common
  64. 1
      per-host/costadelsol/.ssh/.rc-common
  65. 1
      per-host/costadelsol/.ssh/authorized_keys
  66. 2
      per-host/costadelsol/.ssh/config
  67. 0
      per-host/costadelsol/.ssh/config-common
  68. 1
      per-host/costadelsol/.ssh/known_hosts
  69. 4
      per-host/costadelsol/.ssh/rc
  70. 2
      per-host/costadelsol/.tmux.conf
  71. 1
      per-host/costadelsol/.tmux.conf-common
  72. 2
      per-host/costadelsol/.vimrc
  73. 1
      per-host/costadelsol/.vimrc-common
  74. 1
      per-host/costadelsol/.zshrc
  75. 2
      per-host/crystarium/.bash_aliases
  76. 0
      per-host/crystarium/.config/nvim
  77. 0
      per-host/crystarium/.inputrc
  78. 1
      per-host/crystarium/.inputrc-common
  79. 1
      per-host/crystarium/.ssh/config
  80. 0
      per-host/crystarium/.ssh/config-common
  81. 2
      per-host/crystarium/.ssh/rc
  82. 1
      per-host/crystarium/.tmux.conf
  83. 0
      per-host/crystarium/.vim
  84. 1
      per-host/crystarium/.vimrc
  85. 1
      per-host/crystarium/.zshrc
  86. 2
      per-host/goldsaucer/.bash_aliases
  87. 0
      per-host/goldsaucer/.config/nvim
  88. 0
      per-host/goldsaucer/.inputrc
  89. 1
      per-host/goldsaucer/.inputrc-common
  90. 1
      per-host/goldsaucer/.ssh/config
  91. 0
      per-host/goldsaucer/.ssh/config-common
  92. 2
      per-host/goldsaucer/.ssh/rc
  93. 1
      per-host/goldsaucer/.tmux.conf
  94. 0
      per-host/goldsaucer/.vim
  95. 1
      per-host/goldsaucer/.vimrc
  96. 1
      per-host/goldsaucer/.zshrc
  97. 4
      per-host/gubal/.bash_aliases
  98. 1
      per-host/gubal/.bash_aliases-common
  99. 2
      per-host/gubal/.inputrc-common
  100. 1
      per-host/gubal/.ssh/.rc-common
  101. Some files were not shown because too many files have changed in this diff Show More

1
.gitignore vendored

@ -1,2 +1,3 @@
*.swp *.swp
/vim/.netrwhist /vim/.netrwhist
.last-fetch

7
.gitmodules vendored

@ -4,14 +4,11 @@
[submodule "vim/bundle/vim-gfm-syntax"] [submodule "vim/bundle/vim-gfm-syntax"]
path = vim/bundle/vim-gfm-syntax path = vim/bundle/vim-gfm-syntax
url = https://github.com/rhysd/vim-gfm-syntax.git url = https://github.com/rhysd/vim-gfm-syntax.git
[submodule "ssh-find-agent"]
path = ssh-find-agent
url = https://github.com/wwalker/ssh-find-agent.git
[submodule "vim/bundle/ultisnips"] [submodule "vim/bundle/ultisnips"]
path = vim/bundle/ultisnips path = vim/bundle/ultisnips
url = https://github.com/SirVer/ultisnips.git url = https://github.com/SirVer/ultisnips.git
[submodule "git-aware-prompt"] [submodule "git-aware-prompt"]
path = git-aware-prompt path = bash/git-aware-prompt
url = https://github.com/jimeh/git-aware-prompt.git url = https://github.com/jimeh/git-aware-prompt.git
[submodule "vim/ale"] [submodule "vim/ale"]
path = vim/bundle/ale path = vim/bundle/ale
@ -38,7 +35,7 @@
path = vim/bundle/nerdtree-git-plugin path = vim/bundle/nerdtree-git-plugin
url = https://github.com/Xuyuanp/nerdtree-git-plugin.git url = https://github.com/Xuyuanp/nerdtree-git-plugin.git
[submodule "ohmyzsh"] [submodule "ohmyzsh"]
path = ohmyzsh path = zsh/ohmyzsh
url = https://github.com/ohmyzsh/ohmyzsh url = https://github.com/ohmyzsh/ohmyzsh
[submodule "vim/bundle/coc.nvim"] [submodule "vim/bundle/coc.nvim"]
path = vim/bundle/coc.nvim path = vim/bundle/coc.nvim

@ -0,0 +1,103 @@
#!/bin/bash
# Find the path of the git repository relative to this file.
export __COMMON_CONFIGS=$(readlink -e "$( dirname "$(realpath -e "${BASH_SOURCE[0]}")" )/..")
# Install EDITOR
export EDITOR='nvim'
# Set up the vim config path
export VIM_CONFIG_DIR=$__COMMON_CONFIGS/vim
# Set potentially-destructive commands to use interactive modes
alias rm="rm -i"
alias cp="cp -i"
alias mv="mv -i"
# Use a larger number of KDF rounds and the secure ed25519 key type by default.
alias ssh-keygen="ssh-keygen -o -a 100 -b 4096 -t ed25519"
# Reload this file's (and other customizations') aliases.
function reload_bashrc()
{
. "$HOME"/.bashrc
}
# Check if the git repository is fully synced.
function __common_configs_in_sync()
{
(
# Failure modes, in order:
# exit 9: Problem cd'ing or getting commit hashes - things that should never fail
cd "$__COMMON_CONFIGS" || exit 9
localCommit=$(git show-ref --verify --hash refs/heads/master) || exit 9
if [[ $1 == --force-fetch ]] || [[ ! -f .last-fetch ]] || [[ $(date --reference=.last-fetch +%s) -lt $(date --date='5 minutes ago' +%s) ]]; then
git fetch --quiet origin && touch .last-fetch
fi
remoteCommit=$(git show-ref --verify --hash refs/remotes/origin/master) || exit 9
# exit 1: master is not the commit which is checked out.
[[ $(git symbolic-ref HEAD) == "refs/heads/master" ]] || exit 1
# exit 2: master and origin/master are different.
[[ $localCommit == $remoteCommit ]] || exit 2
# exit 3: There are staged changes.
git diff-index --cached --exit-code --quiet HEAD || exit 3
# exit 4: There are unstaged changes.
git diff-files --exit-code --quiet HEAD || exit 4
)
}
function help_prompt() {
echo '\ Help\ page\ '"$@"'\ ?ltline\ %lt?L/%L.:byte\ %bB?s/%s..?\ (END):?pB\ %pB\\%..(press h for help or q to quit)'
}
function man ()
{
if command man "$@" >&/dev/null; then
command man "$@"
elif builtin help -m "$@" >&/dev/null; then
builtin help -m "$@" | command man -l -r "$(help_prompt "$@")" -
else
command man "$@"
fi
}
function help ()
{
if builtin help -m "$@" >&/dev/null; then
builtin help -m "$@" | command man -l -r "$(help_prompt "$@")" -
elif command man "$@" >&/dev/null; then
command man "$@"
else
builtin help -m "$@"
fi
}
source "$__COMMON_CONFIGS"/bash/bash_tmux.sh
PROMPT_COMMAND=""
export GITAWAREPROMPT="$__COMMON_CONFIGS"/bash/git-aware-prompt
source "$GITAWAREPROMPT"/main.sh
function __prettylastexit() {
local exitcode=$?
if [[ -z $exitcode ]]; then
echo "[---]$txtrst "
elif [[ $exitcode == 0 ]]; then
echo "$txtgrn[ OK]$txtrst "
else
printf "$txtred[%3.3s]$txtrst " "$exitcode"
fi
}
function __prettyconfigstate() {
__common_configs_in_sync
local exitcode=$?
case $exitcode in
0) ;;
2) echo; echo "${txtgrn}<config update ready>${txtrst}"; ;;
3) echo; echo "${txtylw}<config change in progress>${txtrst}"; ;;
4) echo; echo "${txtylw}<config change in progress>${txtrst}"; ;;
*) echo; echo "${txtred}<config error>$txtrst" ;;
esac
}
PS1='$(__prettylastexit)\[$bldred\]${debian_chroot:+($debian_chroot)}\[$txtrst\]\[$txtpur\]\u\[$txtrst\]\[$txtylw\]@\[$txtrst\]\[$txtblu\]\h\[$txtrst\]:\[$bldgrn\]\w\[$txtrst\] \[$txtcyn\]$git_branch\[$txtrst\]\[$bldred\]${git_dirty}\[$txtrst\]$(__prettyconfigstate)\n\$ '

@ -1,18 +1,18 @@
#!/bin/bash #!/bin/bash
# vim: set filetype=sh: # vim: set filetype=sh:
# tmux configuration files are found alongside this file # tmux configuration files are found in /tmux
export TMUX_CONF_DIR=${TMUX_CONF_DIR:-"$( dirname "$(realpath -e "${BASH_SOURCE[0]}")" )"} export TMUX_CONF_DIR=${TMUX_CONF_DIR:-$__COMMON_CONFIGS/tmux}
# default status script just shows whether a reboot is needed # default status script just shows whether a reboot is needed
export TMUX_STATUS_SCRIPT=${TMUX_STATUS_SCRIPT:-"$TMUX_CONF_DIR/.tmux.need-reboot.sh"} export TMUX_STATUS_SCRIPT=${TMUX_STATUS_SCRIPT:-"$TMUX_CONF_DIR/tmux.need-reboot.sh"}
function tmux_has_main() { function tmux_running() {
tmux -2 has-session -t "Main Screen" tmux -2 has-session -t "Nexus"
} }
function tmux_init_main() { function tmux_init() {
tmux -2 new-session -d -s "Main Screen" -n "Misc." tmux -2 new-session -d -s "Nexus" -n "Misc."
tmux -2 new-window -d -t "Main Screen:0" -n "Monitor" "htop" tmux -2 new-window -d -t "Nexus:0" -n "Monitor" "htop"
} }
function go_tmux () function go_tmux ()
@ -22,11 +22,11 @@ function go_tmux ()
return 1; return 1;
fi fi
echo "Starting tmux..." echo "Starting tmux..."
tmux_has_main || tmux_init_main || return 1 tmux_running || tmux_init || return 1
if [[ $1 == "-x" ]]; then if [[ $1 == "-x" ]]; then
exec tmux -2 attach-session -t "Main Screen" || return 1 exec tmux -2 attach-session -t "Nexus" || return 1
else else
tmux -2 attach-session -t "Main Screen" || return 1 tmux -2 attach-session -t "Nexus" || return 1
fi fi
} }

@ -1,140 +0,0 @@
#!/bin/bash
# vim: set filetype=sh:
# link destination: $HOME/.bash_aliases
# Install EDITOR
export EDITOR='nvim'
alias rm="rm -i"
alias cp="cp -i"
alias mv="mv -i"
# Send a bell before the prompt if it has been a long time since the last
# prompt.
# function bell_on_long_running_commands() {
# local NOW=`date -u +%s`
# if [ $(( LASTCMD_FOR_BELLS )) -lt $(( NOW - 15 )) ]; then
# echo -n $'\a'
# fi
# unset LASTCMD_FOR_BELLS;
# }
# function set_last_command_time() {
# if [[ -z "${COMPLINE}" ]] && [[ -z "${LASTCMD_FOR_BELLS}" ]]; then
# LASTCMD_FOR_BELLS=`date -u +%s`
# fi
# }
# trap set_last_command_time DEBUG
# export PROMPT_COMMAND=bell_on_long_running_commands
function bell_after() {
"$@"
local exit="$?"
echo -n $'\a' 1>&2
return "$exit"
}
# Reload aliases
function reload_scripts_only()
{
. "$HOME"/.bashrc
}
# from https://stackoverflow.com/a/1203628
# Useful for overriding functions defined in these common scripts
# Usage: copy_func from to
function copy_func()
{
declare -F $1 > /dev/null || return 1
eval "$(echo "${2}()"; declare -f ${1} | tail -n +2)"
}
function sync_git_only()
{
(
cd "$( dirname "$(realpath -e "${BASH_SOURCE[0]}")" )"
if git add . && ! git diff-index --cached --quiet HEAD; then
git commit -am "Autocommitted updated scripts from $(hostname)"
fi
git pull --rebase
git submodule update --init --recursive
./install.sh
if ! git --no-pager diff --exit-code origin/master master; then
git --no-pager log --reverse origin/master..master
if ! read -p "OK to push these changes? (Y/N) " -N 1 confirm; then
confirm = "N"
fi
echo
if [[ "$confirm" != "Y" ]] && [[ "$confirm" != "y" ]]; then
echo "Not pushing yet."
else
git push
fi
fi
)
}
alias ssh-keygen="ssh-keygen -o -a 100 -t ed25519"
function ssh-authorize-key() {
if [[ ! -r "$1" ]] || ! file -b "$1" | grep -q "^OpenSSH .* public key$"; then
echo "Expected a public key file"
fi
cat "$1" >>~/.ssh/authorized_keys
}
function bashreload()
{
reload_scripts_only
sync_git_only
reload_scripts_only
}
function help_prompt() {
echo '\ Help\ page\ '"$@"'\ ?ltline\ %lt?L/%L.:byte\ %bB?s/%s..?\ (END):?pB\ %pB\\%..(press h for help or q to quit)'
}
function man ()
{
if command man "$@" >&/dev/null; then
command man "$@"
elif builtin help -m "$@" >&/dev/null; then
builtin help -m "$@" | command man -l -r "$(help_prompt "$@")" -
else
command man "$@"
fi
}
function help ()
{
if builtin help -m "$@" >&/dev/null; then
builtin help "$@" | command man -l -r "$(help_prompt "$@")" -
elif command man "$@" >&/dev/null; then
command man "$@"
else
builtin help -m "$@"
fi
builtin help -m "$@" 2>/dev/null || command man "$@" 2>/dev/null || builtin help -m "$@"
}
# This is, almost without fail, the right value.
export DISPLAY="${DISPLAY:-:0.0}"
COMMON_CONFIGS_PATH="$( dirname "$(realpath -e "${BASH_SOURCE[0]}")" )"
. "$COMMON_CONFIGS_PATH"/bash_tmux.sh
PROMPT_COMMAND=""
export GITAWAREPROMPT="$COMMON_CONFIGS_PATH"/git-aware-prompt
. "$GITAWAREPROMPT"/main.sh
function prettylastexit() {
local exitcode=$?
if [[ -z $exitcode ]]; then
echo "[---]$txtrst "
elif [[ $exitcode == 0 ]]; then
echo "$txtgrn[ OK]$txtrst "
else
printf "$txtred[%3.3s]$txtrst " "$exitcode"
fi
}
PS1='$(prettylastexit)\[$bldred\]${debian_chroot:+($debian_chroot)}\[$txtrst\]\[$txtpur\]\u\[$txtrst\]\[$txtylw\]@\[$txtrst\]\[$txtblu\]\h\[$txtrst\]:\[$bldgrn\]\w\[$txtrst\] \[$txtcyn\]$git_branch\[$txtrst\]\[$bldred\]${git_dirty}\[$txtrst\]\n\$ '

@ -1,4 +0,0 @@
#!/bin/bash
. ~/.bash_aliases-common
auto_tmux

@ -1 +0,0 @@
../../../ssh/authorized_keys

@ -1 +0,0 @@
Include .config-common

@ -1 +0,0 @@
../../../ssh/known_hosts

@ -1,2 +0,0 @@
#!/bin/sh
. ~/.ssh/.rc-common

@ -1 +0,0 @@
source ~/.tmux.conf-common

@ -1 +0,0 @@
source ~/.vimrc-common

@ -1,4 +0,0 @@
#!/bin/bash
. ~/.bash_aliases-common
auto_tmux

@ -1 +0,0 @@
../../../ssh/authorized_keys

@ -1 +0,0 @@
Include .config-common

@ -1 +0,0 @@
../../../ssh/known_hosts

@ -1,2 +0,0 @@
#!/bin/sh
. ~/.ssh/.rc-common

@ -1 +0,0 @@
source ~/.tmux.conf-common

@ -1 +0,0 @@
source ~/.vimrc-common

@ -1,4 +0,0 @@
#!/bin/bash
. ~/.bash_aliases-common
auto_tmux

@ -1 +0,0 @@
$include ~/.inputrc-common

@ -1 +0,0 @@
../../../ssh/authorized_keys

@ -1 +0,0 @@
Include .config-common

@ -1 +0,0 @@
../../../ssh/known_hosts

@ -1,2 +0,0 @@
#!/bin/sh
. ~/.ssh/.rc-common

@ -1 +0,0 @@
source ~/.tmux.conf-common

@ -1 +0,0 @@
source ~/.vimrc-common

@ -1,11 +0,0 @@
#!/bin/bash
. ~/.bash_aliases-common
copy_func tmux_init_main tmux_init_main_base
function tmux_init_main() {
tmux_init_main_base
tmux -2 new-window -d -t "Main Screen:1" -n "Server" "~/current-server/mark2/start; ~/current-server/mark2/attach"
}
auto_tmux

@ -1 +0,0 @@
$include ~/.inputrc-common

@ -1 +0,0 @@
../../../ssh/authorized_keys

@ -1 +0,0 @@
Include .config-common

@ -1 +0,0 @@
../../../ssh/known_hosts

@ -1,2 +0,0 @@
#!/bin/sh
. ~/.ssh/.rc-common

@ -1,2 +0,0 @@
source ~/.tmux.conf-common
set -g base-index 2

@ -1 +0,0 @@
source ~/.vimrc-common

@ -1,4 +1,2 @@
#!/bin/bash #!/bin/bash
. ~/.bash_aliases-common . "$( dirname "$(realpath -e "${BASH_SOURCE[0]}")" )"/../../bash/bash_aliases.sh
auto_tmux

@ -1 +1 @@
../../inputrc ../../readline/inputrc

@ -1 +0,0 @@
../../../ssh/authorized_keys

@ -1 +1 @@
Include .config-common Include config-common

@ -1 +0,0 @@
../../../ssh/known_hosts

@ -1,2 +1,2 @@
#!/bin/sh #!/bin/bash
. ~/.ssh/.rc-common . ${BASH_SOURCE[0]}.rc-common

@ -1 +1 @@
source ~/.tmux.conf-common source $TMUX_CONF_DIR/tmux.conf

@ -1 +1 @@
source ~/.vimrc-common source $VIM_CONFIG_DIR/vimrc

@ -0,0 +1 @@
source $(dirname $(readlink -e ${(%):-%N}))/../../zsh/zshrc.zsh

@ -0,0 +1,2 @@
#!/bin/bash
. "$( dirname "$(realpath -e "${BASH_SOURCE[0]}")" )"/../../bash/bash_aliases.sh

@ -0,0 +1 @@
../../readline/inputrc

@ -0,0 +1 @@
Include config-common

@ -0,0 +1,2 @@
#!/bin/bash
. ${BASH_SOURCE[0]}.rc-common

@ -0,0 +1 @@
source $TMUX_CONF_DIR/tmux.conf

@ -0,0 +1 @@
source $VIM_CONFIG_DIR/vimrc

@ -0,0 +1 @@
source $(dirname $(readlink -e ${(%):-%N}))/../../zsh/zshrc.zsh

@ -0,0 +1,2 @@
#!/bin/bash
. "$( dirname "$(realpath -e "${BASH_SOURCE[0]}")" )"/../../bash/bash_aliases.sh

@ -0,0 +1 @@
../../readline/inputrc

@ -0,0 +1 @@
Include config-common

@ -0,0 +1,2 @@
#!/bin/bash
. ${BASH_SOURCE[0]}.rc-common

@ -0,0 +1 @@
source $TMUX_CONF_DIR/tmux.conf

@ -0,0 +1 @@
source $VIM_CONFIG_DIR/vimrc

@ -0,0 +1 @@
source $(dirname $(readlink -e ${(%):-%N}))/../../zsh/zshrc.zsh

@ -1,4 +1,2 @@
#!/bin/bash #!/bin/bash
. ~/.bash_aliases-common . "$( dirname "$(realpath -e "${BASH_SOURCE[0]}")" )"/../../bash/bash_aliases.sh
auto_tmux

@ -1 +0,0 @@
../../bash_aliases.sh

@ -1 +1 @@
../../inputrc ../../readline/inputrc

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save