Post

Flying in Linux Mint

Flying in Linux Mint

Workspaces

I have set up 12 workspaces. Sounds a lot on paper, but it isn’t. Here are they with the specific workspace number:

  1. Communication
  2. Workspace
  3. Workspace
  4. Other
  5. Main 1
  6. Main 2
  7. Main 3
  8. Other
  9. Calendar
  10. Workspace
  11. Music
  12. Other

My setup

My current setup is:

  1. Communication - Discord, Mail, Messenger, Whatsapp, Telegram, Signal, everything communications related stays here
  2. Study - not used a lot, but nice to have. Here I read and write notes, read presentations and so on
  3. Blog - here I keep a console so I can quickly draft and write posts
  4. Other - empty for now
  5. Main 1 - work tasks
  6. Main 2 - work tasks
  7. Main 3 - work tasks (We have a lot of different projects, so I need to divide them so it is easier to switch context fast)
  8. Other - some personal projects I work on rarely, but still want to have them on hand
  9. Calendar - I use TikTik, so I can just quickly jump to this workspace with ‘Ctrl Alt 1’, then press ‘N’ and create a task, easy as that
  10. This is for university extracariculars. Here I keep my TEDx stuff open for quick access.
  11. Music - Spotify and YouTube always here. I use Brave to play music from YouTube without ads.
  12. Other - empty for now

Linux mint has these very useful keyboard shortcuts:

  • “Switch to workspace X”
  • “Move window to workspace X”

ZSH

I use zsh as a terminal.

It’s very useful for its easy history search and autosuggestions.

Here are my custom aliases in ~/.config/.zsh_aliases

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
alias j='jekyll'
alias kk='kill -9'

# Show tree with file sizes
# alias tree='tree -CAhF --dirsfirst'

alias mountedinfo='df -hT'

# Show all logs in /var/log
alias logs="sudo find /var/log -type f -exec file {} \; | grep 'text' | cut -d' ' -f1 | sed -e's/:$//g' | grep -v '[0-9]$' | xargs tail -f"


# To see if a command is aliased, a file, or a built-in command
alias checkcommand="type -t"


# Search files in the current folder
alias f="find . | grep "

# Search running processes
alias p="ps aux | grep "

# Search command line history
alias h="history | grep "

# alias to show the date
alias da='date "+%Y-%m-%d %A %T %Z"'

alias cls="clear"

alias c="code"
alias cn="code -n"


#######################################################
# Networking
#######################################################

# Show open ports
alias openports='netstat -nape --inet'


#######################################################
# Files and Directories
#######################################################
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

alias o='open'

#######################################################
# Git and GitHub
#######################################################
alias s='git status'
alias a='git add '
alias d='git diff '
alias gc='git checkout '
alias grst='git restore --staged'

alias log='git log --pretty=format:"%C(yellow)%h %C(#775f2c)%ad%Cred%d %Creset%s%Cblue [%cn]" --decorate --date=short'
alias b='git rev-parse --abbrev-ref HEAD'

alias ghil='gh issue list'
alias ghiv='gh issue view '
alias ghid='gh issue develop -c '

alias ghicw='gh issue create --web'

#######################################################
# Ruby on Rails
#######################################################
alias r='rails'
alias rdbms='rails db:migrate:status'
alias rdbreset='rails db:drop db:create db:schema:load db:seed'
alias rce='EDITOR="code --wait" rails credentials:edit -e development'
alias rtests='RAILS_ENV=test rdbreset && rspec'
#######################################################
#
#######################################################

alias c="code -n"

Here is the ~/.zshrc setup:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Personal Zsh configuration file. It is strongly recommended to keep all
# shell customization and configuration (including exported environment
# variables such as PATH) in this file or in files sourced from it.
#
# Documentation: https://github.com/romkatv/zsh4humans/blob/v5/README.md.

# Periodic auto-update on Zsh startup: 'ask' or 'no'.
# You can manually run `z4h update` to update everything.
zstyle ':z4h:' auto-update      'no'
# Ask whether to auto-update this often; has no effect if auto-update is 'no'.
zstyle ':z4h:' auto-update-days '28'

# Keyboard type: 'mac' or 'pc'.
zstyle ':z4h:bindkey' keyboard  'pc'

# Start tmux if not already in tmux.
# Commenting it out as I am not ready yet. Too much of a hasle
# zstyle ':z4h:' start-tmux command tmux -u new -A -D -t z4h

# Whether to move prompt to the bottom when zsh starts and on Ctrl+L.
zstyle ':z4h:' prompt-at-bottom 'no'

# Mark up shell's output with semantic information.
zstyle ':z4h:' term-shell-integration 'yes'

