diff --git a/.bash_aliases b/.bash_aliases index ac11de4..fedb5ae 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -1,24 +1,28 @@ -# launch Ghidra -alias ghidra='~/Apps/ghidra/ghidraRun' - # take a nap (suspend the system) alias nap='systemctl suspend' -# launch apktool -alias apktool='java -jar ~/Apps/apktool/apktool.jar' - # lanuch pwninit with a custom template alias pwninit='~/Apps/pwninit/pwninit --template-path ~/.config/pwninit-template.py' # get sorted disk usage for current working directory alias gdu='du -shl * | sort -h' -# start firefox -alias ffp='firefox -private-window &' - # delete branches no longer on remote # from: https://stackoverflow.com/questions/7726949/remove-tracking-branches-no-longer-on-remote alias gitlodel='git fetch -p && for branch in $(git for-each-ref --format '\''%(refname) %(upstream:track)'\'' refs/heads | awk '\''$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'\''); do git branch -D $branch; done' # remove tracking branches no longer on remote alias gitredel='git remote prune origin' + +# nvim +alias vim="nvim" +alias vi="nvim" +alias v="nvim" + +# Python +alias p="python3" +alias py="python3" +alias py2="python2" + +# Search for a directory and cd into it +alias sd='cd $(find ~ -type d | fzf)' diff --git a/.bashrc b/.bashrc index 2f1fe3f..0b53957 100644 --- a/.bashrc +++ b/.bashrc @@ -1,131 +1,39 @@ -# ~/.bashrc: executed by bash(1) for non-login shells. -# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) -# for examples +# .bashrc -# 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) +# Source global definitions +if [ -f /etc/bashrc ]; then + . /etc/bashrc 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 +# Colored prompt +# [user@host:~ ]$ +# PS1='${debian_chroot:+($debian_chroot)}[\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] ]\$ ' +# user@host:~$ +PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' -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\$ ' +# User specific environment +if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]] +then + PATH="$HOME/.local/bin:$HOME/bin:$PATH" fi -unset color_prompt force_color_prompt +export PATH -# 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 -alF' -alias la='ls -A' -alias l='ls -CF' - -# 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$//'\'')"' - -# 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. +# Uncomment the following line if you don't like systemctl's auto-paging feature: +# export SYSTEMD_PAGER= +# Alias definitions if [ -f ~/.bash_aliases ]; then . ~/.bash_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 - -# ===== Extra Paths ===== -export PATH="$HOME/dev/pwn.kr/COMMANDS:$PATH" -# added my Scripts to PATH -export PATH="$HOME/Scripts:$PATH" -export PATH="$HOME/Scripts/secrets:$PATH" +# Extra Paths +export PATH="$HOME/.config/scripts:$PATH" -# ===== Source Custom Functions ===== +# Source Custom Functions if [ -f ~/.bash_functions ]; then . ~/.bash_functions fi # ===== Default Programs ===== -export EDITOR="vim" +export EDITOR="nvim" +export PAGER="less" diff --git a/.window_bindings b/.window_bindings new file mode 100755 index 0000000..7adc11c --- /dev/null +++ b/.window_bindings @@ -0,0 +1,82 @@ +#!/bin/sh + +# Note that there's a known bug with Wayland, which sometimes doesn't display all windows (like GNOME apps): +# https://bugs.launchpad.net/ubuntu/+source/gnome-terminal/+bug/1725991 +# Recommended to switch to Xorg if you encounter this issue. + +toggle_brave() { + # If Brave is running, focus it. Otherwise, open it. + # If the --incognito flag is set, do the same for a private window. + INCOGNITO_MAGIC_STRING='Private Tab' + if [[ "$1" == '--incognito' ]]; then + # The window title for incognito windows is postfixed with 'Private Tab' when using my extension + WINDOW_ID=$(wmctrl -l | grep -F -- "$INCOGNITO_MAGIC_STRING - Brave" | awk '{print $1}') + if [ -n "$WINDOW_ID" ]; then + wmctrl -i -a "$WINDOW_ID" + else + brave-browser --incognito & + fi + else + WINDOW_ID=$(wmctrl -l | grep -Fv -- "$INCOGNITO_MAGIC_STRING - Brave" | grep -F -- '- Brave' | awk '{print $1}') + if [ -n "$WINDOW_ID" ]; then + wmctrl -i -a "$WINDOW_ID" + else + brave-browser & + fi + fi +} + +toggle_obsidian() { + # If Obsidian is running, focus it. Otherwise, open it. + if wmctrl -l | grep -q "Obsidian"; then + wmctrl -xa "obsidian.obsidian" + else + ~/Apps/obsidian/Obsidian.AppImage & + fi +} + +toggle_generic_app() { + # If the app is running, focus it. Otherwise, open it. + if wmctrl -lx | grep -iq "$1"; then + wmctrl -xa "$2" + else + $1 & + fi +} + +toggle_terminal() { + toggle_generic_app "gnome-terminal" "gnome.Terminal.Gnome-terminal" +} + +toggle_vscode() { + toggle_generic_app "code" "code.Code" +} + +toggle_file_manager() { + toggle_generic_app "nautilus" "org.gnome.Nautilus" +} + +# Handle supplied argument +case "$1" in + brave) + toggle_brave + ;; + brave-incognito) + toggle_brave --incognito + ;; + obsidian) + toggle_obsidian + ;; + terminal) + toggle_terminal + ;; + vscode) + toggle_vscode + ;; + files) + toggle_file_manager + ;; + *) + echo "Invalid option. Use: brave, brave-incognito, obsidian, terminal, vscode, files" + ;; +esac diff --git a/README.md b/README.md index bc6dced..3d0f37c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # Scripts + Some bash scripts I use for handling my linux machine. Nothing Fancy here :) diff --git a/auto_mount.md b/auto_mount.md deleted file mode 100644 index 82f1c5c..0000000 --- a/auto_mount.md +++ /dev/null @@ -1,12 +0,0 @@ -# Mount my drive on boot -``` -UUID=01D6E903EBEC3D70 /media/D auto nodev,x-gvfs-show,remove_hiberfile 0 0 -``` -### Mount the drive when booting: -```shell -sudo vim /etc/fstab -# at the bottom of the file, add the entry above -# now to test that the configuration works, run: -sudo mount -a -# if you see no errors, the fstab entry is correct and you're safe to reboot -``` diff --git a/biuftp b/biuftp deleted file mode 100755 index a5a22d8..0000000 --- a/biuftp +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# import username from secrets.sh and open a sftp connection -source "secrets.sh" && sftp -J $biu_username@vpn.esc.biu.ac.il:2222 $biu_username@planet.cs.biu.ac.il diff --git a/biussh b/biussh deleted file mode 100755 index 7473b1b..0000000 --- a/biussh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# import username from secrets.sh and open a ssh connection -source "secrets.sh" && ssh -J $biu_username@vpn.esc.biu.ac.il:2222 $biu_username@planet.cs.biu.ac.il diff --git a/init.sh b/init.sh new file mode 100755 index 0000000..12a86e8 --- /dev/null +++ b/init.sh @@ -0,0 +1,2 @@ +# To install run: echo '@reboot //init.sh' | crontab -e +mkdir -p /tmp/downloads diff --git a/mount_d_drive b/mount_d_drive deleted file mode 100755 index 5b105b7..0000000 --- a/mount_d_drive +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# Mount the D drive - -MOUNT_POINT="/media/D" - -if [ ! -d "$MOUNT_POINT" ]; then - sudo mkdir "$MOUNT_POINT" -fi - -# Warning!! this will destroy any unsaved data that is in the hibernated Windows session -sudo ntfs-3g -o remove_hiberfile /dev/sdb1 "$MOUNT_POINT"