Skip to content

Commit

Permalink
✨ Add mergetool, various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelange committed Jul 7, 2020
1 parent eb8dca0 commit 3c04305
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 47 deletions.
26 changes: 13 additions & 13 deletions .bash_profile
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,18 @@ alias sm='smerge'

# bash_history

shopt -s histverify # https://unix.stackexchange.com/a/4082
# global bash history https://unix.stackexchange.com/a/1292
# Avoid duplicates
export HISTCONTROL=ignoredups:erasedups
# When the shell exits, append to the history file instead of overwriting it
shopt -s histappend
export HISTCONTROL=ignoredups #:erasedups
# After each command, append to the history file and reread it
# export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"

export HISTSIZE=
export HISTFILESIZE=
export HISTTIMEFORMAT="[%F %T] "
export HISTFILE=~/.bash_eternal_history
# When the shell exits, append to the history file instead of overwriting it
shopt -s histverify # https://unix.stackexchange.com/a/4082
shopt -s histappend

# prompt

Expand All @@ -79,9 +82,6 @@ PS1="⨊ 𝕯𝓭𝓵:\[\033[36m\]\w\[\033[m\]$ " # ⚛ ⨊ 𝓓𝔇𝒟ℓℒ

# functions

# https://github.com/ddelange/yt
source "${HOME}/git/yt/yt.sh"

