Skip to content

Instantly share code, notes, and snippets.

@dek4nice
Last active April 12, 2022 06:35
Show Gist options
  • Save dek4nice/cb551c01013a169e14929e741b069170 to your computer and use it in GitHub Desktop.
Save dek4nice/cb551c01013a169e14929e741b069170 to your computer and use it in GitHub Desktop.
d3 bash aliases
# .bash_d3_aliases
# You may uncomment the following lines if you want `ls' to be colorized:
# some more ls aliases
if [ -x /usr/bin/dircolors ]; then
export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -laF'
alias la='ls $LS_OPTIONS -lAF'
alias lm='ls $LS_OPTIONS -mA'
alias l='ls $LS_OPTIONS -CF'
alias llc='ls $LS_OPTIONS -la | column -t'
fi
# grc
if [ -x /usr/bin/grc ]; then
alias ping='grc ping'
alias traceroute='grc traceroute'
alias make='grc make'
alias diff='grc diff'
alias cvs='grc cvs'
alias netstat='grc netstat'
alias logc='grc cat'
alias logt='grc tail'
alias logh='grc head'
alias less='less --RAW-CONTROL-CHARS'
fi
# git aliases
if [ -x /usr/bin/git ]; then
# alias ggo='git checkout'
alias gia='git add'
alias gib='git branch'
alias gif='git diff'
# alias gic='git commit'
alias gis='git status'
alias gih='git stash'
alias gihl='git stash list'
alias giha='git stash apply'
alias gihp='git stash pop'
alias giss='git submodule status'
alias gisf='git submodule foreach -q'
alias gism='git submodule summary'
alias giqa='git commit --amend --no-edit'
# alias gisu='git submodule update --init'
# alias gip='git cherry-pick'
# alias girh='git reset --hard'
# alias girs='git reset --soft'
# alias gih='git show'
# alias gin='git show --name-only'
# git lambdas
function giq { git commit -m "$*"; }
# function gil { if [ -z $1 ]; then git lg; else git lg -$1; fi }
function gitls () {
if [ -z "$1" ]; then
git ls-tree -rt `git write-tree`
else
git ls-tree -rt `git write-tree` "$1"
fi
}
function gitpwd () {
git write-tree --prefix="$1"
}
fi
# docker aliases
if [ -x /usr/bin/docker ]; then
alias docps='docker ps --all --format "table {{.ID}}|{{.Names}}\t{{.Image}}\t[{{.Status}}]\t{{.Command}}"'
alias docimg='docker image ls --all --format "table {{.ID}} ({{.Size}})\t@ {{.Repository}} \t: {{.Tag}}"'
fi
# screen
if [ -x /usr/bin/screen ]; then
alias sl='screen -ls'
alias sr='screen -r'
alias sx='screen -x'
alias swork='screen -x work'
alias spro='screen -x pro'
fi
# d3k aliases
alias h='host'
alias ds='dropbox status'
alias dfh='df -hl -x tmpfs -x devtmpfs | sed 1d'
alias service-runned='service --status-all | grep -e +'
alias ls-links='ls -la . | grep -e "->"'
# npm
alias npm-lsg='npm ls -g --depth=0'
# ping
alias p='ping'
alias p8='pp 8.8.8.8'
alias py='pp ya.ru'
function pp { ping "$1" -c 2; }
# sshagent
SSH_SOCK_PATH=~/.ssh/ssh_auth_sock
function sshagent_list () { ls -lt /tmp/ssh-*/agent.* 2> /dev/null | grep $(whoami) | awk '{print $9}'; }
alias sshagent_last_get='sshagent_list | head -n 1'
alias sshagent_checkout='echo env SSH_AUTH_SOCK: $SSH_AUTH_SOCK; echo env SSH_AGENT_PID: $SSH_AGENT_PID; echo SSH_SOCK_PATH: $SSH_SOCK_PATH'
alias sshagent_clear='unset SSH_AUTH_SOCK SSH_AGENT_PID'
alias sshagent_add02='ssh-add ~/.ssh/ihos-init-02'
# Case Functions
function amiroot {
return $(test `id -u` -eq 0)
}
function mkdircd () {
mkdir "$1";
cd "$1";
}
function cgi-fcgi-run {
# http://127.0.0.1:9000/ping
SCRIPT_NAME=$2 \
SCRIPT_FILENAME=$2 \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect 127.0.0.1:$1
}
function saveiptables {
if amiroot; then
if ! test -z "$1"; then
cd /root/rctmp/data
iptables-save > $1
chown ihos $1
chgrp ihoshandle $1
fi
else
echo 'iptables-save should be run under root'
fi
}
# folder_move_to_gzip node_modules
function folder_move_to_gzip {
if [[ -d "$1" ]]; then
du -sh "$1/";
read -n1 -r -p "Press a key to continue..." key;
tar --remove-files -cf "$1.tar" "$1"/;
gzip "$1.tar";
mkdir "$1";
else
echo \'"$1"\' not found
fi
}
function sshagent_create {
if [ ! -S $SSH_SOCK_PATH ]; then
eval `ssh-agent`
ln -sf "$SSH_AUTH_SOCK" $SSH_SOCK_PATH
fi
# ls -ld $SSH_SOCK_PATH
}
function sshagent_reset_agent_socketpid {
local last_agent_socket=$(sshagent_last_get)
if test -n $last_agent_socket; then
echo '>' ssh-agent socket found;
echo '>' \$last_agent_socket : $last_agent_socket;
[ -z "$SSH_AUTH_SOCK" ] && SSH_AUTH_SOCK=$last_agent_socket;
# [ -z "$SSH_AGENT_PID" -a -n $socket_pid ] && SSH_AGENT_PID=$(($socket_pid + 1));
[ -z "$SSH_AGENT_PID" ] && {
local socket_pid=`echo $last_agent_socket | cut -d. -f2`;
echo '>' \$socket_pid : $socket_pid;
[ -n $socket_pid ] && SSH_AGENT_PID=$(($socket_pid + 1));
};
[ -n "$SSH_AUTH_SOCK" ] && {
export SSH_AUTH_SOCK;
ln -sf "$SSH_AUTH_SOCK" $SSH_SOCK_PATH
};
[ -n "$SSH_AGENT_PID" ] && export SSH_AGENT_PID;
echo '>' agent environment reseted;
return 0;
else
echo '>' no ssh agent running;
return 1;
fi;
}
# ~/.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'
# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'
# 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
if [ -f ~/.bash_d3_aliases ]; then
. ~/.bash_d3_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
[core]
excludesfile = /home/dim/.gitignore
editor = vim
# symlinks = false
[user]
name = Dmitriy Ilyenkov
email = [email protected]
[alias]
wt = worktree
soft = reset --soft
hard = reset --hard
pick = cherry-pick
tree = ls-tree -r -t --full-tree
files = ls-files --modified
pwd = write-tree
last = rev-parse HEAD
unstage = restore --staged
logfile = lgd --follow
lg = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'
lgn = log --pretty=oneline
lgd = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
lgf = log --pretty=format:'%H %t %p | %ad | %s%d [%an]' --date=iso
# --all --graph --decorate
lga = log --all --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'
lg0 = log --all --graph --abbrev-commit --decorate --date=relative --format=format:'%h - (%ar) %s - %an%d'
lg1 = log --all --graph --decorate=short --color --format=format:'%C(bold blue)%h%C(reset) %C(auto)%d%C(reset)\n %C(black)[%cr]%C(reset) %x09%C(black)%an: %s %C(reset)'
lg2 = log --all --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
lgx = log --all --graph --decorate=short --color --format=format:'%C(bold blue)%h%C(reset)+%C(dim black)(%cr)%C(reset)+%C(auto)%d%C(reset)++\n+++ %C(bold black)%an%C(reset)%C(black): %s%C(reset)'
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[credential "bitbucket.org"]
interactive = always
[credential "https://gitlab.com"]
helper = store --file ~/.gitlab-credentials
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment