From 586aa3b5e75bd2ad284850a1baaba1e0c1862ddd Mon Sep 17 00:00:00 2001 From: Nikolas Weger Date: Tue, 26 May 2020 21:52:12 +0200 Subject: [PATCH] updated stuff --- copy/gitconfig | 18 +++++++++---- copy/sshconfig | 5 ++++ zsh/dircolor.zsh | 3 +-- zsh/fpath/_extract | 7 +++++ zsh/libs/completion.zsh | 2 +- zsh/libs/directories.zsh | 5 ---- zsh/plgs/aliases.zsh | 7 ----- zsh/plgs/appup.zsh | 58 ++++++++++++++++++++++++++++++---------- zsh/plgs/extract.zsh | 11 ++++++++ zsh/plgs/systemctl.zsh | 3 --- 10 files changed, 82 insertions(+), 37 deletions(-) create mode 100644 zsh/fpath/_extract diff --git a/copy/gitconfig b/copy/gitconfig index 91641b8..ae8638b 100644 --- a/copy/gitconfig +++ b/copy/gitconfig @@ -78,12 +78,20 @@ compact = "%C(auto)%h %s %C(green)%ar%n %C(auto)%d%n" detail = "%C(auto)%h %s%n %C(yellow)by %C(blue)%an %C(magenta)<%ae> [%G?] %C(green)%ar%n %C(auto)%d%n" -[merge] - defaultToUpstream = true - tool = vimdiff +[diff] + tool = meld -[mergetool] - keepBackup = false +[difftool] + prompt = false + +[difftool "meld"] + cmd = meld "$REMOTE" "$LOCAL" + +[merge] + tool = meld + +[mergetool "meld"] + cmd = meld "$LOCAL" "$MERGED" "$REMOTE" --output "$MERGED" [push] default = upstream diff --git a/copy/sshconfig b/copy/sshconfig index e9d101a..0cb8c5d 100644 --- a/copy/sshconfig +++ b/copy/sshconfig @@ -1,6 +1,11 @@ Host * + AddressFamily inet ServerAliveInterval 300 ServerAliveCountMax 2 Host web + HostName megumi.eeleater.org ForwardX11 yes + +Host pxm + HostName pxm.eeleater.org \ No newline at end of file diff --git a/zsh/dircolor.zsh b/zsh/dircolor.zsh index 4296d1b..213373c 100644 --- a/zsh/dircolor.zsh +++ b/zsh/dircolor.zsh @@ -1,2 +1 @@ -LS_COLORS='no=00;38;2;171;178;191:fi=00:rs=00;38;2;171;178;191:di=00;38;2;97;175;239:ln=00;38;2;86;182;194:mh=00:pi=07;38;2;171;178;191:so=07;38;2;171;178;191:do=07;38;2;171;178;191:bd=07;38;2;171;178;191:cd=07;38;2;171;178;191:or=00;38;2;190;80;70:su=01;38;2;171;178;191:sg=04;01;38;2;171;178;191:ca=07;38;2;171;178;191:tw=04;01;38;2;97;175;239:ow=01;38;2;97;175;239:st=04;38;2;97;175;239:ex=00;38;2;152;195;121:*.jl=00;38;2;198;120;221:*.c=00;38;2;198;120;221:*.cpp=00;38;2;198;120;221:*.cc=00;38;2;198;120;221:*.h=00;38;2;198;120;221:*.asm=00;38;2;198;120;221:*.py=00;38;2;198;120;221:*.js=00;38;2;198;120;221:*.java=00;38;2;198;120;221:*.sh=00;38;2;198;120;221:*.perl=00;38;2;198;120;221:*.pl=00;38;2;198;120;221:*.go=00;38;2;198;120;221:*.scala=00;38;2;198;120;221:*.m=00;38;2;198;120;221:*.cs=00;38;2;198;120;221:*.r=00;38;2;198;120;221:*.csv=00;38;2;92;99;112:*.txt=00;38;2;92;99;112:*.md=00;38;2;92;99;112:*.toml=00;38;2;92;99;112:*.yml=00;38;2;92;99;112:*.yaml=00;38;2;92;99;112:*.xml=00;38;2;92;99;112:*.json=00;38;2;92;99;112:*.conf=00;38;2;92;99;112:*.tar=00;38;2;224;108;117:*.tgz=00;38;2;224;108;117:*.arj=00;38;2;224;108;117:*.taz=00;38;2;224;108;117:*.lzh=00;38;2;224;108;117:*.lzma=00;38;2;224;108;117:*.tlz=00;38;2;224;108;117:*.txz=00;38;2;224;108;117:*.zip=00;38;2;224;108;117:*.z=00;38;2;224;108;117:*.Z=00;38;2;224;108;117:*.dz=00;38;2;224;108;117:*.gz=00;38;2;224;108;117:*.lz=00;38;2;224;108;117:*.xz=00;38;2;224;108;117:*.bz2=00;38;2;224;108;117:*.bz=00;38;2;224;108;117:*.tbz=00;38;2;224;108;117:*.tbz2=00;38;2;224;108;117:*.tz=00;38;2;224;108;117:*.deb=00;38;2;224;108;117:*.rpm=00;38;2;224;108;117:*.jar=00;38;2;224;108;117:*.rar=00;38;2;224;108;117:*.ace=00;38;2;224;108;117:*.zoo=00;38;2;224;108;117:*.cpio=00;38;2;224;108;117:*.7z=00;38;2;224;108;117:*.rz=00;38;2;224;108;117:*.apk=00;38;2;224;108;117:*.gem=00;38;2;224;108;117:*.jpg=00;38;2;229;192;123:*.JPG=00;38;2;229;192;123:*.jpeg=00;38;2;229;192;123:*.gif=00;38;2;229;192;123:*.bmp=00;38;2;229;192;123:*.pbm=00;38;2;229;192;123:*.pgm=00;38;2;229;192;123:*.ppm=00;38;2;229;192;123:*.tga=00;38;2;229;192;123:*.xbm=00;38;2;229;192;123:*.xpm=00;38;2;229;192;123:*.tif=00;38;2;229;192;123:*.tiff=00;38;2;229;192;123:*.png=00;38;2;229;192;123:*.PNG=00;38;2;229;192;123:*.svg=00;38;2;229;192;123:*.svgz=00;38;2;229;192;123:*.mng=00;38;2;229;192;123:*.pcx=00;38;2;229;192;123:*.dl=00;38;2;229;192;123:*.xcf=00;38;2;229;192;123:*.xwd=00;38;2;229;192;123:*.yuv=00;38;2;229;192;123:*.cgm=00;38;2;229;192;123:*.emf=00;38;2;229;192;123:*.eps=00;38;2;229;192;123:*.CR2=00;38;2;229;192;123:*.ico=00;38;2;229;192;123:*.mov=00;38;2;229;192;123:*.MOV=00;38;2;229;192;123:*.mpg=00;38;2;229;192;123:*.mpeg=00;38;2;229;192;123:*.m2v=00;38;2;229;192;123:*.mkv=00;38;2;229;192;123:*.ogm=00;38;2;229;192;123:*.mp4=00;38;2;229;192;123:*.m4v=00;38;2;229;192;123:*.mp4v=00;38;2;229;192;123:*.vob=00;38;2;229;192;123:*.qt=00;38;2;229;192;123:*.nuv=00;38;2;229;192;123:*.wmv=00;38;2;229;192;123:*.asf=00;38;2;229;192;123:*.rm=00;38;2;229;192;123:*.rmvb=00;38;2;229;192;123:*.flc=00;38;2;229;192;123:*.avi=00;38;2;229;192;123:*.fli=00;38;2;229;192;123:*.flv=00;38;2;229;192;123:*.gl=00;38;2;229;192;123:*.m2ts=00;38;2;229;192;123:*.divx=00;38;2;229;192;123:*.webm=00;38;2;229;192;123:'; -export LS_COLORS +export LS_COLORS='no=00;38;2;171;178;191:fi=00:rs=00;38;2;171;178;191:di=00;38;2;97;175;239:ln=00;38;2;86;182;194:mh=00:pi=07;38;2;171;178;191:so=07;38;2;171;178;191:do=07;38;2;171;178;191:bd=07;38;2;171;178;191:cd=07;38;2;171;178;191:or=00;38;2;190;80;70:su=01;38;2;171;178;191:sg=04;01;38;2;171;178;191:ca=07;38;2;171;178;191:tw=04;01;38;2;97;175;239:ow=01;38;2;97;175;239:st=04;38;2;97;175;239:ex=00;38;2;152;195;121:*.jl=00;38;2;198;120;221:*.c=00;38;2;198;120;221:*.cpp=00;38;2;198;120;221:*.cc=00;38;2;198;120;221:*.h=00;38;2;198;120;221:*.asm=00;38;2;198;120;221:*.py=00;38;2;198;120;221:*.js=00;38;2;198;120;221:*.java=00;38;2;198;120;221:*.sh=00;38;2;198;120;221:*.perl=00;38;2;198;120;221:*.pl=00;38;2;198;120;221:*.go=00;38;2;198;120;221:*.scala=00;38;2;198;120;221:*.m=00;38;2;198;120;221:*.cs=00;38;2;198;120;221:*.r=00;38;2;198;120;221:*.csv=00;38;2;92;99;112:*.txt=00;38;2;92;99;112:*.md=00;38;2;92;99;112:*.toml=00;38;2;92;99;112:*.yml=00;38;2;92;99;112:*.yaml=00;38;2;92;99;112:*.xml=00;38;2;92;99;112:*.json=00;38;2;92;99;112:*.conf=00;38;2;92;99;112:*.tar=00;38;2;224;108;117:*.tgz=00;38;2;224;108;117:*.arj=00;38;2;224;108;117:*.taz=00;38;2;224;108;117:*.lzh=00;38;2;224;108;117:*.lzma=00;38;2;224;108;117:*.tlz=00;38;2;224;108;117:*.txz=00;38;2;224;108;117:*.zip=00;38;2;224;108;117:*.z=00;38;2;224;108;117:*.Z=00;38;2;224;108;117:*.dz=00;38;2;224;108;117:*.gz=00;38;2;224;108;117:*.lz=00;38;2;224;108;117:*.xz=00;38;2;224;108;117:*.bz2=00;38;2;224;108;117:*.bz=00;38;2;224;108;117:*.tbz=00;38;2;224;108;117:*.tbz2=00;38;2;224;108;117:*.tz=00;38;2;224;108;117:*.deb=00;38;2;224;108;117:*.rpm=00;38;2;224;108;117:*.jar=00;38;2;224;108;117:*.rar=00;38;2;224;108;117:*.ace=00;38;2;224;108;117:*.zoo=00;38;2;224;108;117:*.cpio=00;38;2;224;108;117:*.7z=00;38;2;224;108;117:*.rz=00;38;2;224;108;117:*.apk=00;38;2;224;108;117:*.gem=00;38;2;224;108;117:*.jpg=00;38;2;229;192;123:*.JPG=00;38;2;229;192;123:*.jpeg=00;38;2;229;192;123:*.gif=00;38;2;229;192;123:*.bmp=00;38;2;229;192;123:*.pbm=00;38;2;229;192;123:*.pgm=00;38;2;229;192;123:*.ppm=00;38;2;229;192;123:*.tga=00;38;2;229;192;123:*.xbm=00;38;2;229;192;123:*.xpm=00;38;2;229;192;123:*.tif=00;38;2;229;192;123:*.tiff=00;38;2;229;192;123:*.png=00;38;2;229;192;123:*.PNG=00;38;2;229;192;123:*.svg=00;38;2;229;192;123:*.svgz=00;38;2;229;192;123:*.mng=00;38;2;229;192;123:*.pcx=00;38;2;229;192;123:*.dl=00;38;2;229;192;123:*.xcf=00;38;2;229;192;123:*.xwd=00;38;2;229;192;123:*.yuv=00;38;2;229;192;123:*.cgm=00;38;2;229;192;123:*.emf=00;38;2;229;192;123:*.eps=00;38;2;229;192;123:*.CR2=00;38;2;229;192;123:*.ico=00;38;2;229;192;123:*.mov=00;38;2;229;192;123:*.MOV=00;38;2;229;192;123:*.mpg=00;38;2;229;192;123:*.mpeg=00;38;2;229;192;123:*.m2v=00;38;2;229;192;123:*.mkv=00;38;2;229;192;123:*.ogm=00;38;2;229;192;123:*.mp4=00;38;2;229;192;123:*.m4v=00;38;2;229;192;123:*.mp4v=00;38;2;229;192;123:*.vob=00;38;2;229;192;123:*.qt=00;38;2;229;192;123:*.nuv=00;38;2;229;192;123:*.wmv=00;38;2;229;192;123:*.asf=00;38;2;229;192;123:*.rm=00;38;2;229;192;123:*.rmvb=00;38;2;229;192;123:*.flc=00;38;2;229;192;123:*.avi=00;38;2;229;192;123:*.fli=00;38;2;229;192;123:*.flv=00;38;2;229;192;123:*.gl=00;38;2;229;192;123:*.m2ts=00;38;2;229;192;123:*.divx=00;38;2;229;192;123:*.webm=00;38;2;229;192;123:'; diff --git a/zsh/fpath/_extract b/zsh/fpath/_extract new file mode 100644 index 0000000..1a263a7 --- /dev/null +++ b/zsh/fpath/_extract @@ -0,0 +1,7 @@ +#compdef extract +#autoload + +_arguments \ + '(-r --remove)'{-r,--remove}'[Remove archive.]' \ + "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \ + && return 0 diff --git a/zsh/libs/completion.zsh b/zsh/libs/completion.zsh index 5cb612a..9d93b72 100644 --- a/zsh/libs/completion.zsh +++ b/zsh/libs/completion.zsh @@ -38,7 +38,7 @@ zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-dir zstyle ':completion::complete:*' use-cache 1 zstyle ':completion::complete:*' cache-path "$HOME/.cache/zsh/compcache/" -zstyle ':completion:*:*:*:users' ignored-patterns adm amanda apache at avahi avahi-autoipd backup beaglidx bin bitwarden_rs cacti canna clamav ceph colord consul daemon dbus distcache dnsdist dnsmasq dovecot eeleater elasticsearch fax flaskdemo ftp games gdm git gitea gkrellmd gluster gopher gophernicus gnats hacluster haldaemon halt hsqldb http ident irc junkbust kdm kibana landscape ldap list lldpd logstash lp lxd mail mailman mailnull man mattermost messagebus mldonkey mongodb mxisd mysql nagios named netdata netdump news nfsnobody nobody nscd ntp nut nweger nx obsrun openvpn operator pcap pcp polkitd pollinate postfix postgres powerdns privoxy proxy pulse prosody puppet pvm quagga radvd redis rpc rpcuser rpm rtkit root scard shutdown squid sshd statd svn synapse sync sys syslog systemd-coredump systemd-journal-remote systemd-network systemd-resolve systemd-timesync tcpdump teamspeak tftp tss turnserver usbmux unbound uucp uuidd vault vcsa webvirtmgr wildfly wwwrun www-data xfs youtrack zabbix-agent zabbix-server zabbix zerotier-one zerotier '_*' +zstyle ':completion:*:*:*:users' ignored-patterns adm amanda apache at avahi avahi-autoipd backup beaglidx bin bitwarden_rs cacti canna clamav ceph colord consul cups daemon dbus dhcp dhcpcd distcache dnsdist dnsmasq dovecot eeleater elasticsearch fax flatpak flaskdemo ftp games gdm geoclue git gitea gkrellmd gluster gopher gophernicus gnats hacluster haldaemon halt hsqldb http ident irc junkbust kdm kibana landscape ldap lightdm list lldpd logstash lp lxd mail mailman mailnull man mattermost messagebus mldonkey mongodb mxisd mysql nagios named netdata netdump news nfsnobody nm-openvpn nobody nscd ntp nut nvidia-persistenced nweger nx obsrun openvpn operator pcap pcp polkitd pollinate postfix postgres powerdns privoxy proxy pulse prosody puppet pvm quagga radiusd radvd redis rpc rpcuser rpm rtkit root scard sddm shutdown squid sshd statd stunnel svn synapse sync sys syslog systemd-coredump systemd-journal-remote systemd-network systemd-resolve systemd-timesync tcpdump teamspeak tftp tinyproxy transmission tss turnserver usbmux unbound uucp uuidd vault vcsa webvirtmgr wildfly wwwrun www-data xfs youtrack zabbix-agent zabbix-server zabbix zerotier-one zerotier '_*' zstyle '*' single-ignored show diff --git a/zsh/libs/directories.zsh b/zsh/libs/directories.zsh index 28a2c94..faea546 100644 --- a/zsh/libs/directories.zsh +++ b/zsh/libs/directories.zsh @@ -1,8 +1,3 @@ setopt auto_pushd setopt pushd_ignore_dups setopt pushdminus - -alias lsa='ls -lah' -alias l='ls -lah' -alias ll='ls -lh' -alias la='ls -lAh' diff --git a/zsh/plgs/aliases.zsh b/zsh/plgs/aliases.zsh index b043405..14bf01b 100644 --- a/zsh/plgs/aliases.zsh +++ b/zsh/plgs/aliases.zsh @@ -2,13 +2,6 @@ alias ls='exa -al --color=always --group-directories-first' alias la='exa -a --color=always --group-directories-first' alias ll='exa -l --color=always --group-directories-first' alias lt='exa -aT --color=always --group-directories-first' -alias lg='ls --git' - -alias grep='grep --color' -alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} ' - -alias fd='find . -type d -name' -alias ff='find . -type f -name' alias rm='rm -i' alias cp='cp -i' diff --git a/zsh/plgs/appup.zsh b/zsh/plgs/appup.zsh index 0ed4054..31b3d3f 100644 --- a/zsh/plgs/appup.zsh +++ b/zsh/plgs/appup.zsh @@ -1,36 +1,65 @@ +# Docker _appup_docker () { if hash docker-compose >/dev/null 2>&1; then - if hash docker-machine >/dev/null 2>&1; then - if docker-machine status | grep -qi "Stopped"; then - read -q "REPLY?Docker Machine is not running, would you like to start it? [y/n] " - echo "" - - if [[ "$REPLY" == "y" ]]; then - docker-machine start default && eval $(docker-machine env default) + # Check if docker has been started + if [ "${APPUP_CHECK_STARTED:-true}" = true ]; then + if hash docker-machine >/dev/null 2>&1 && [ "${APPUP_DOCKER_MACHINE:-true}" = true ]; then + if docker-machine status | grep -qi "Stopped"; then + read -r -k 1 "REPLY?Docker Machine is not running, would you like to start it? [y/N] " echo "" + + if [[ "$REPLY" == "y" ]]; then + docker-machine start default && eval $(docker-machine env default) + echo "" + else + return 0 + fi + fi + elif docker ps 2>&1 | grep -qi "Is the docker daemon running?"; then + read -r -k 1 "REPLY?Docker for Mac is not running, would you like to start it? [y/N] " + echo "" + + if [[ "$REPLY" == "y" ]]; then + open -a Docker + + echo "" + echo "Waiting for docker to start.." + echo "" + + # Wait for it to start + while true; do + if docker ps 2>&1 | grep -qi "Is the docker daemon running?" || docker ps 2>&1 | grep -qi "connection refused"; then + sleep 5 + else + break + fi + done else - return + return0 fi fi fi - + + # Check YAML extension compose_file='' compose_project_file='' - + if [ -e "docker-compose.yml" ]; then compose_file='docker-compose.yml' elif [ -e "docker-compose.yaml" ]; then compose_file='docker-compose.yaml' fi - + + # will look for docker-compose..yml if [ -n "$2" ]; then if [ -e "docker-compose.$2.yml" ]; then compose_project_file="docker-compose.$2.yml" elif [ -e "docker-compose.$2.yaml" ]; then compose_project_file="docker-compose.$2.yaml" fi - - if [ -n "$compose_project_file" ]; then + + if [ -n "$compose_project_file" ]; then + # Override project name from custom env if [ -e ".env.$2" ]; then project=$(source ".env.$2"; echo $COMPOSE_PROJECT_NAME) @@ -51,6 +80,7 @@ _appup_docker () { fi } +# Vagrant _appup_vagrant () { if hash vagrant >/dev/null 2>&1; then vagrant $1 "${@:2}" @@ -59,6 +89,7 @@ _appup_vagrant () { fi } +# Commands up () { if [ -e "docker-compose.yml" ] || [ -e "docker-compose.yaml" ]; then _appup_docker up "$@" @@ -108,4 +139,3 @@ stop () { env stop "$@" fi } - diff --git a/zsh/plgs/extract.zsh b/zsh/plgs/extract.zsh index d3d847d..a5594b8 100644 --- a/zsh/plgs/extract.zsh +++ b/zsh/plgs/extract.zsh @@ -40,14 +40,24 @@ extract() { tar --lzma --help &> /dev/null \ && tar --lzma -xvf "$1" \ || lzcat "$1" | tar xvf - ;; + (*.tar.zst|*.tzst) + tar --zstd --help &> /dev/null \ + && tar --zstd -xvf "$1" \ + || zstdcat "$1" | tar xvf - ;; (*.tar) tar xvf "$1" ;; + (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$1" ;; + (*.tar.lz4) lz4 -c -d "$1" | tar xvf - ;; + (*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$1" ;; (*.gz) (( $+commands[pigz] )) && pigz -dk "$1" || gunzip -k "$1" ;; (*.bz2) bunzip2 "$1" ;; (*.xz) unxz "$1" ;; + (*.lrz) (( $+commands[lrunzip] )) && lrunzip "$1" ;; + (*.lz4) lz4 -d "$1" ;; (*.lzma) unlzma "$1" ;; (*.z) uncompress "$1" ;; (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;; (*.rar) unrar x -ad "$1" ;; + (*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;; (*.7z) 7za x "$1" ;; (*.deb) mkdir -p "$extract_dir/control" @@ -58,6 +68,7 @@ extract() { cd ..; rm *.tar.* debian-binary cd .. ;; + (*.zst) unzstd "$1" ;; (*) echo "extract: '$1' cannot be extracted" >&2 success=1 diff --git a/zsh/plgs/systemctl.zsh b/zsh/plgs/systemctl.zsh index ed22bc5..c37748c 100644 --- a/zsh/plgs/systemctl.zsh +++ b/zsh/plgs/systemctl.zsh @@ -3,6 +3,3 @@ cmds=(status show start stop reload restart enable disable daemon-reload) for cmd in $cmds; do alias sc-$cmd="sudo systemctl $cmd" done - -alias sc-enablenow="sc-enable --now" -alias sc-disablenow="sc-disable --now"