diff --git a/shells/shared/aliases b/shells/shared/aliases index 29bd4c5f..2f405849 100644 --- a/shells/shared/aliases +++ b/shells/shared/aliases @@ -148,7 +148,8 @@ alias updateTime="sudo ntpd -qg" # Keyboard - reset # Sometimes, if I turn the screens off, the keyboard resets itself to defaults. Not sure why but this will put my keyboard back to how I like it -alias kb="xmodmap ~/.Xmodmap; xset r rate 200 70; xcape" +#alias kb="xmodmap ~/.Xmodmap; xset r rate 200 70; xcape" +alias kb="setxkbmap -layout gb,gb -variant \"colemak,\" -option grp:shifts_toggle; xset r rate 200 70; xinput --list | grep -E 'ErgoDox EZ ErgoDox EZ\s+id' | grep -oE 'id=[0-9]+' | cut -d'=' -f2 | xargs setxkbmap -layout gb -device" alias colemak="setxkbmap -layout gb,gb -variant \"colemak,\" -option grp:shifts_toggle" alias qwerty="setxkbmap -layout gb" @@ -157,7 +158,7 @@ alias ol="open-local" alias globalip="drill myip.opendns.com @resolver1.opendns.com | sed -n '/ANSWER SECTION/,/AUTHORITY SECTION/ p' | sed -n '2 p' | awk '{print \$5}'" -alias ss="cat /usr/share/exploitdb/files_exploits.csv | fzf | cut -d',' -f1 | xargs searchsploit -m" +alias ss="tail -n +2 /usr/share/exploitdb/files_exploits.csv | awk -F ',' '{print \$2 \"\t\" \$3 \"\t(\" \$1 \")\"}' | fzf --preview-window=up --preview='echo {} | cut -d\" \" -f1 | xargs echo \"/usr/share/exploitdb/\" | tr -d \" \" | xargs bat --color=always' | cut -d' ' -f3 | tr -d \"()\" | xargs searchsploit -m" alias ddg="ddgr" diff --git a/shells/shared/functions b/shells/shared/functions index ed7ad72e..a0e6cf8f 100644 --- a/shells/shared/functions +++ b/shells/shared/functions @@ -247,3 +247,47 @@ function ssh(){ source $HOME/.dotfiles/shells/zsh/current-color-scheme fi } + +function proxy_on() { + export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com" + + if (( $# > 0 )); then + valid=$(echo $@ | sed -n 's/\([0-9]\{1,3\}.\?\)\{4\}:\([0-9]\+\)/&/p') + if [[ $valid != $@ ]]; then + >&2 echo "Invalid address" + return 1 + fi + local proxy=$1 + export http_proxy="$proxy" \ + https_proxy=$proxy \ + ftp_proxy=$proxy \ + rsync_proxy=$proxy + echo "Proxy environment variable set." + return 0 + fi + + echo -n "username: "; read username + if [[ $username != "" ]]; then + echo -n "password: " + read -es password + local pre="$username:$password@" + fi + + echo -n "server: "; read server + echo -n "port: "; read port + local proxy=$pre$server:$port + export http_proxy="$proxy" \ + https_proxy=$proxy \ + ftp_proxy=$proxy \ + rsync_proxy=$proxy \ + HTTP_PROXY=$proxy \ + HTTPS_PROXY=$proxy \ + FTP_PROXY=$proxy \ + RSYNC_PROXY=$proxy +} + +function proxy_off(){ + unset http_proxy https_proxy ftp_proxy rsync_proxy \ + HTTP_PROXY HTTPS_PROXY FTP_PROXY RSYNC_PROXY + echo -e "Proxy environment variable removed." +} diff --git a/shells/zsh/oh-my-zsh-core b/shells/zsh/oh-my-zsh-core index 6d2221e6..52f58785 160000 --- a/shells/zsh/oh-my-zsh-core +++ b/shells/zsh/oh-my-zsh-core @@ -1 +1 @@ -Subproject commit 6d2221e697ea4a2445202b1c32283610f84585ef +Subproject commit 52f58785645c18aa88ea515d070a42bcfe97508d diff --git a/shells/zsh/oh-my-zsh-custom/fzf.zsh b/shells/zsh/oh-my-zsh-custom/fzf.zsh index 891c3494..b39f1cea 100644 --- a/shells/zsh/oh-my-zsh-custom/fzf.zsh +++ b/shells/zsh/oh-my-zsh-custom/fzf.zsh @@ -1,6 +1,7 @@ # this rg command will get a list of files that are not in gitignore or similar export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude .git" -export FZF_DEFAULT_OPTS="--preview '[[ \$(file --mime {}) =~ binary ]] && echo {} is a binary file || ( bat --style=numbers --color=always {} || cat {}) 2> /dev/null | head -500'" +export FZF_DEFAULT_OPTS="--preview '[[ \$(file -L --mime {}) =~ binary ]] && echo {} is a binary file || ( bat --style=numbers --color=always {} || cat {}) 2> /dev/null | head -500'" +export FZF_CTRL_R_OPTS="--no-preview" # this is the argument completeion optionm, use the same command export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" if [ -e /usr/share/fzf/key-bindings.zsh ]; then @@ -9,22 +10,40 @@ if [ -e /usr/share/fzf/key-bindings.zsh ]; then # CTRL-W to select a wordlist __fsel_wordlist() { - local cmd="$FZF_DEFAULT_COMMAND '' /usr/share/wordlists/" - setopt localoptions pipefail 2> /dev/null - eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" $(__fzfcmd) -m "$@" | while read item; do - echo -n "${(q)item} " - done - local ret=$? - echo - return $ret + local cmd="$FZF_DEFAULT_COMMAND --exclude \*.md --exclude \*.gif --exclude \*.jpg --exclude \*.png --exclude \*.lua --exclude \*.jar --exclude \*.pl '' /usr/share/wordlists/ | sed 's#^/usr/share/wordlists/##'" + setopt localoptions pipefail 2> /dev/null + eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS --preview 'bat --color=always /usr/share/wordlists/{}'" $(__fzfcmd) -m "$@" | while read item; do + echo -n "/usr/share/wordlists/${(q)item} " + done + local ret=$? + echo + return $ret } fzf-wordlist-widget() { - LBUFFER="${LBUFFER}$(__fsel_wordlist)" - local ret=$? - zle reset-prompt - return $ret + LBUFFER="${LBUFFER}$(__fsel_wordlist)" + local ret=$? + zle reset-prompt + return $ret } zle -N fzf-wordlist-widget bindkey '^W' fzf-wordlist-widget + + # CTRL-P to select an IP address from project host + __fsel_ip() { + setopt localoptions pipefail 2> /dev/null + project hosts ip --fzf + + local ret=$? + return $ret + } + + fzf-ip-widget() { + LBUFFER="${LBUFFER}$(project hosts ip --fzf) " + local ret=$? + zle reset-prompt + return $ret + } + zle -N fzf-ip-widget + bindkey '^P' fzf-ip-widget fi