# https://gist.github.com/ddelange/24575a702a10c2cb6348c4c7f342e0eb
kubelogs() {
# View logs as they come in (like in Rancher) using mktemp and less -r +F.
Expand All @@ -103,13 +103,13 @@ kubelogs() {
return
fi
local tmpfile=`mktemp`
local log_tail_lines=${KUBELOGS_MAX:-1000}
local sleep_amount=$((5 + log_tail_lines / 400))
local log_tail_lines=${KUBELOGS_MAX:-10000}
local sleep_amount=$((7 + log_tail_lines / 20000))
echo "kubectl logs --kubeconfig ${KUBECONFIG:-"$HOME/.kube/config"} --namespace ${namespace} --since 24h --tail ${log_tail_lines} -f ${podname} > ${tmpfile}"
kubectl logs --kubeconfig ${KUBECONFIG:-"$HOME/.kube/config"} --namespace ${namespace} --since 24h --tail ${log_tail_lines} -f ${podname} > ${tmpfile} &
local k8s_log_pid=$!
echo "Waiting ${sleep_amount}s for logs to download"
sleep ${sleep_amount} && less -r +F ${tmpfile} && kill ${k8s_log_pid} && echo "kubectl logs pid ${k8s_log_pid} killed"
sleep ${sleep_amount} && less -rf +F ${tmpfile} && kill ${k8s_log_pid} && echo "kubectl logs pid ${k8s_log_pid} killed"
}

kubebash() {
Expand Down Expand Up @@ -148,9 +148,9 @@ kubebranch() {
echo "Pod \"${pod}\" not found in namespace \"${namespace}\""
return
fi
kubectl get deployments --kubeconfig ${KUBECONFIG:-"$HOME/.kube/config"} --namespace ${namespace} -o wide | sed -n '1!p' | awk '{print $8}' | uniq | tr "/:" "\t" | column -t | grep ${pod}
kubectl get deployments --kubeconfig ${KUBECONFIG:-"$HOME/.kube/config"} --namespace ${namespace} -o wide | sed -n '1!p' | awk '{print $1 "\t" $8}' | uniq | tr ":" "\t" | column -t | grep ${pod}
else
kubectl get deployments --kubeconfig ${KUBECONFIG:-"$HOME/.kube/config"} --namespace ${namespace} -o wide | sed -n '1!p' | awk '{print $8}' | uniq | tr "/:" "\t" | column -t
kubectl get deployments --kubeconfig ${KUBECONFIG:-"$HOME/.kube/config"} --namespace ${namespace} -o wide | sed -n '1!p' | awk '{print $1 "\t" $8}' | uniq | tr ":" "\t" | column -t
fi
}

Expand Down
4 changes: 2 additions & 2 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": null,
"lines": null
},
"generated_at": "2020-05-10T20:38:58Z",
"generated_at": "2020-07-07T11:44:36Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -62,7 +62,7 @@
{
"hashed_secret": "60b9c35a33c0f5acde612f2984b6917cb35d6d54",
"is_verified": false,
"line_number": 201,
"line_number": 214,
"type": "Secret Keyword"
}
]
Expand Down
35 changes: 29 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Commandline-tools (including [SDK headers](https://github.com/pyenv/pyenv/wiki#s
```bash
# install homebrew and command-line tools, SDK headers
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
xcode-select --install
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
# check wether all is good
brew doctor
Expand All @@ -78,7 +79,8 @@ brew tap buo/cask-upgrade # `brew cu -a docker` - https://github.com/buo/homebr
brew install \
git git-lfs bash-completion rsync curl openssl readline automake xz zlib \
sshfs htop ncdu direnv pwgen \
gcc@8 rust ruby node yarn sqlite3
gcc@8 rust ruby node@12 sqlite3
npm install -g yarn
```


Expand All @@ -88,7 +90,9 @@ brew install \
brew cask install iterm2
brew tap homebrew/cask-fonts
brew cask install font-inconsolatalgc-nerd-font
cargo install exa ripgrep # ls, rg
cargo install ripgrep # rg (search for regex occurrences in directory)
cargo install zoxide # z (cd with auto-complete)
cargo install --git https://github.com/ogham/exa.git
# use exa with icons and git status instead of builtin ls
alias ls="exa --all --group-directories-first --icons --level=2" # default level for --tree
alias ll="ls --long --sort=age --git --time=modified --time-style=iso"
Expand All @@ -101,6 +105,8 @@ alias ll="ls --long --sort=age --git --time=modified --time-style=iso"
# Docker CE - docker.com/community-edition
brew cask install docker
brew install docker-compose
# PostgresApp - postgresapp.com
brew cask install postgres
# Sublime Text - sublimetext.com
brew cask install sublime-text
# Sublime Merge - sublimemerge.com
Expand Down Expand Up @@ -172,15 +178,19 @@ mas install 595191960
git clone https://github.com/momo-lab/pyenv-install-latest.git "$(pyenv root)"/plugins/pyenv-install-latest
git clone git://github.com/concordusapps/pyenv-implict.git "$(pyenv root)"/plugins/pyenv-implict
# list all available python versions
pyenv install -l
pyenv install -l | grep '^\s*[0-9]'
pyenv install-latest 2.7
pyenv install-latest 3.7
sudo SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/ pyenv install-latest 3.8 # might need to unsource .bash_profile first
pyenv global $(pyenv install-latest --print 3.7) $(pyenv install-latest --print 2.7) # set default versions: prefer py3 over py2
source ~/.bash_profile # global history etc
pip install --upgrade pip setuptools wheel Cython
pip3.7 install --upgrade pip setuptools wheel Cython
pip2.7 install --upgrade pip setuptools wheel Cython
pip3.8 install --upgrade pip setuptools wheel Cython
# install virtualenv 'vv' based latest pyenv Python version 3.7, inheriting installed packages
pyenv virtualenv $(pyenv install-latest --print 3.7) --system-site-packages vv
pyenv virtualenv $(pyenv install-latest --print 2.7) --system-site-packages vv27
pyenv virtualenv $(pyenv install-latest --print 3.8) --system-site-packages vv38
```
- Manage envs
```bash
Expand Down Expand Up @@ -220,7 +230,7 @@ Note: first open Chrome for the first time
- iStat Menus preferences: `File/Import Settings...`, select `iStat Menus Settings.ismp`
- Quickly download audio & video with [`yt`](https://github.com/ddelange/yt)
```bash
git clone https://github.com/ddelange/yt.git ~/git/yt && brew install youtube-dl
brew install ddelange/brewformulae/yt
```
Expand Down Expand Up @@ -277,6 +287,16 @@ git config --global icdiff.options "--highlight --line-numbers --numlines=3"
git config --global difftool.icdiff.cmd 'icdiff --highlight --line-numbers --numlines=3 $LOCAL $REMOTE'
```
##### Mergetool
On failed automatic merge, use Sublime Merge GUI for conflict resolution using `git mergetool` or `git mt` (see below).
```bash
git config --global mergetool.smerge.cmd 'smerge mergetool "$BASE" "$LOCAL" "$REMOTE" -o "$MERGED"'
git config --global mergetool.smerge.trustExitCode true
git config --global mergetool.keepBackup false
git config --global merge.tool smerge
```
##### Aliases
Expand All @@ -289,13 +309,16 @@ git config --global alias.camend "commit --amend -am"
git config --global alias.amend "commit --amend --no-edit -a"
git config --global alias.br "branch"
git config --global alias.co "checkout"
git config --global alias.mt "mergetool"
git config --global alias.lg "log --graph --decorate --pretty=oneline --abbrev-commit"
git config --global alias.fp "fetch -p --all" # purge and fetch all remotes
git config --global alias.defaultbranch '! f() { echo $(git remote show origin | grep "HEAD branch" | cut -d ":" -f 2 | xargs); }; f' # https://stackoverflow.com/questions/28666357#comment101797372_50056710
git config --global alias.df '! f() { git icdiff --color=always "$@" | less -eR; }; f' # no FX (keep output in terminal)
git config --global alias.pr '! git push --set-upstream origin "$(git rev-parse --abbrev-ref HEAD)"'
git config --global alias.dm '! git fetch -p && for branch in `git branch -vv | grep '"': gone] ' | awk '"'{print $1}'"'"'`; do git branch -D $branch; done' # 'delete merged' - local branches that have been deleted on remote
git config --global alias.gg '! f() { git checkout "${1:-master}" && git dm && git pull; }; f'
git config --global alias.gg '! f() { git checkout "${1:-$(git defaultbranch)}" && git dm && git pull; }; f' # git gg develop -- no arg: defaultbranch. Return to default branch (or specified branch), delete merged, pull branch
git config --global alias.pall '! f() { START=$(git branch | grep "\*" | sed "s/^.//"); for i in $(git branch | sed "s/^.//"); do git checkout $i; git pull || break; done; git checkout $START; }; f' # 'pull all' - pull local branches that have been updated on remote
git config --global alias.undo '! f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f' # https://megakemp.com/2016/08/25/git-undo/
```
Expand Down
2 changes: 1 addition & 1 deletion sublime_text_user_settings/Base File.sublime-settings
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[
{ "keys": ["shift+ctrl+a"], "command": "alignment" }
]
]
2 changes: 1 addition & 1 deletion sublime_text_user_settings/Default (OSX).sublime-keymap
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[
]
]
2 changes: 1 addition & 1 deletion sublime_text_user_settings/Default.sublime-keymap
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[
]
]
24 changes: 12 additions & 12 deletions sublime_text_user_settings/LaTeXTools.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// Cite/ref autocompletion by default is triggered after e.g. \ref{. If you don't like this,
// set to false. You can also use toggles: C-l,t,a,c and C-l,t,a,r.
"cite_auto_trigger": true,
"ref_auto_trigger": true,
"ref_auto_trigger": true,

// Fill-helper autocompletion triggered for a wide range of references to external
// files. You can also use toggle: C-l,t,a,f
Expand All @@ -21,7 +21,7 @@

// Keep focus on Sublime Text after building (true) or switch to PDF viewer (false)
"keep_focus": true,
// Sync PDF to current editor position after building (true) or not
// Sync PDF to current editor position after building (true) or not
"forward_sync": true,


Expand Down Expand Up @@ -55,7 +55,7 @@
// and "python" by default is liked to Python 3. If blank, "python" is used
// Note: ST3 uses Python 3 internally, but the evince scripts need Python 2
"python2": "",
// The name of the ST2 or ST3 executable. On Ubuntu, both subl and sublime-text are
// The name of the ST2 or ST3 executable. On Ubuntu, both subl and sublime-text are
// available for ST2; adjust as needed for other platforms, and for ST3
"sublime": "sublime-text",
// How long to wait after evince has launched before sending a sync message
Expand All @@ -69,7 +69,7 @@
// ------------------------------------------------------------------
// Build engine settings
// ------------------------------------------------------------------

// OPTION: "builder"
// Specifies a build engine
// Possible values:
Expand Down Expand Up @@ -100,9 +100,9 @@
// If non-empty, specifies a path to a custom builder, relative to the
// Sublime Text Packages directory.
// For instance, "User/builders" (on Windows: "User\builders") is a good
// choice if you roll your own.
// choice if you roll your own.
// (Note: if you choose "User", you may get a Python import error in the
// console, but things will still work).
// console, but things will still work).
// Leave empty ("") for a built-in builder.

"builder_path": "",
Expand All @@ -114,12 +114,12 @@
// Builder setting can be general or OS-dependent

"builder_settings" : {

// General settings:
// See README or third-party documentation

// (built-ins): true shows the log of each command in the output panel
"display_log" : false,
"display_log" : false,

// Platform-specific settings:
"osx" : {
Expand All @@ -141,9 +141,9 @@
// ------------------------------------------------------------------

/* This preference sets the format of the quick panel to select citations using wildcards.
The setting is a list with one or two string using wildcards for author, title, keyword etc.
Default setting: the traditional display, `["{title} ({keyword})","{author}"]`
The setting is a list with one or two string using wildcards for author, title, keyword etc.
Default setting: the traditional display, `["{title} ({keyword})","{author}"]`
Format:
Can quantum-mechanical description of physical reality be considered complete? This is an non-existing subtitle to illustrate (einstein1935quantum)
Albert Einstein and B Podolsky and N Rosen
Expand Down Expand Up @@ -173,4 +173,4 @@
// Similarly, the formatting for the autocomplete panel:
"cite_autocomplete_format": "{keyword}: {title}"

}
}
2 changes: 1 addition & 1 deletion sublime_text_user_settings/LaTeXing.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
}
],
"output_directory": false
}
}
2 changes: 2 additions & 0 deletions sublime_text_user_settings/Package Control.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
"installed_packages":
[
"All Autocomplete",
"ayu",
"Babel",
"BracketHighlighter",
"Diffy",
"Dockerfile Syntax Highlighting",
"FindKeyConflicts",
"Github Color Theme",
"GitLink",
"Jedi - Python autocompletion",
"JsPrettier",
Expand Down
17 changes: 14 additions & 3 deletions sublime_text_user_settings/Preferences.sublime-settings
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"index_exclude_patterns": ["*.log", "htmlcov/", "node_modules/", ".mypy_cache/"],
"folder_exclude_patterns": ["htmlcov", "node_modules", ".mypy_cache"],
"added_words":
[
"accretes",
Expand Down Expand Up @@ -52,11 +50,17 @@
],
"auto_indent": true,
"caret_style": "phase",
"color_scheme": "Packages/Neon Color Scheme/Neon.tmTheme",
"color_scheme": "Packages/Github Color Theme/GitHub.tmTheme",
"dictionary": "Packages/Language - English/en_GB.dic",
"draw_indent_guides": true,
"ensure_newline_at_eof_on_save": true,
"fade_fold_buttons": false,
"folder_exclude_patterns":
[
"htmlcov",
"node_modules",
".mypy_cache"
],
"font_options": "subpixel_antialias",
"font_size": 10.0,
"gitlink_revision_type": "commithash",
Expand All @@ -72,6 +76,13 @@
],
"indent_to_bracket": false,
"indent_using_spaces": true,
"index_exclude_patterns":
[
"*.log",
"htmlcov/",
"node_modules/",
".mypy_cache/"
],
"keymaps":
{
"show_pretty_keys": true
Expand Down
10 changes: 5 additions & 5 deletions sublime_text_user_settings/SublimeLinter.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
"disable": false,
"python": "~/.pyenv/versions/vv/bin/python",
"args": [
"ignore = D10,E203,E501,W503",
"max-line-length = 88",
"select = A,B,C4,D,E,F,M,Q,T,W,ABS,BLK",
// "inline-quotes = \"",
"docstring-convention = google",
"--ignore=D10,E203,E501,W503",
"--max-line-length=88",
"--select=A,B,C4,D,E,F,M,Q,T,W,ABS,BLK",
"--inline-quotes=\"",
"--docstring-convention=google",
"--exclude=.git,__pycache__,.direnv,node_modules",
],
"working_dir": "${folder}", // or just put above in a config.cfg with [flake8] in the root level folder in the sidebar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,4 @@
<key>uuid</key>
<string>D8D5E82E-3D5B-46B5-B38E-8C841C21347D</string>
</dict>
</plist>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,4 @@
<key>uuid</key>
<string>8D4988B9-ADD8-436F-B388-BC1360F8504B</string>
</dict>
</plist>
</plist>

0 comments on commit 3c04305

Please sign in to comment.