From: Jannik ZANDER Date: Sat, 7 Jul 2018 19:03:23 +0000 (+0200) Subject: Rename bash files X-Git-Url: https://git.zndr.dk/?a=commitdiff_plain;h=13ed8a5d140603a6703e2cda02c3a08046b7fcb3;p=dotfiles.git Rename bash files --- diff --git a/.config/bash/aliases b/.config/bash/aliases deleted file mode 100644 index 134e809..0000000 --- a/.config/bash/aliases +++ /dev/null @@ -1,73 +0,0 @@ -# ls with coloring -lsflags="-hF" - -# Detect which `ls` flavor is in use -if [ -x "$(which dircolors 2>/dev/null)" ]; then # GNU `ls` - colorflag="--color=auto" - lsflags="$lsflags -I NTUSER.\* -I ntuser.\*" -else # OS X `ls` - export CLICOLOR=1 - colorflag="-G" -fi - -alias ls="ls $colorflag $lsflags" -alias sl=ls -alias la='ls -A' -alias ll='ls -l' -alias l1='ls -1' -alias l.='ls -d .[a-z]*' - -# grep and less with coloring -alias grep='grep --color=auto' -alias egrep='egrep --color=auto' -alias fgrep='fgrep --color=auto' -alias less='less -m -N -g -i -J --underline-special --SILENT -X' -alias more='less' - -# Secure settings -alias rm='rm -i' -alias cp='cp -i' -alias mv='mv -i' -alias md='mkdir -p' -alias rd='rmdir' - -# My shortcuts -alias h='history' -alias info='info --vi-keys' -alias open='xdg-open &>/dev/null' -alias dit='git --git-dir=$HOME/.dit --work-tree=$HOME' -alias ag='ag --path-to-ignore=$HOME/.ignore --skip-vcs-ignores' -alias rg='rg --path-separator="//"' - -if [ ! -x "$(which tree 2>/dev/null)" ] -then - alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'" -fi - -# Enable aliases to be sudo'ed -alias sudo='sudo ' - -# Get week number -alias week='date +%V' - -# Stopwatch -alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date' - -# make date folders -alias mkdate='mkdir "$(date +'%Y%m%d')"' - -# Automatically change the directory in bash after closing ranger -function ranger-cd { - tempfile="$(mktemp -t tmp.XXXXXX)" -# /usr/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}" - ~/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}" - test -f "$tempfile" && - if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then - cd -- "$(cat "$tempfile")" - fi - rm -f -- "$tempfile" -} - -# This binds Ctrl-O to ranger-cd: -bind '"\C-o":"ranger-cd\C-m"' -alias r='ranger-cd' diff --git a/.config/bash/aliases.sh b/.config/bash/aliases.sh new file mode 100644 index 0000000..0ecbb00 --- /dev/null +++ b/.config/bash/aliases.sh @@ -0,0 +1,74 @@ +# ls with coloring +lsflags="-hF" + +# Detect which `ls` flavor is in use +if [ -x "$(which dircolors 2>/dev/null)" ]; then # GNU `ls` + colorflag="--color=auto" + lsflags="$lsflags -I NTUSER.\* -I ntuser.\*" +else # OS X `ls` + export CLICOLOR=1 + colorflag="-G" +fi + +alias ls="ls $colorflag $lsflags" +alias sl=ls +alias la='ls -A' +alias ll='ls -l' +alias l1='ls -1' +alias l.='ls -d .[a-z]*' + +# grep and less with coloring +alias grep='grep --color=auto' +alias egrep='egrep --color=auto' +alias fgrep='fgrep --color=auto' +alias less='less -m -N -g -i -J --underline-special --SILENT -X' +alias more='less' + +# Secure settings +alias rm='rm -i' +alias cp='cp -i' +alias mv='mv -i' +alias md='mkdir -p' +alias rd='rmdir' + +# My shortcuts +alias h='history' +alias q='exit' +alias info='info --vi-keys' +alias open='xdg-open &>/dev/null' +alias dit='git --git-dir=$HOME/.dit --work-tree=$HOME' +alias ag='ag --path-to-ignore=$HOME/.ignore --skip-vcs-ignores' +alias rg='rg --path-separator="//"' + +if [ ! -x "$(which tree 2>/dev/null)" ] +then + alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'" +fi + +# Enable aliases to be sudo'ed +alias sudo='sudo ' + +# Get week number +alias week='date +%V' + +# Make directory named todays date +alias mkdate='mkdir "$(date +'%Y%m%d')"' + +# Stopwatch +alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date' + + +# Automatically change the directory in bash after closing ranger +function ranger-cd { + tempfile="$(mktemp -t tmp.XXXXXX)" + ~/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}" + test -f "$tempfile" && + if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then + cd -- "$(cat "$tempfile")" + fi + rm -f -- "$tempfile" +} + +# This binds Ctrl-O to ranger-cd: +bind '"\C-o":"ranger-cd\C-m"' +alias r='ranger-cd' diff --git a/.config/bash/completion b/.config/bash/completion deleted file mode 100644 index 938c3af..0000000 --- a/.config/bash/completion +++ /dev/null @@ -1,12 +0,0 @@ -# Add tab completion for many Bash commands -[ -f /etc/bash_completion ] && . /etc/bash_completion - -# Enable tab completion for `dit` by marking it as an alias for `git` -if type _git &> /dev/null; then - complete -o default -o nospace -F _git dit; -fi; - -# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards -if [ -e "$HOME/.ssh/config" ]; then - complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2 | tr ' ' '\n')" scp sftp ssh; -fi; diff --git a/.config/bash/completion.sh b/.config/bash/completion.sh new file mode 100644 index 0000000..938c3af --- /dev/null +++ b/.config/bash/completion.sh @@ -0,0 +1,12 @@ +# Add tab completion for many Bash commands +[ -f /etc/bash_completion ] && . /etc/bash_completion + +# Enable tab completion for `dit` by marking it as an alias for `git` +if type _git &> /dev/null; then + complete -o default -o nospace -F _git dit; +fi; + +# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards +if [ -e "$HOME/.ssh/config" ]; then + complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2 | tr ' ' '\n')" scp sftp ssh; +fi; diff --git a/.config/bash/options b/.config/bash/options deleted file mode 100644 index 9d648a2..0000000 --- a/.config/bash/options +++ /dev/null @@ -1,20 +0,0 @@ -# Case-insensitive globbing (used in pathname expansion) -shopt -s nocaseglob - -# Append to the Bash history file, rather than overwriting it -shopt -s histappend - -# Autocorrect typos in path names when using `cd` -shopt -s cdspell - -# Enable some Bash 4 features when possible: -# * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux` -# * Recursive globbing, e.g. `echo **/*.txt` -for option in autocd globstar; do - shopt -s "$option" 2> /dev/null; -done; - -# Don't use ^D to exit -set -o ignoreeof -set -o vi - diff --git a/.config/bash/options.sh b/.config/bash/options.sh new file mode 100644 index 0000000..9d648a2 --- /dev/null +++ b/.config/bash/options.sh @@ -0,0 +1,20 @@ +# Case-insensitive globbing (used in pathname expansion) +shopt -s nocaseglob + +# Append to the Bash history file, rather than overwriting it +shopt -s histappend + +# Autocorrect typos in path names when using `cd` +shopt -s cdspell + +# Enable some Bash 4 features when possible: +# * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux` +# * Recursive globbing, e.g. `echo **/*.txt` +for option in autocd globstar; do + shopt -s "$option" 2> /dev/null; +done; + +# Don't use ^D to exit +set -o ignoreeof +set -o vi +