Skip to content

Instantly share code, notes, and snippets.

@petevb
Last active May 18, 2023 09:52
Show Gist options
  • Save petevb/b0550df0114ed14ad68f9486c375403e to your computer and use it in GitHub Desktop.
Save petevb/b0550df0114ed14ad68f9486c375403e to your computer and use it in GitHub Desktop.
[dotfiles] copy to `%userprofile%`
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# twotime: https://www.npmjs.com/package/twotime
alias tt="twotime"
alias tts="tt start --tp $*"
alias ttr="tt resume $*"
alias ttp="tt pause $*"
alias ttf="tt finish $*"
alias ttfa="tt finish --all $*"
alias ttl="tt list $*"
alias c="code ."
alias dc="devcontainer open"
alias cr="code . -r"
alias ci="code-insiders ."
alias cir="code-insiders -r ."
alias vs="/mnt/c/Program\ Files/Microsoft\ Visual\ Studio/2022/Enterprise/Common7/IDE/devenv.com $*"
# when I don't have code installed, alias ci to same
command -v code || alias code="ci"
function ttfao() {
for (( i=$1; i>=0; i-- ));
do
echo finishing $i ...
ttfa -o $i
done
}
# https://coderwall.com/p/-mydag/my-best-essential-git-aliases-what-are-your-s
alias gitlog="git log --color --graph --pretty=format:'%Cgreen[%Creset%h%Cgreen]%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias gittoday="git log --color --graph --pretty=format:'%Cgreen[%Creset%h%Cgreen]%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --since=yesterday"
# https://dev.to/jmau111/another-cheat-sheet-for-bash-173j
alias whatsmyip="echo $(ifconfig -a | grep broadcast | awk '{print $2}')"
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# twotime: https://www.npmjs.com/package/twotime
alias tt="twotime"
alias tts="tt start --tp $*"
alias ttr="tt resume $*"
alias ttp="tt pause $*"
alias ttf="tt finish $*"
alias ttfa="tt finish --all $*"
alias ttl="tt list $*"
alias c="code ."
alias dc="devcontainer open"
alias cr="code . -r"
alias ci="code-insiders ."
alias cir="code-insiders -r ."
alias vs="/mnt/c/Program\ Files/Microsoft\ Visual\ Studio/2022/Enterprise/Common7/IDE/devenv.com $*"
function ttfao() {
for (( i=$1; i>=0; i-- ));
do
echo finishing $i ...
ttfa -o $i
done
}
# https://coderwall.com/p/-mydag/my-best-essential-git-aliases-what-are-your-s
alias gitlog="git log --color --graph --pretty=format:'%Cgreen[%Creset%h%Cgreen]%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias gittoday="git log --color --graph --pretty=format:'%Cgreen[%Creset%h%Cgreen]%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --since=yesterday"
# https://dev.to/jmau111/another-cheat-sheet-for-bash-173j
alias whatsMyIp="echo $(ifconfig -a | grep broadcast | awk '{print $2}')"
test -f ~/.profile && . ~/.profile
test -f ~/.bashrc && . ~/.bashrc
test -f ~/.bash_prompt && . ~/.bash_prompt
#alias docker='/mnt/c/Program\ Files/Docker/Docker/resources/bin/docker.exe'
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
#
# USAGE:
#
# 1. Save this file as ~/.bash_prompt
# 2. Add the following line to the end of your ~/.bashrc or ~/.bash_profile:
# . ~/.bash_prompt
#
# LINEAGE:
#
# Based on work by woods
#
# https://gist.github.com/31967
# The various escape codes that we can use to color our prompt.
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[1;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
CYAN="\[\033[0;36m\]"
PURPLE="\[\033[0;35m\]"
COLOR_NONE="\[\e[0m\]"
# Detect whether the current directory is a git repository.
function is_git_repository {
git branch > /dev/null 2>&1
}
# Determine the branch/state information for this git repository.
function set_git_branch {
# Capture the output of the "git status" command.
git_status="$(git status 2> /dev/null)"
# Set color based on clean/staged/dirty.
if [[ ${git_status} =~ "working directory clean" ]]; then
state="${GREEN}"
elif [[ ${git_status} =~ "Changes to be committed" ]]; then
state="${YELLOW}"
else
state="${RED}"
fi
# Set arrow icon based on status against remote.
remote_pattern="Your branch is (.*) of"
if [[ ${git_status} =~ ${remote_pattern} ]]; then
if [[ ${BASH_REMATCH[1]} == "ahead" ]]; then
remote="↑"
else
remote="↓"
fi
else
remote=""
fi
diverge_pattern="Your branch and (.*) have diverged"
if [[ ${git_status} =~ ${diverge_pattern} ]]; then
remote="↕"
fi
# Get the name of the branch.
branch_pattern="^(# )?On branch ([^${IFS}]*)"
if [[ ${git_status} =~ ${branch_pattern} ]]; then
branch=${BASH_REMATCH[2]}
fi
# Set the final branch string.
BRANCH="${state}(${branch})${remote}${COLOR_NONE} "
}
# Return the prompt symbol to use, colorized based on the return value of the
# previous command.
function set_prompt_symbol () {
if test $1 -eq 0 ; then
PROMPT_SYMBOL="\$"
else
PROMPT_SYMBOL="${LIGHT_RED}\$${COLOR_NONE}"
fi
}
# Set the full bash prompt.
function set_bash_prompt () {
# Set the PROMPT_SYMBOL variable. We do this first so we don't lose the
# return value of the last command.
set_prompt_symbol $?
# Set the BRANCH variable.
if is_git_repository ; then
set_git_branch
else
BRANCH=''
fi
# Set the bash prompt variable.
PS1="
${BLUE}\w${COLOR_NONE} ${BRANCH}
${PROMPT_SYMBOL} "
}
# Tell bash to execute this function just before displaying its prompt.
PROMPT_COMMAND=set_bash_prompt
#!/bin/bash
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
shopt -s expand_aliases
# Must set this option, else script will not expand aliases.
# ----------------------
# Git Functions
# ----------------------
# Git log find by commit message
function glf() { git log --all --grep="$1"; }
:: .dos.cmd
::
:: Run this on launch of your DOS shell with:
:: reg add "HKCU\Software\Microsoft\Command Processor" /v AutoRun ^ /t REG_EXPAND_SZ /d "%"USERPROFILE"%\.dos.cmd" /f
::
@echo off
if defined AUTORUN_HAS_BEEN_RUN exit /b
echo.
echo ### .dos.cmd ###
echo.
echo Setting up aliases...
echo.
set dircmd=/w /ogn /p
doskey ls=dir $*
doskey ll=dir /n /q /r /-w $*
:: edit this doc.
doskey alias=code %USERPROFILE%\.dos.cmd
doskey ssa=start-ssh-agent
doskey ci=code-insiders $*
:: Common directories
doskey src=cd /d c:\src
doskey home=cd /d %USERPROFILE%
:: twotime terseness
doskey onetime=twotime $*
doskey tt=twotime $*
doskey tts=twotime start --tp $*
doskey ttr=twotime resume $*
doskey ttp=twotime pause $*
doskey ttf=twotime finish $*
doskey ttfa=twotime finish --all $*
doskey ttfal=for /l %%i in ($1+0,-1,1) do twotime finish --all -o %%i
doskey ttfao=for /l %%i in ($1+0,-1,1) do twotime finish --all -o %%i
doskey ttl=twotime list $*
:: show what you did
doskey /macros:all
echo.
echo Don't forget to start SSH agent! (alias "ssa")
set AUTORUN_HAS_BEEN_RUN=1
call %comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\Tools\VsDevCmd.bat"
[winUpdater]
recentlySeenVersion = 2.24.0.windows.2
[user]
name = petevb
email = petevb@neworbit.co.uk
[core]
autocrlf = input
eol = lf
editor = 'code' --wait
filemode = false
[difftool "bc"]
path = D:\\OneDrive\\apps\\bc4\\bcomp.exe
[mergetool "bc"]
path = D:\\OneDrive\\apps\\bc4\\bcomp.exe
[diff]
tool = bc
[merge]
tool = bc
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[branch]
autosetuprebase = always
[log]
decorate = true
abbrevCommit = true
[alias]
co = checkout
cob = co -b
cod = co develop
com = co master
cp = cherry-pick
p = pull
st = status
b = branch
r = reset
rh = r --hard
rho = rh origin
rhod = rh origin/develop
logol = log --pretty=format:"%h\\ %s\\ [%cn]"
lo = log --pretty=format:"%h\\ %s\\ [%cn]"
dd = difftool --dir-diff
dt = difftool --dir-diff
work = !git lo --author petevb --before today --after \"seven days ago\"
info = !git st && echo && git remote -v
up = !git fetch && git rebase --autostash
# alternative
#up2 = !git stash save -u && git pull && git stash pop
[difftool]
prompt = true
[http]
schannelCheckRevoke = false
[pull]
rebase = true
#
# From http://cheat.errtheblog.com/s/git ...
#
[color]
ui = auto
#ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
whitespace = red reverse
[color "status"]
added = yellow
changed = green
untracked = cyan
#eof
{
"theme": "dark",
"snippet": {
"expanded": true,
"newSnippetPrivate": true,
"sorting": "updated_at",
"sortingReverse": true
},
"editor" : {
"tabSize": 4
},
"userPanel": {
"hideProfilePhoto": true
},
"logger": {
"level": "debug"
},
"proxy": {
"enable": false,
"address": "socks://localhost:1080"
},
"enterprise": {
"enable": false,
"host": "github_enterprise_host",
"token": "token_with_gist_enabled",
"avatarUrl": "optional_avatar_url"
}
}
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment