Cleanup bash settings
This commit is contained in:
parent
4cd8f5fa80
commit
a29852afeb
4 changed files with 5 additions and 174 deletions
|
@ -1,9 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
# debian specific aliases
|
||||
alias pbcopy='xclip -selection clipboard'
|
||||
alias pbpaste='xclip -selection clipboard -o'
|
||||
|
||||
# Easier navigation: .., ..., ...., ....., ~ and -
|
||||
alias ..="cd .."
|
||||
alias ...="cd ../.."
|
||||
|
@ -39,79 +35,12 @@ alias less="less -R"
|
|||
# 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'
|
||||
|
||||
# IP addresses
|
||||
alias pubip="dig +short myip.opendns.com @resolver1.opendns.com"
|
||||
alias localip="ip a | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | grep -v '172.17.'"
|
||||
|
||||
# View HTTP traffic
|
||||
alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
|
||||
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""
|
||||
|
||||
# Canonical hex dump some systems have this symlinked
|
||||
command -v hd > /dev/null || alias hd="hexdump -C"
|
||||
|
||||
# OS X has no `md5sum`, so use `md5` as a fallback
|
||||
command -v md5sum > /dev/null || alias md5sum="md5"
|
||||
|
||||
# OS X has no `sha1sum`, so use `shasum` as a fallback
|
||||
command -v sha1sum > /dev/null || alias sha1sum="shasum"
|
||||
|
||||
# Trim new lines and copy to clipboard
|
||||
alias c="tr -d '\n' | xclip -selection clipboard"
|
||||
|
||||
# URL-encode strings
|
||||
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
|
||||
|
||||
# Intuitive map function
|
||||
# For example, to list all directories that contain a certain file:
|
||||
# find . -name .gitattributes | map dirname
|
||||
alias map="xargs -n1"
|
||||
|
||||
# One of @janmoesen’s ProTip™s
|
||||
for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
|
||||
alias "$method"="lwp-request -m '$method'"
|
||||
done
|
||||
|
||||
# Kill all the tabs in Chrome to free up memory
|
||||
# [C] explained: http://www.commandlinefu.com/commands/view/402/exclude-grep-from-your-grepped-output-of-ps-alias-included-in-description
|
||||
alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v extension-process | tr -s ' ' | cut -d ' ' -f2 | xargs kill"
|
||||
|
||||
# Lock the screen (when going AFK)
|
||||
alias afk="~/.bin/~/.bin/screenlock.sh"
|
||||
|
||||
# vhosts
|
||||
alias hosts='sudo vim /etc/hosts'
|
||||
|
||||
# copy working directory
|
||||
alias cwd='pwd | tr -d "\r\n" | xclip -selection clipboard'
|
||||
|
||||
# copy file interactive
|
||||
alias cp='cp -i'
|
||||
|
||||
# move file interactive
|
||||
alias mv='mv -i'
|
||||
|
||||
# untar
|
||||
alias untar='tar xvf'
|
||||
|
||||
# Pipe my public key to my clipboard.
|
||||
alias pubkey="more ~/.ssh/id.pub | xclip -selection clipboard | echo '=> Public key copied to pasteboard.'"
|
||||
|
||||
# Pipe my private key to my clipboard.
|
||||
alias privkey="more ~/.ssh/id | xclip -selection clipboard | echo '=> Private key copied to pasteboard.'"
|
||||
|
||||
# vi == vim
|
||||
alias vi='vim'
|
||||
|
||||
# vim w/ forced latin1
|
||||
alias l1vim='vim -c "e ++enc=latin1"'
|
||||
|
||||
# Temperatursensoren mit Pfad
|
||||
alias get_systemp="paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) <(ls -1 /sys/class/thermal/thermal_zone*/temp) | column -s $'\t' -t"
|
||||
|
||||
|
@ -124,5 +53,7 @@ alias y_rem='pikaur -Rsn'
|
|||
# Passwort erstellen
|
||||
alias mkpasswd='openssl rand -base64 40 | cut -c1-40'
|
||||
|
||||
# Copy latest Download into primary selection
|
||||
alias cld='cat $(ls --directory --format single-column -t --color=never ~/Downloads/* | head --lines 1) | xclip -in'
|
||||
# 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$//'\'')"'
|
||||
|
||||
|
|
|
@ -25,54 +25,6 @@ case "$TERM" in
|
|||
xterm-color) 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='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
||||
else
|
||||
PS1='\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
|
||||
|
||||
# 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$//'\'')"'
|
||||
|
||||
# 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).
|
||||
|
|
|
@ -5,8 +5,7 @@ which ruby >/dev/null 2>&1 && PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"
|
|||
export PATH=~/.local/bin:~/.bin:$PATH
|
||||
|
||||
# Make vim the default editor
|
||||
export EDITOR=vim;
|
||||
export TERMINAL="alacritty";
|
||||
export EDITOR=nvim;
|
||||
|
||||
export HISTSIZE=50000000;
|
||||
export HISTFILESIZE=$HISTSIZE;
|
||||
|
@ -40,12 +39,3 @@ export LESS_TERMCAP_md="${yellow}";
|
|||
export MANPAGER="less -X";
|
||||
|
||||
export DBUS_SESSION_BUS_ADDRESS=unix:path=/var/run/user/$(id -u)/bus;
|
||||
|
||||
export TODOTXT_DEFAULT_ACTION=ls
|
||||
|
||||
export CM_LAUNCHER=rofi
|
||||
|
||||
# hidpi for gtk apps
|
||||
#export GDK_SCALE=2
|
||||
#export GDK_DPI_SCALE=0.5
|
||||
#export QT_DEVICE_PIXEL_RATIO=2
|
||||
|
|
|
@ -45,24 +45,6 @@ fs() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Start an HTTP server from a directory, optionally specifying the port
|
||||
server() {
|
||||
local port="${1:-8000}"
|
||||
sleep 1 && open "http://localhost:${port}/" &
|
||||
# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
|
||||
# And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
|
||||
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
|
||||
}
|
||||
|
||||
# Compare original and gzipped file size
|
||||
gz() {
|
||||
local origsize=$(wc -c < "$1")
|
||||
local gzipsize=$(gzip -c "$1" | wc -c)
|
||||
local ratio=$(echo "$gzipsize * 100 / $origsize" | bc -l)
|
||||
printf "orig: %d bytes\n" "$origsize"
|
||||
printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio"
|
||||
}
|
||||
|
||||
# Run `dig` and display the most useful info
|
||||
digga() {
|
||||
dig +nocmd "$1" any +multiline +noall +answer
|
||||
|
@ -102,16 +84,6 @@ getcertnames() {
|
|||
fi
|
||||
}
|
||||
|
||||
# `o` with no arguments opens the current directory, otherwise opens the given
|
||||
# location
|
||||
o() {
|
||||
if [ $# -eq 0 ]; then
|
||||
xdg-open . > /dev/null 2>&1
|
||||
else
|
||||
xdg-open "$@" > /dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
# Get colors in manual pages
|
||||
man() {
|
||||
env \
|
||||
|
@ -125,20 +97,6 @@ man() {
|
|||
man "$@"
|
||||
}
|
||||
|
||||
# Use feh to nicely view images
|
||||
openimage() {
|
||||
local types='*.jpg *.JPG *.png *.PNG *.gif *.GIF *.jpeg *.JPEG'
|
||||
|
||||
cd $(dirname "$1")
|
||||
local file=$(basename "$1")
|
||||
|
||||
feh -q $types --auto-zoom \
|
||||
--sort filename --borderless \
|
||||
--scale-down --draw-filename \
|
||||
--image-bg black \
|
||||
--start-at "$file"
|
||||
}
|
||||
|
||||
# get the name of a x window
|
||||
xname(){
|
||||
local window_id=$1
|
||||
|
|
Loading…
Reference in a new issue