From 2b95eb1d48a24c3799ac4971748fe2d50da26228 Mon Sep 17 00:00:00 2001 From: Karel Kočí Date: Sun, 17 Sep 2017 20:07:10 +0200 Subject: Add usbkey script --- install | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'install') diff --git a/install b/install index bd6ef50..c6b769e 100755 --- a/install +++ b/install @@ -114,3 +114,7 @@ fi if ask "Install lxc-net script"; then inst local/bin/lxc-net ~/.local/bin/lxc-net fi + +if ask "Install usbkey script"; then + inst local/bin/usbkey ~/.local/bin/usbkey +fi -- cgit v1.3 From 39da53ab62b710a231cef8cea50bfa316816f2ad Mon Sep 17 00:00:00 2001 From: Karel Kočí Date: Mon, 18 Sep 2017 21:04:04 +0200 Subject: Add completions for usbkey --- bash_completions/usbkey | 35 +++++++++++++++++++++++++++++++++++ bashrc | 8 ++++++++ install | 4 ++++ zsh_completions/usbkey | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ zshrc | 1 + 5 files changed, 96 insertions(+) create mode 100644 bash_completions/usbkey create mode 100644 zsh_completions/usbkey (limited to 'install') diff --git a/bash_completions/usbkey b/bash_completions/usbkey new file mode 100644 index 0000000..10cb0b9 --- /dev/null +++ b/bash_completions/usbkey @@ -0,0 +1,35 @@ +# Bash completion file for usbkey +# vim: ft=sh + +_usbkey_mounted() { + mount | grep "/media/usbkey" | grep -q "/dev/mapper/usbkey" +} + +_usbkey() { + local cur prev + _init_completion || return + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + if [[ $COMP_CWORD -gt 1 ]]; then + _usbkey_mounted || return + case "${COMP_WORDS[1]}" in + ssh-import) + [ -d "/media/usbkey/ssh" ] || return + local keys + for F in $(find "/media/usbkey/ssh" -name '*.pub'); do + F="${F#/media/usbkey/ssh/}" + keys="$keys ${F%.pub}" + done + COMPREPLY+=($(compgen -W "${keys}" -- ${cur})) + ;; + esac + else + local ops="-h --help mount sync" + if _usbkey_mounted; then + ops="$ops unmount ssh-list ssh-generate ssh-import" + fi + COMPREPLY+=($(compgen -W "${ops}" -- ${cur})) + fi +} + +complete -F _usbkey usbkey diff --git a/bashrc b/bashrc index aee1c22..a5462d5 100644 --- a/bashrc +++ b/bashrc @@ -10,6 +10,14 @@ if [ -f /etc/bashrc ]; then . /etc/bashrc fi +# Source all completions +if [ -d ~/.bash_completions ]; then + for F in $(find ~/.bash_completions -type f); do + . "$F" + done +fi + +# PROMPT ####################################################### PS1='$( if [ `id -u` -eq "0" ]; then echo -n "\[\e[1;31m\]\u@\h:\[\e[1;34m\]\W\[\e[1;31m\]\$\[\e[0m\] " diff --git a/install b/install index c6b769e..549f63f 100755 --- a/install +++ b/install @@ -22,12 +22,14 @@ if ask "Install Bashrc"; then inst bashrc ~/.bashrc inst shellrc ~/.shellrc inst profile ~/.profile + mkdir -p ~/.bash_completions fi if ask "Install zshrc"; then inst zshrc ~/.zshrc inst shellrc ~/.shellrc inst zprofile ~/.zprofile + mkdir -p ~/.zsh_completions fi if ask "Install GIT configuration"; then @@ -117,4 +119,6 @@ fi if ask "Install usbkey script"; then inst local/bin/usbkey ~/.local/bin/usbkey + inst zsh_completions/usbkey ~/.zsh_completions/_usbkey + inst bash_completions/usbkey ~/.bash_completions/usbkey fi diff --git a/zsh_completions/usbkey b/zsh_completions/usbkey new file mode 100644 index 0000000..0de1375 --- /dev/null +++ b/zsh_completions/usbkey @@ -0,0 +1,48 @@ +#compdef usbkey +#autoload + +_usbkey_mounted() { + mount | grep "/media/usbkey" | grep -q "/dev/mapper/usbkey" +} + +_usbkey () { + local cmd + if (( CURRENT > 2)); then + _usbkey_mounted || return + operation=${words[2]} + # Run the completion for the subcommand + case "${operation}" in + ssh-import) + [ -d "/media/usbkey/ssh" ] || return + local keys=() + for F in $(find "/media/usbkey/ssh" -name '*.pub'); do + F="${F#/media/usbkey/ssh/}" + keys+=("${F%.pub}") + done + _describe -t keys 'usbkey' keys + ;; + # TODO + esac + else + local operations=( + "mount:Mount key of usb driver" + "unmount:Unmount usb driver" + "sync:Synchronize drive to bakup drive" + ) + if _usbkey_mounted; then + operations+=( + "gpg-import:Import gpg key" + "ssh-import:Import ssh key" + "ssh-generate:Generate new ssh key" + "ssh-list:List all keys in store" + "openvpn-list:List all keys" + "openvpn-get:Get keys for some host" + "openvpn-generate:Generate key for new host" + ) + fi + _describe -t operations 'usbkey' operations + _arguments : "--help[Output help message]" + fi +} + +_usbkey diff --git a/zshrc b/zshrc index dceef1b..c8f8f31 100644 --- a/zshrc +++ b/zshrc @@ -10,6 +10,7 @@ zstyle ':completion:*' cache-path ~/.cache/zsh zstyle :compinstall filename '/home/kkoci/.zshrc' zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)(?)*==32=33}:${(s.:.)LS_COLORS}")' zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} +fpath=(~/.zsh_completions $fpath) autoload -Uz compinit && compinit autoload -Uz colors && colors -- cgit v1.3 From 5193d42151091b2d15b28f1095a5ee19589bc312 Mon Sep 17 00:00:00 2001 From: Karel Kočí Date: Thu, 5 Oct 2017 23:33:18 +0200 Subject: Add htop configuration --- config/htop/htoprc | 26 ++++++++++++++++++++++++++ install | 1 + 2 files changed, 27 insertions(+) create mode 100644 config/htop/htoprc (limited to 'install') diff --git a/config/htop/htoprc b/config/htop/htoprc new file mode 100644 index 0000000..0492e91 --- /dev/null +++ b/config/htop/htoprc @@ -0,0 +1,26 @@ +# Beware! This file is rewritten by htop when settings are changed in the interface. +# The parser is also very primitive, and not human-friendly. +fields=0 48 17 18 38 39 40 2 46 47 49 1 +sort_key=46 +sort_direction=1 +hide_threads=1 +hide_kernel_threads=1 +hide_userland_threads=1 +shadow_other_users=0 +show_thread_names=0 +show_program_path=1 +highlight_base_name=0 +highlight_megabytes=1 +highlight_threads=1 +tree_view=1 +header_margin=1 +detailed_cpu_time=0 +cpu_count_from_zero=0 +update_process_names=0 +account_guest_in_cpu_meter=0 +color_scheme=0 +delay=15 +left_meters=LeftCPUs Memory Swap +left_meter_modes=1 1 1 +right_meters=RightCPUs Tasks LoadAverage Uptime +right_meter_modes=1 2 2 2 diff --git a/install b/install index 549f63f..efce93f 100755 --- a/install +++ b/install @@ -39,6 +39,7 @@ fi if ask "Install configurations for various utility tools"; then inst screenrc ~/.screenrc + inst config/htop/htoprc ~/.config/htop/htoprc fi if ask "Install user services"; then -- cgit v1.3