My zsh configuration
git clone https://github.com/m-col/zshrc
Files | Refs | Readme

Commit e3d6600c1a6fd95c18c9d5d88caac15362da6be6
Parent: 84aff2e11393ee261481bb3bfdf5b765748d40d2
Author: Matt Colligan <matthewcolligan@improbable.io>
Date: 2023-06-18 00:12:13 +0100
Committer: Matt Colligan <matthewcolligan@improbable.io>
Committed: 2023-06-18 00:12:13 +0100

updates from work mac

zshrc Modified

@@ -16,6 +16,8 @@
     export IS_TMUX=false
 fi
 
+export IS_DOCKER=${IS_DOCKER:-false}
+
 # zsh settings
 local ZSH="$HOME/.zsh"
 HYPHEN_INSENSITIVE="true"
@@ -75,6 +77,3 @@
     z $DO2
     unset DO2
 fi
-
-# Init PYENV for interactive shell
-eval "$(pyenv init -)"

themes/ban.zsh-theme Modified

@@ -125,7 +125,7 @@
 }
 
 
-if $IS_SSH
+if $IS_SSH || $IS_DOCKER
 then
     tmux_following_colour=green
 elif [[ $EUID -eq 0 ]]

functions.zsh Modified

@@ -3,13 +3,14 @@
 #
 
 # use last browsed directory automatically with ranger
+_ranger=`which ranger`
 ranger-cd() { 
     tempfile="$(mktemp -t ranger.XXXXXX)"
     if [[ -f $HOME/.local/bin/ranger ]]
     then
 	$HOME/.local/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}"
     else
-	/usr/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}"
+	$_ranger --choosedir="$tempfile" "${@:-$(pwd)}"
     fi
     test -f "$tempfile" &&
 	if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then

docker-completion.plugin.zsh Added

@@ -0,0 +1,41 @@
+# Copyright 2020 Christian Fritz <mail at chr-fritz dot de>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Adds the given file to the zsh variable fpath.
+# Before adding it, it checks if the file exists.
+__dockerCompletion_linkIfNeeded() {
+    local file=$1
+    local target="/usr/local/share/zsh/site-functions/$2"
+    if [[ -f "${file}" && ! -e "${target}" ]]; then
+        ln -s "${file}" "${target}"
+    fi
+}
+
+# Get the base path of the Docker for Mac installation.
+# It assumes that the completions are relative to the real path of the docker command.
+# This is the normal case for all Docker for Mac installations.
+__dockerCompletion_basePath() {
+    docker_loc=$(which docker)
+    dirname $(dirname ${docker_loc:A})
+}
+
+# Registers the docker completions from the Docker for Mac installation.
+__dockerCompletion_registerCompletion(){
+    basePath="$(__dockerCompletion_basePath)"
+    __dockerCompletion_linkIfNeeded "${basePath}/etc/docker.zsh-completion" "_docker"
+    __dockerCompletion_linkIfNeeded "${basePath}/etc/docker-machine.zsh-completion" "_docker-machine"
+    __dockerCompletion_linkIfNeeded "${basePath}/etc/docker-compose.zsh-completion" "_docker-compose"
+}
+
+__dockerCompletion_registerCompletion

aliases Modified

@@ -6,7 +6,7 @@
 # misc
 alias ..='cd ../'
 alias ...='cd ../../'
-alias l='ls -lhFv -I \*.o'
+alias l='ls -lhFv'
 alias lc='ls -c1'
 alias tmp='cd /tmp; l'
 alias _='sudo'
@@ -15,12 +15,19 @@
 alias rg='grep -r'
 alias pth='echo "${PATH//:/\n}"'
 vgr() { vim `grep -lr "$@"`; }
+alias va="source venv/bin/activate"
+alias vd="deactivate"
+alias dc=docker-compose
 
-if [[ -z "$WAYLAND_DISPLAY" ]]
+if [[ -n "$WAYLAND_DISPLAY" ]]
 then
-    alias copy='xclip -selection clipboard'
-else
     alias copy='wl-copy'
+elif [[ -n "$DISPLAY" ]]
+then
+    alias copy='xclip -selection clipboard'
+elif [[ "$OSTYPE" == "darwin"* ]]
+then
+    alias copy=pbcopy
 fi
 
 alias grep='grep --exclude-dir=__pycache__ --exclude-dir=.git --exclude-dir=.tox --exclude-dir=.eggs --exclude-dir=.mypy_cache'
@@ -61,12 +68,13 @@
 # git
 alias gs='git status'
 alias ad='git add'
+alias adp='git add --patch'
 alias co='git commit'
 alias cm='git commit -m'
 alias ca='git commit --amend'
 alias cmf='git commit --fixup'
 alias psh='git push'
-alias pshs='git push &> /dev/null &'
+alias pshs='git push &> /dev/null &|'
 alias fe='git fetch && git status'
 alias pl='git pull'
 rb() {
@@ -97,6 +105,11 @@
 lgo()  { git log --oneline -${1:-1}; }
 alias lgc="git log -1 | head -1 | awk '{print \$2}' | copy -n"
 
+pdif() {
+    git diff --name-only --diff-filter=${1:-M}
+}
+alias vimd='vim `pdif`'
+
 # tools
 alias usync='rsync -avPzh --delete'
 alias psb='python setup.py -q build'
@@ -120,8 +133,7 @@
 alias gg='cd $HOME/git; l'
 alias gb='cd $HOME/.config/bin'
 alias ge='cd /etc'
-alias gv='cd $HOME/.vim/bundle/vim-misc'
-alias gvm='cd $HOME/.vim/bundle/vim-misc; ra'
+alias gv='cd $HOME/.vim/pack/vim-misc'
 alias gz='cd $HOME/.zsh; l'
 alias gR='cd $HOME/reach'