diff --git a/.config/fish/conf.d/01_env.fish b/.config/fish/conf.d/01_env.fish new file mode 100644 index 0000000..ac2f0ab --- /dev/null +++ b/.config/fish/conf.d/01_env.fish @@ -0,0 +1,6 @@ +#!/usr/bin/env fish +fish_add_path --path ~/go/bin +fish_add_path --path ~/.local/scripts + +set EDITOR nvim + diff --git a/.config/fish/conf.d/02_aliases.fish b/.config/fish/conf.d/02_aliases.fish new file mode 100644 index 0000000..4f7f818 --- /dev/null +++ b/.config/fish/conf.d/02_aliases.fish @@ -0,0 +1,16 @@ +#!/usr/bin/env fish +# nvim alias +alias vim=nvim + +## Colorize the ls output +alias ls='ls --color=auto' + +## Use a long listing format +alias ll='ls -la' + +## pwninit alias +alias pwninit='pwninit --template-path /home/daniele/.config/pwninit/pwninit-template.py' + +## alias for managing dotfiles +alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME' + diff --git a/.config/fish/conf.d/04_keybinds.fish b/.config/fish/conf.d/04_keybinds.fish new file mode 100644 index 0000000..00e2c41 --- /dev/null +++ b/.config/fish/conf.d/04_keybinds.fish @@ -0,0 +1,12 @@ +#!/usr/bin/env fish +# Set vim keybinds for autocompletition menu +bind h 'if commandline --paging-mode; commandline --function backward-char; else; commandline --insert h; end' +bind l 'if commandline --paging-mode; commandline --function forward-char; else; commandline --insert l; end' +bind j 'if commandline --paging-mode; commandline --function down-line; else; commandline --insert j; end' +bind k 'if commandline --paging-mode; commandline --function up-line; else; commandline --insert k; end' + +# tmux-sessionizer (Ctrl+n) +bind ctrl-n 'tmux-sessionizer' + +bind shift-enter 'accept-autosuggestion' + diff --git a/.config/fish/conf.d/09_launch_compositor.fish b/.config/fish/conf.d/09_launch_compositor.fish new file mode 100644 index 0000000..9a743f0 --- /dev/null +++ b/.config/fish/conf.d/09_launch_compositor.fish @@ -0,0 +1,13 @@ +#!/usr/bin/env fish +if status is-login + # Commands to run in interactive sessions can go here + + # Launch Hyprland via uwsm + # Check if we are inside a tmux session + if not set -q TMUX + if uwsm check may-start + exec uwsm start hyprland.desktop + end + end +end + diff --git a/.config/fish/config.fish b/.config/fish/config.fish new file mode 100644 index 0000000..22cb279 --- /dev/null +++ b/.config/fish/config.fish @@ -0,0 +1,3 @@ +if status is-interactive + echo -ne "\e[6 q" # Set cursor to a line (bar) style +end diff --git a/.config/fish/fish_variables b/.config/fish/fish_variables new file mode 100644 index 0000000..f40b3df --- /dev/null +++ b/.config/fish/fish_variables @@ -0,0 +1,42 @@ +# This file contains fish universal variable definitions. +# VERSION: 3.0 +SETUVAR __fish_initialized:3800 +SETUVAR fish_color_autosuggestion:666 +SETUVAR fish_color_cancel:\x2dr +SETUVAR fish_color_command:normal +SETUVAR fish_color_comment:888\x1e\x2d\x2ditalics +SETUVAR fish_color_cwd:0A0 +SETUVAR fish_color_cwd_root:A00 +SETUVAR fish_color_end:009900 +SETUVAR fish_color_error:F22 +SETUVAR fish_color_escape:0AA +SETUVAR fish_color_history_current:0AA +SETUVAR fish_color_host:normal +SETUVAR fish_color_host_remote:yellow +SETUVAR fish_color_keyword:00Afb8 +SETUVAR fish_color_match:0AA +SETUVAR fish_color_normal:B2B2B2 +SETUVAR fish_color_operator:0AA +SETUVAR fish_color_option:aaaaff +SETUVAR fish_color_param:ccccff +SETUVAR fish_color_quote:9ce781 +SETUVAR fish_color_redirection:FFF +SETUVAR fish_color_search_match:\x2d\x2dbackground\x3d533 +SETUVAR fish_color_selection:\x2d\x2dbackground\x3dB218B2 +SETUVAR fish_color_status:F22 +SETUVAR fish_color_user:brgreen +SETUVAR fish_color_valid_path:\x1d +SETUVAR fish_key_bindings:fish_default_key_bindings +SETUVAR fish_pager_color_background:\x1d +SETUVAR fish_pager_color_completion:BBB +SETUVAR fish_pager_color_description:666 +SETUVAR fish_pager_color_prefix:\x2d\x2dunderline\x1e0AA +SETUVAR fish_pager_color_progress:0AA +SETUVAR fish_pager_color_secondary_background:\x1d +SETUVAR fish_pager_color_secondary_completion:\x1d +SETUVAR fish_pager_color_secondary_description:\x1d +SETUVAR fish_pager_color_secondary_prefix:\x1d +SETUVAR fish_pager_color_selected_background:\x2d\x2dbackground\x3d333 +SETUVAR fish_pager_color_selected_completion:\x1d +SETUVAR fish_pager_color_selected_description:\x1d +SETUVAR fish_pager_color_selected_prefix:\x1d diff --git a/.config/fish/functions/fish_greeting.fish b/.config/fish/functions/fish_greeting.fish new file mode 100644 index 0000000..018520b --- /dev/null +++ b/.config/fish/functions/fish_greeting.fish @@ -0,0 +1,2 @@ +function fish_greeting +end diff --git a/.config/fish/functions/fish_prompt.fish b/.config/fish/functions/fish_prompt.fish new file mode 100644 index 0000000..c17450e --- /dev/null +++ b/.config/fish/functions/fish_prompt.fish @@ -0,0 +1,90 @@ +function fish_prompt + set -l __last_command_exit_status $status + + if not set -q -g __fish_arrow_functions_defined + set -g __fish_arrow_functions_defined + function _git_branch_name + set -l branch (git symbolic-ref --quiet HEAD 2>/dev/null) + if set -q branch[1] + echo (string replace -r '^refs/heads/' '' $branch) + else + echo (git rev-parse --short HEAD 2>/dev/null) + end + end + + function _is_git_dirty + not command git diff-index --cached --quiet HEAD -- &>/dev/null + or not command git diff --no-ext-diff --quiet --exit-code &>/dev/null + end + + function _is_git_repo + type -q git + or return 1 + git rev-parse --git-dir >/dev/null 2>&1 + end + + function _hg_branch_name + echo (hg branch 2>/dev/null) + end + + function _is_hg_dirty + set -l stat (hg status -mard 2>/dev/null) + test -n "$stat" + end + + function _is_hg_repo + fish_print_hg_root >/dev/null + end + + function _repo_branch_name + _$argv[1]_branch_name + end + + function _is_repo_dirty + _is_$argv[1]_dirty + end + + function _repo_type + if _is_hg_repo + echo hg + return 0 + else if _is_git_repo + echo git + return 0 + end + return 1 + end + end + + set -l cyan (set_color -o cyan) + set -l yellow (set_color -o yellow) + set -l red (set_color -o red) + set -l green (set_color -o green) + set -l blue (set_color -o blue) + set -l normal (set_color normal) + + set -l arrow_color "$green" + if test $__last_command_exit_status != 0 + set arrow_color "$red" + end + + set -l arrow "$arrow_color➜ " + if fish_is_root_user + set arrow "$arrow_color# " + end + + set -l cwd $green(prompt_pwd -D 3) + + set -l repo_info + if set -l repo_type (_repo_type) + set -l repo_branch $red(_repo_branch_name $repo_type) + set repo_info "$blue $repo_type:($repo_branch$blue)" + + if _is_repo_dirty $repo_type + set -l dirty "$yellow ✗" + set repo_info "$repo_info$dirty" + end + end + + echo -n -s ' '$cwd $repo_info $normal ' ' +end diff --git a/.config/fish/functions/web2app-remove.fish b/.config/fish/functions/web2app-remove.fish new file mode 100644 index 0000000..c18ba05 --- /dev/null +++ b/.config/fish/functions/web2app-remove.fish @@ -0,0 +1,20 @@ +#!/usr/bin/env fish + +# Remove a desktop launcher for a web app +function web2app-remove + # Check if the correct number of arguments is provided + if test (count $argv) -ne 1 + echo "Usage: web2app-remove " + return 1 + end + + # Assign arguments to variables + set APP_NAME $argv[1] + set ICON_DIR "$HOME/.local/share/applications/icons" + set DESKTOP_FILE "$HOME/.local/share/applications/$APP_NAME.desktop" + set ICON_PATH "$ICON_DIR/$APP_NAME.png" + + # Remove the .desktop file and icon + rm -f $DESKTOP_FILE + rm -f $ICON_PATH +end diff --git a/.config/fish/functions/web2app.fish b/.config/fish/functions/web2app.fish new file mode 100644 index 0000000..4423a86 --- /dev/null +++ b/.config/fish/functions/web2app.fish @@ -0,0 +1,42 @@ +#!/usr/bin/env fish + +# Create a desktop launcher for a web app +function web2app + # Check if the correct number of arguments is provided + if test (count $argv) -ne 3 + echo "Usage: web2app (IconURL must be in PNG -- use https://dashboardicons.com)" + return 1 + end + + # Assign arguments to variables + set APP_NAME $argv[1] + set APP_URL $argv[2] + set ICON_URL $argv[3] + set ICON_DIR "$HOME/.local/share/applications/icons" + set DESKTOP_FILE "$HOME/.local/share/applications/$APP_NAME.desktop" + set ICON_PATH "$ICON_DIR/$APP_NAME.png" + + # Create the icon directory if it doesn't exist + mkdir -p $ICON_DIR + + # Download the icon + if not curl -sL -o $ICON_PATH $ICON_URL + echo "Error: Failed to download icon." + return 1 + end + + # Create the .desktop file + echo "[Desktop Entry] +Version=1.0 +Name=$APP_NAME +Comment=$APP_NAME +Exec=chromium --new-window --ozone-platform=wayland --app=\"$APP_URL\" --name=\"$APP_NAME\" --class=\"$APP_NAME\" +Terminal=false +Type=Application +Icon=$ICON_PATH +StartupNotify=true" > $DESKTOP_FILE + + # Make the .desktop file executable + chmod +x $DESKTOP_FILE +end +