# Right-arrow key accepts one character ('partial-accept') from
# command autosuggestions or the whole thing ('accept')?
zstyle ':z4h:autosuggestions' forward-char 'accept'

# Recursively traverse directories when TAB-completing files.
zstyle ':z4h:fzf-complete' recurse-dirs 'no'

# Enable direnv to automatically source .envrc files.
zstyle ':z4h:direnv'         enable 'no'
# Show "loading" and "unloading" notifications from direnv.
zstyle ':z4h:direnv:success' notify 'yes'

# Enable ('yes') or disable ('no') automatic teleportation of z4h over
# SSH when connecting to these hosts.
zstyle ':z4h:ssh:example-hostname1'   enable 'yes'
zstyle ':z4h:ssh:*.example-hostname2' enable 'no'
# The default value if none of the overrides above match the hostname.
zstyle ':z4h:ssh:*'                   enable 'no'

# Send these files over to the remote host when connecting over SSH to the
# enabled hosts.
zstyle ':z4h:ssh:*' send-extra-files '~/.nanorc' '~/.env.zsh'

# Clone additional Git repositories from GitHub.
#
# This doesn't do anything apart from cloning the repository and keeping it
# up-to-date. Cloned files can be used after `z4h init`. This is just an
# example. If you don't plan to use Oh My Zsh, delete this line.
z4h install ohmyzsh/ohmyzsh || return

# Install or update core components (fzf, zsh-autosuggestions, etc.) and
# initialize Zsh. After this point console I/O is unavailable until Zsh
# is fully initialized. Everything that requires user interaction or can
# perform network I/O must be done above. Everything else is best done below.
z4h init || return

# Extend PATH.
path=(~/bin $path)

# Export environment variables.
export GPG_TTY=$TTY

# Source additional local files if they exist.
z4h source ~/.env.zsh

# Use additional Git repositories pulled in with `z4h install`.
#
# This is just an example that you should delete. It does nothing useful.
z4h source ohmyzsh/ohmyzsh/lib/diagnostics.zsh  # source an individual file
z4h load   ohmyzsh/ohmyzsh/plugins/emoji-clock  # load a plugin

# Define key bindings.
z4h bindkey z4h-backward-kill-word  Ctrl+Backspace     Ctrl+H
z4h bindkey z4h-backward-kill-zword Ctrl+Alt+Backspace

z4h bindkey undo Ctrl+/ Shift+Tab  # undo the last command line change
z4h bindkey redo Alt+/             # redo the last undone command line change

z4h bindkey z4h-cd-back    Alt+Left   # cd into the previous directory
z4h bindkey z4h-cd-forward Alt+Right  # cd into the next directory
z4h bindkey z4h-cd-up      Alt+Up     # cd into the parent directory
z4h bindkey z4h-cd-down    Alt+Down   # cd into a child directory

# Autoload functions.
autoload -Uz zmv

# Define functions and completions.
function md() { [[ $# == 1 ]] && mkdir -p -- "$1" && cd -- "$1" }
compdef _directories md

# Define named directories: ~w <=> Windows home directory on WSL.
[[ -z $z4h_win_home ]] || hash -d w=$z4h_win_home

# Define aliases.
alias tree='tree -a -I .git'

# Add flags to existing aliases.
# alias ls="${aliases[ls]:-ls} -A"

# Set shell options: http://zsh.sourceforge.net/Doc/Release/Options.html.
setopt glob_dots     # no special treatment for file names with a leading dot
setopt no_auto_menu  # require an extra TAB press to open the completion menu



#################################
# Mine
#################################

alias e="code -n ~/.config/.zsh_aliases ~/.zshrc ~/.config/.zsh_workspaces ~/.local/bin/./workspace-startup.sh ~/.config/.zsh_commands"
alias reload="exec zsh"

source ~/.config/.zsh_aliases
source ~/.config/.zsh_commands
source ~/.config/.zsh_workspaces

export EDITOR="code"


# TODO: Ruby doesn't work otherwise. I should fix it
export PATH="$PATH:$HOME/.rvm/bin"

# TODO: Vs Code doesn't work otherwise. I should fix it
export PATH="$PATH:/usr/share/code/bin"

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

Here are the ~/.config/.zsh_workspaces. I use this to quickly go into projects and open an editor.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Full setup
# We run the script with "." to ensure that the terminal used to run the script is used for the workspace
alias work=". $HOME/.local/bin/./workspace-startup.sh"


# Set useful aliases for changing directories to workspaces and opening vscode quickly
alias wo='cd ~/Programming/work'
typeset -A work_projects=(
  woa "$HOME/Programming/work/project1"
  wob "$HOME/Work/blog"
  woc "$HOME/Programming/work/company/some_project"
  woe "$HOME/Programming/personal/rails/some_project"
  wog "$HOME/Programming/work/some_project"
  woi "$HOME/Programming/work/company/some_project"
  woj "$HOME/Programming/personal/rails/some_project"
  wom "$HOME/Programming/personal/rails/some_project/"
  wor "$HOME/Programming/personal/rails/some_project"
  wot "$HOME/Programming/personal/rails/some_project"
  wow "$HOME/Programming/work/company/some_project"
)


# Loop through array and create aliases
for alias_base in ${(k)work_projects}; do
  alias $alias_base="cd '${work_projects[$alias_base]}'"
  alias ${alias_base}c="cd '${work_projects[$alias_base]}' && code ."
done

Custom zsh commands in ~/.config/.zsh_commands:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
mkvmp4() {
  if [ -z "$1" ]; then
    echo "Usage: mkvmp4 <input.mkv>"
    return 1
  fi

  input="$1"
  output="${input%.mkv}.mp4"

  ffmpeg -i "$input" "$output"
}

mp43() {
  if [ -z "$1" ]; then
    echo "Usage: mp43 <input.mp4>"
    return 1
  fi

  input="$1"
  output="${input%.mp4}.mp3"

  ffmpeg -i "$input" "$output"
}

difftext(){
  diff <(echo "$1") <(echo "$2")
}



# Open file explorer
fex(){
    if [ "$#" -ne 1 ]; then
        gio open . >/dev/null 2>&1 &;
    else
        gio open $1 >/dev/null 2>&1 &;
    fi
}



# Make a dir and cd into it
mkcdir(){
    mkdir -p -- "$1"
    cd -P -- "$1"
}



## Make a custom alias
## == not working in zsh for some reason
# addalias() {
#     if [ "$#" -lt 1 ]; then
#         echo "Usage:"
#         echo "  addalias <alias_name> <command>   - Add a custom alias"
#         echo "  addalias -c <alias_name>          - Create an alias to cd into the current directory"
#         return 1
#     fi

#     if [ "$1" == "-c" ]; then
#         if [ -z "$2" ]; then
#             echo "Usage: addalias -c <alias_name>"
#             return 1
#         fi
#         ALIAS_NAME="$2"
#         ALIAS_COMMAND="cd $(pwd)"
#     else
#         if [ "$#" -ne 2 ]; then
#             echo "Usage: addalias <alias_name> <command>"
#             return 1
#         fi
#         ALIAS_NAME="$1"
#         ALIAS_COMMAND="$2"
#     fi

#     # Check if a command with the same name exists
#     if type "$ALIAS_NAME" &>/dev/null; then
#         echo "Error: '$ALIAS_NAME' is already a command. Choose a different alias name."
#         return 1
#     fi

#     # Check if the alias already exists in ~/.config/.zsh_aliases
#     if grep -q "^alias $ALIAS_NAME=" ~/.config/.zsh_aliases; then
#         echo "Alias '$ALIAS_NAME' already exists in ~/.config/.zsh_aliases. Use a different name."
#         return 1
#     fi

#     # Add a newline before adding the alias for better readability
#     echo -e "\nalias $ALIAS_NAME=\"$ALIAS_COMMAND\"" >> ~/.config/.zsh_aliases
#     echo "Alias '$ALIAS_NAME' added successfully."

#     # Reload ~/.bashrc to apply changes
#     source ~/.bashrc
# }

I don’t use this anymore, bc I just sleep my computer, but it is useful for an automatic startup after reboot ~/.local/bin/./workspace-startup.sh:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash

# Spotify in "Music" workspace (Workspace 5)
spotify &
sleep 2
wmctrl -r "Spotify" -t 5
wmctrl -r "Spotify" -b add,maximized_vert,maximized_horz

# Discord in "Coms" workspace (Workspace 0)
flatpak run com.discordapp.Discord &

# Terminal, VS Code, and Brave in "Axlessoft" workspace (Workspace 1)
wmctrl -s 1
gnome-terminal --working-directory=$HOME/Programming/work/company/project &
sleep 1
wmctrl -r "Programming/work/company/project" -e 0,0,0,960,1080
wmctrl -a "Programming/work/company/project"
brave-browser &
code --new-window $HOME/Programming/work/company/project &
sleep 1

# Move discord, after we have given it enough time to load
wmctrl -r "Discord" -t 0
wmctrl -r "Discord" -b add,maximized_vert,maximized_horz

exit 0
This post is licensed under CC BY-NC 4.0 by the author.