Commit 76f59c43 authored by Nigel Kukard's avatar Nigel Kukard

Complete rework of awit-zsh-superawesome for IDMS Linux Rolling

parent 66f1058c
......@@ -10,30 +10,12 @@
cd ~
git clone ssh://git@gitlab.devlabs.linuxassist.net:608/allworldit/awit-zsh-superawesome.git .zsh
# Activate ZSH
# Activate the configuration
ln -s .zsh/zshrc .zshrc
# Install fonts
mkdir ~/.fonts
cp fonts/*.ttf ~/.fonts/
fc-cache -fv ~/.fonts
# For Konsole
cp AWIT-ZSH-SuperAwesome.profile ~/.local/share/konsole/
cp AWIT-ZSH-SuperAwesome.colorscheme ~/.local/share/konsole/
Select the "AWIT-ZSH-SuperAwesome" profile as default in Konsole's profile manager.
# Customizing
Customizing can be done by adding files to ~/.zsh/zshrc_local.d/ directory and editing the ~/.zsh/zshrc.local file.
If you have something awesome to contribute, please consider adding it to zshrc.d/.
# Updating
The fonts/ is a download of the complete fonts in https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/Hack
# Ignore everything in this directory
*
# Except this file
!.gitignore
# compsys initialization
autoload -U compinit
compinit
# Get an array of known SSH host names after deleting:
# - Everything after the first column of host names or IPs
# - Square brackets and attached port numbers
# - IP addresses
# - Encrypted host names
hosts=( `sed -e 's/[, ].*//g' -e 's/\[\([^]]*\)\].*/\1/' -e '/^[0-9]\+/d' -e '/^|1|/d' $HOME/.ssh/known_hosts` )
zstyle ':completion:*:hosts' hosts $hosts
#!/bin/zsh
die() {
echo "$1"
exit 1
}
grep -q '^|1|' ~/.ssh/known_hosts && die "ERROR: ~/.ssh/known_hosts is hashed. Aborting!
Please see this contributions README.md for more information."
if [ ! -e ~/.zsh/completion/_awit-ssh ]; then
# Install
ln -s ~/.zsh/contrib/awit-ssh-completion/_awit-ssh ~/.zsh/completion/
echo "Installed ~/.zsh/completion/_awit-ssh"
else
# Uninstall
rm -f ~/.zsh/completion/_awit-ssh
echo "Uninstalled ~/.zsh/completion/_awit-ssh"
fi
if [ ! -e ~/.zsh/zshrc.d/51-completion-awit-ssh.zsh ]; then
# Install
ln -s ~/.zsh/contrib/awit-ssh-completion/51-completion-awit-ssh.zsh ~/.zsh/zshrc_local.d/
echo "Installed ~/.zsh/zshrc.d/51-completion-awit-ssh.zsh"
else
# Uninstall
rm -f ~/.zsh/zshrc.d/51-completion-awit-ssh.zsh ~/.zsh/zshrc_local.d/51-completion-awit-ssh.zsh
echo "Uninstalled ~/.zsh/zshrc.d/51-completion-awit-ssh.zsh and ~/.zsh/zshrc_local.d/51-completion-awit-ssh.zsh"
fi
# awit-ssh Completion
If you want to use awit-ssh completion with zsh you first need to clean up your ~/.ssh/known_hosts file if it is hashed.
Run the follow and if you see any number other than zero, your ~/.ssh/known_hosts file is hashed
grep -c '^|1|' ~/.ssh/known_hosts
Since you need the file unencrypted make a backup of ~/.ssh/known_hosts and then add the following lines to the top of ~/.ssh/config
Host *
HashKnownHosts no
Then delete the hashed lines
sed -i '/^|1|/d' ~/.ssh/known_hosts
Going forward host names will be added in plain text. You'll be prompted to re-add the deleted hosts names as you log in to each server again.
#compdef awit-ssh
local curcontext="$curcontext" state line expl ret=1
local -a _comp_priv_prefix
_arguments -C \
'(-?)--help[display help information]' \
'--version[display version information]' \
'--forward-agent[forward the ssh-agent socket]' \
'--knock[knock on HOST:PORT to gain access]' \
'--rsync[use rsync to rsync data from remote server to DEST]' \
'--libvirt-vnc[connect to remote VNC server HOST:PORT]' \
'1:remote host name:->userhost' \
'*:::args:_normal' && ret=0
case $state in
userhost)
if compset -P '*@'; then
_wanted hosts expl 'remote host name' _ssh_hosts && ret=0
elif compset -S '@*'; then
_wanted users expl 'login name' _combination -s '[:@]' my-accounts users-hosts users -S '' && ret=0
else
_alternative \
'hosts:remote host name:_ssh_hosts' \
'users:login name:_combination -s "[:@]" my-accounts users-hosts users -qS@' && ret=0
fi
;;
esac
return ret
# https://github.com/robbyrussell/oh-my-zsh/wiki/Customization#overriding-internals
*.zsh
# https://github.com/robbyrussell/oh-my-zsh/wiki/Customization#overriding-internals
*.zsh
# https://github.com/robbyrussell/oh-my-zsh/wiki/Customization#overriding-and-adding-plugins
#
# Ignore everything in this directory
*
# Except this file
!.gitignore
/usr/share/zsh/plugins/zsh-syntax-highlighting
\ No newline at end of file
# https://github.com/robbyrussell/oh-my-zsh/wiki/Customization#overriding-and-adding-themes
#
# Ignore everything in this directory
*
# Except this file
!.gitignore
/usr/share/zsh-theme-powerlevel9k/powerlevel9k.zsh-theme
\ No newline at end of file
# We need to enable extended globbing here for the below source inclusion
setopt EXTENDED_GLOB
# Set the directory where we're being loaded from
AZS_DIR=$(dirname "$0")
# Source in resources
find "$HOME"/.zsh/zshrc{,_local}.d -type f -name "*.zsh" | sort -t/ -k6,6 | while read LINE; do
# If there's a file in zshrc_local.d with the same name as one
# in zshrc.d, ignore the file in zshrc.d
if [[ "$LINE" =~ "zshrc.d" && -e "$HOME/.zsh/zshrc_local.d/${LINE:t}" ]] ; then
# Do nothing
:
else
source "$LINE"
fi
# Locate and load zshrc files
find "$AZS_DIR"/zshrc.d -type f -name "*.zsh" | sort | while read rc_file; do
source "$rc_file"
done
# NB: Note that precedence matters, so some settings will not yield the
# expected results when put into ~/.zsh/zshrc.local. In that case you need
# to figure out the file number and put it into ~/.zsh/zshrc_local.d/
# Source in local stuff
if [ -f ~/.zsh/zshrc.local ]
then
source ~/.zsh/zshrc.local
fi
......@@ -5,22 +5,16 @@
if [ -d "$HOME/bin" ]
then
if [[ "$PATH" =~ "$HOME/bin" ]]
if ! [ "$PATH" =~ "$HOME/bin" ]
then
# Do nothing
:
else
export PATH="$HOME/bin:$PATH"
fi
fi
if [ -d "$HOME/.local/bin" ]
then
if [[ "$PATH" =~ "$HOME/.local/bin" ]]
if ! [ "$PATH" =~ "$HOME/.local/bin" ]]
then
# Do nothing
:
else
export PATH="$HOME/.local/bin:$PATH"
fi
fi
......
......@@ -5,8 +5,8 @@ then
then
# Use KDE askpass
export SSH_ASKPASS=/usr/bin/ksshaskpass
echo "zsh: Using ksshaskpass"
echo "A-Z-S: Using ksshaskpass"
else
echo "NOTICE: You're using the plasma desktop, but you don't have ksshaskpass installed?"
echo "A-Z-S: NOTICE - You're using the plasma desktop, but you don't have ksshaskpass installed?"
fi
fi
......@@ -2,5 +2,5 @@
if [ -x /usr/bin/keychain ]
then
eval `keychain --confirm --clear --noask --timeout 15 --eval --systemd --stop others --quiet --inherit local-once --agents ssh`
echo "zsh: Using keychain (15 min timeout, explicit confirmation)"
echo "A-Z-S: Using keychain (15 min timeout, explicit confirmation)"
fi
# Which plugins would you like to load?
# Standard plugins can be found in ~/.zsh/oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
colored-man-pages
colorize
......
# Abort theming if we're not running in xterm-256color
if [ "$TERM" != "xterm-256color" ]; then
return
fi
# Set oh my zsh theme
ZSH_THEME="powerlevel9k"
......
# Useful functions
# Initiate git project with the specified license and commit
function make-project() { mcd "$1"; git init; cp /usr/share/common-licenses/$2 COPYING; git add COPYING; git commit -m "This project is under the $2 licence at this time"; }
# mkdir and cd into it
function mcd() { mkdir -p "$1"; cd "$1"; }
# Dump files in hexadecimal, 4 bytes per integer
function odx() { od -t x4 -A x "$@"; }
# Dump files in hexadecimal, 1 byte per integer
function odx1() { od -t x1 -A x "$@"; }
# Setting -F to the users home dir will ignore the system ssh_config
# We do this because:
# - The system has SendEnv set to send locale environment variables to the server, LANG and LC_ALL
alias ssh="/usr/bin/ssh -F ~/.ssh/config"
# Ignore everything in this directory
*
# Except this file
!.gitignore
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment