gists/windows.bashrc
2025-08-02 16:01:34 -07:00

86 lines
2.5 KiB
Bash

#!/bin/bash
# Change to VI or something else if you want a different default CLI editor.
export EDITOR=nano
# Ignore Window's specific invisible files in `ls`
alias ls='ls --color=auto --ignore="NTUSER.DAT*"'
# Use a window's kill command to attack some hokey windows foolishness that
# results in pasted text wrapping in the wrong column for a given bash window
# size. Run once per login session if the problem occors.
alias _wrapping_fix='kill -WINCH $$'
# Grep colors are your friend.
alias grep='grep --color=auto'
# diff without windows newlines
alias diff='diff --strip-trailing-cr --color=auto'
# Define the TERM variable as some processes want to know
if [[ -z "${TERM}" ]]; then
export TERM=cygwin
fi
# less and more are two utilities for reading text files at the command line.
# git bash includes the more modern `less` but not `more.` If we detect that
# `more` isn't available, set the less alias flags to replicate the behavior
# transparently
if [[ ! $(which more 2>/dev/null) ]]; then
alias more="$(which less) -XSE"
fi
export HISTIGNORE='pwd:exit:fg:bg:top:clear:history:ls:uptime:df'
export LESS='-rFX'
alias randbin='dd if=/dev/random bs=1 count=32 | base64'
# Use a GUI diff-tool when installed
if [[ -e '/c/Program Files (x86)/Meld/Meld.exe' ]]; then
alias meld='/c/Program\ Files\ \(x86\)/Meld/Meld.exe'
elif [[ -e '/cygdrive/c/Program Files (x86)/Meld/Meld.exe' ]]; then
alias meld='/cygdrive/c/Program\ Files\ \(x86\)/Meld/Meld.exe'
fi
# When notepad++ is available, use it
function npp() {
export IFS=$'\n'
NOTEPADPP_EXE='/c/Program Files/Notepad++/notepad++.exe'
if [[ -e "${NOTEPADPP_EXE}" ]]; then
echo 'notepad++.exe '$*' &'
"${NOTEPADPP_EXE}" $* &
return 0
else
echo "notepad++ not found."
return 1
fi
}
alias kate=npp
# a find alias that will ignore .git directories, but not git repo contents
function ngfind() {
export IFS=$'\n'
POSITIONAL_ARGS=()
while [[ $# -gt 0 && "${1:0:1}" != "-" ]]; do
POSITIONAL_ARGS+=("$1")
shift;
done
find ${POSITIONAL_ARGS[*]} -not -wholename '*/.git/*' $*
}
# Curl, but use netrc and automatically name files.
function nget() {
export IFS=$'\n'
URL="$1"
FN="${1##*/}"
if [[ ${#FN} -lt 1 ]]; then
echo "ERROR, zero length file name!"
else
curl -n --output "$FN" "$URL"
fi
}
function -bashrc-reload() { source ~/.bashrc }
alias __bashrc_reload='source ~/.bashrc'
# avoid some windows pain
if ! command -v python3 &>/dev/null ; then
alias python3=python
fi